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 var attributes = %GetTemplateField(data, kApiPrototypeAttributesOffset); | 76 var flags = %GetTemplateField(data, kApiFlagOffset); |
77 if (attributes != NONE) { | 77 fun.prototype = prototype ? Instantiate(prototype) : {}; |
78 %IgnoreAttributesAndSetProperty( | 78 if (flags & (1 << kReadOnlyPrototypeBit)) { |
79 fun, "prototype", | 79 %FunctionReadOnlyPrototype(fun); |
80 prototype ? Instantiate(prototype) : {}, | |
81 attributes); | |
82 } else { | |
83 fun.prototype = prototype ? Instantiate(prototype) : {}; | |
84 } | 80 } |
85 %SetProperty(fun.prototype, "constructor", fun, DONT_ENUM); | 81 %SetProperty(fun.prototype, "constructor", fun, DONT_ENUM); |
86 var parent = %GetTemplateField(data, kApiParentTemplateOffset); | 82 var parent = %GetTemplateField(data, kApiParentTemplateOffset); |
87 if (parent) { | 83 if (parent) { |
88 var parent_fun = Instantiate(parent); | 84 var parent_fun = Instantiate(parent); |
89 fun.prototype.__proto__ = parent_fun.prototype; | 85 fun.prototype.__proto__ = parent_fun.prototype; |
90 } | 86 } |
91 ConfigureTemplateInstance(fun, data); | 87 ConfigureTemplateInstance(fun, data); |
92 } catch (e) { | 88 } catch (e) { |
93 cache[serialNumber] = kUninitialized; | 89 cache[serialNumber] = kUninitialized; |
(...skipping 15 matching lines...) Expand all Loading... |
109 var prop_data = properties[i + 2]; | 105 var prop_data = properties[i + 2]; |
110 var attributes = properties[i + 3]; | 106 var attributes = properties[i + 3]; |
111 var value = Instantiate(prop_data, name); | 107 var value = Instantiate(prop_data, name); |
112 %SetProperty(obj, name, value, attributes); | 108 %SetProperty(obj, name, value, attributes); |
113 } | 109 } |
114 } finally { | 110 } finally { |
115 if (requires_access_checks) %EnableAccessChecks(obj); | 111 if (requires_access_checks) %EnableAccessChecks(obj); |
116 } | 112 } |
117 } | 113 } |
118 } | 114 } |
OLD | NEW |