| 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 24 matching lines...) Expand all Loading... |
| 35 date.setTime(time); | 35 date.setTime(time); |
| 36 return date; | 36 return date; |
| 37 } | 37 } |
| 38 | 38 |
| 39 | 39 |
| 40 var kApiFunctionCache = new InternalArray(); | 40 var kApiFunctionCache = new InternalArray(); |
| 41 var functionCache = kApiFunctionCache; | 41 var functionCache = kApiFunctionCache; |
| 42 | 42 |
| 43 | 43 |
| 44 function Instantiate(data, name) { | 44 function Instantiate(data, name) { |
| 45 %DebugBreak(); |
| 45 if (!%IsTemplate(data)) return data; | 46 if (!%IsTemplate(data)) return data; |
| 46 var tag = %GetTemplateField(data, kApiTagOffset); | 47 var tag = %GetTemplateField(data, kApiTagOffset); |
| 47 switch (tag) { | 48 switch (tag) { |
| 48 case kFunctionTag: | 49 case kFunctionTag: |
| 49 return InstantiateFunction(data, name); | 50 return InstantiateFunction(data, name); |
| 50 case kNewObjectTag: | 51 case kNewObjectTag: |
| 51 var Constructor = %GetTemplateField(data, kApiConstructorOffset); | 52 var Constructor = %GetTemplateField(data, kApiConstructorOffset); |
| 52 // Note: Do not directly use a function template as a condition, our | 53 // Note: Do not directly use a function template as a condition, our |
| 53 // internal ToBoolean doesn't handle that! | 54 // internal ToBoolean doesn't handle that! |
| 54 var result = typeof Constructor === 'undefined' ? | 55 var result = typeof Constructor === 'undefined' ? |
| (...skipping 17 matching lines...) Expand all Loading... |
| 72 if (!isFunctionCached) { | 73 if (!isFunctionCached) { |
| 73 try { | 74 try { |
| 74 cache[serialNumber] = null; | 75 cache[serialNumber] = null; |
| 75 var fun = %CreateApiFunction(data); | 76 var fun = %CreateApiFunction(data); |
| 76 if (name) %FunctionSetName(fun, name); | 77 if (name) %FunctionSetName(fun, name); |
| 77 cache[serialNumber] = fun; | 78 cache[serialNumber] = fun; |
| 78 var prototype = %GetTemplateField(data, kApiPrototypeTemplateOffset); | 79 var prototype = %GetTemplateField(data, kApiPrototypeTemplateOffset); |
| 79 var flags = %GetTemplateField(data, kApiFlagOffset); | 80 var flags = %GetTemplateField(data, kApiFlagOffset); |
| 80 // Note: Do not directly use an object template as a condition, our | 81 // Note: Do not directly use an object template as a condition, our |
| 81 // internal ToBoolean doesn't handle that! | 82 // internal ToBoolean doesn't handle that! |
| 83 %DebugBreak(); |
| 82 fun.prototype = typeof prototype === 'undefined' ? | 84 fun.prototype = typeof prototype === 'undefined' ? |
| 83 {} : Instantiate(prototype); | 85 {} : Instantiate(prototype); |
| 84 if (flags & (1 << kReadOnlyPrototypeBit)) { | 86 if (flags & (1 << kReadOnlyPrototypeBit)) { |
| 85 %FunctionSetReadOnlyPrototype(fun); | 87 %FunctionSetReadOnlyPrototype(fun); |
| 86 } | 88 } |
| 87 %SetProperty(fun.prototype, "constructor", fun, DONT_ENUM); | 89 %SetProperty(fun.prototype, "constructor", fun, DONT_ENUM); |
| 88 var parent = %GetTemplateField(data, kApiParentTemplateOffset); | 90 var parent = %GetTemplateField(data, kApiParentTemplateOffset); |
| 89 // Note: Do not directly use a function template as a condition, our | 91 // Note: Do not directly use a function template as a condition, our |
| 90 // internal ToBoolean doesn't handle that! | 92 // internal ToBoolean doesn't handle that! |
| 91 if (!(typeof parent === 'undefined')) { | 93 if (!(typeof parent === 'undefined')) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 113 var prop_data = properties[i + 2]; | 115 var prop_data = properties[i + 2]; |
| 114 var attributes = properties[i + 3]; | 116 var attributes = properties[i + 3]; |
| 115 var value = Instantiate(prop_data, name); | 117 var value = Instantiate(prop_data, name); |
| 116 %SetProperty(obj, name, value, attributes); | 118 %SetProperty(obj, name, value, attributes); |
| 117 } | 119 } |
| 118 } finally { | 120 } finally { |
| 119 if (requires_access_checks) %EnableAccessChecks(obj); | 121 if (requires_access_checks) %EnableAccessChecks(obj); |
| 120 } | 122 } |
| 121 } | 123 } |
| 122 } | 124 } |
| OLD | NEW |