Index: src/apinatives.js |
diff --git a/src/apinatives.js b/src/apinatives.js |
index ccbedd6d397455aa18f2b26bcda172683ba750c7..d93ed80374e7bb51eef94915f1f7e09f7f05a1a3 100644 |
--- a/src/apinatives.js |
+++ b/src/apinatives.js |
@@ -75,22 +75,26 @@ function InstantiateFunction(data, name) { |
var fun = %CreateApiFunction(data); |
if (name) %FunctionSetName(fun, name); |
cache[serialNumber] = fun; |
- var prototype = %GetTemplateField(data, kApiPrototypeTemplateOffset); |
var flags = %GetTemplateField(data, kApiFlagOffset); |
- // Note: Do not directly use an object template as a condition, our |
- // internal ToBoolean doesn't handle that! |
- fun.prototype = typeof prototype === 'undefined' ? |
- {} : Instantiate(prototype); |
- if (flags & (1 << kReadOnlyPrototypeBit)) { |
- %FunctionSetReadOnlyPrototype(fun); |
- } |
- %SetProperty(fun.prototype, "constructor", fun, DONT_ENUM); |
- var parent = %GetTemplateField(data, kApiParentTemplateOffset); |
- // Note: Do not directly use a function template as a condition, our |
- // internal ToBoolean doesn't handle that! |
- if (!(typeof parent === 'undefined')) { |
- var parent_fun = Instantiate(parent); |
- %SetPrototype(fun.prototype, parent_fun.prototype); |
+ if (flags & (1 << kRemovePrototypeBit)) { |
+ %FunctionRemovePrototype(fun); |
+ } else { |
+ var prototype = %GetTemplateField(data, kApiPrototypeTemplateOffset); |
+ // Note: Do not directly use an object template as a condition, our |
+ // internal ToBoolean doesn't handle that! |
+ fun.prototype = typeof prototype === 'undefined' ? |
+ {} : Instantiate(prototype); |
+ if (flags & (1 << kReadOnlyPrototypeBit)) { |
+ %FunctionSetReadOnlyPrototype(fun); |
+ } |
+ %SetProperty(fun.prototype, "constructor", fun, DONT_ENUM); |
+ var parent = %GetTemplateField(data, kApiParentTemplateOffset); |
+ // Note: Do not directly use a function template as a condition, our |
+ // internal ToBoolean doesn't handle that! |
+ if (!(typeof parent === 'undefined')) { |
+ var parent_fun = Instantiate(parent); |
+ %SetPrototype(fun.prototype, parent_fun.prototype); |
+ } |
} |
ConfigureTemplateInstance(fun, data); |
} catch (e) { |