OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 var serialNumber = %GetTemplateField(data, kApiSerialNumberOffset); | 66 var serialNumber = %GetTemplateField(data, kApiSerialNumberOffset); |
67 var isFunctionCached = | 67 var isFunctionCached = |
68 (serialNumber in cache) && (cache[serialNumber] != kUninitialized); | 68 (serialNumber in cache) && (cache[serialNumber] != kUninitialized); |
69 if (!isFunctionCached) { | 69 if (!isFunctionCached) { |
70 try { | 70 try { |
71 cache[serialNumber] = null; | 71 cache[serialNumber] = null; |
72 var fun = %CreateApiFunction(data); | 72 var fun = %CreateApiFunction(data); |
73 if (name) %FunctionSetName(fun, name); | 73 if (name) %FunctionSetName(fun, name); |
74 cache[serialNumber] = fun; | 74 cache[serialNumber] = fun; |
75 var prototype = %GetTemplateField(data, kApiPrototypeTemplateOffset); | 75 var prototype = %GetTemplateField(data, kApiPrototypeTemplateOffset); |
76 fun.prototype = prototype ? Instantiate(prototype) : {}; | 76 var properties = %GetTemplateField(data, kApiPrototypePropertiesOffset); |
| 77 if (properties != NONE) { |
| 78 %IgnoreAttributesAndSetProperty( |
| 79 fun, "prototype", |
| 80 prototype ? Instantiate(prototype) : {}, |
| 81 properties); |
| 82 } else { |
| 83 fun.prototype = prototype ? Instantiate(prototype) : {}; |
| 84 } |
77 %SetProperty(fun.prototype, "constructor", fun, DONT_ENUM); | 85 %SetProperty(fun.prototype, "constructor", fun, DONT_ENUM); |
78 var parent = %GetTemplateField(data, kApiParentTemplateOffset); | 86 var parent = %GetTemplateField(data, kApiParentTemplateOffset); |
79 if (parent) { | 87 if (parent) { |
80 var parent_fun = Instantiate(parent); | 88 var parent_fun = Instantiate(parent); |
81 fun.prototype.__proto__ = parent_fun.prototype; | 89 fun.prototype.__proto__ = parent_fun.prototype; |
82 } | 90 } |
83 ConfigureTemplateInstance(fun, data); | 91 ConfigureTemplateInstance(fun, data); |
84 } catch (e) { | 92 } catch (e) { |
85 cache[serialNumber] = kUninitialized; | 93 cache[serialNumber] = kUninitialized; |
86 throw e; | 94 throw e; |
(...skipping 14 matching lines...) Expand all Loading... |
101 var prop_data = properties[i + 2]; | 109 var prop_data = properties[i + 2]; |
102 var attributes = properties[i + 3]; | 110 var attributes = properties[i + 3]; |
103 var value = Instantiate(prop_data, name); | 111 var value = Instantiate(prop_data, name); |
104 %SetProperty(obj, name, value, attributes); | 112 %SetProperty(obj, name, value, attributes); |
105 } | 113 } |
106 } finally { | 114 } finally { |
107 if (requires_access_checks) %EnableAccessChecks(obj); | 115 if (requires_access_checks) %EnableAccessChecks(obj); |
108 } | 116 } |
109 } | 117 } |
110 } | 118 } |
OLD | NEW |