UNPKG

2.88 kBSource Map (JSON)View Raw
1{"version":3,"sources":["../../src/values/FunctionValue.js"],"names":["FunctionValue","ObjectValue","constructor","realm","intrinsicName","intrinsics","FunctionPrototype","getName","Error","getKind","getLength","binding","properties","get","desc","descriptor","value","NumberValue","undefined","hasDefaultLength","getDebugName"],"mappings":";;;;;;;AAcA;;AACA;;;;AAfA;;;;;;;;;AAiBA;AACe,MAAMA,aAAN,SAA4BC,kBAA5B,CAAwC;AACrDC,cAAYC,KAAZ,EAA0BC,aAA1B,EAAkD;AAChD,UAAMD,KAAN,EAAaA,MAAME,UAAN,CAAiBC,iBAA9B,EAAiDF,aAAjD;AACD;;AAaDG,YAAkB;AAChB,UAAM,IAAIC,KAAJ,CAAU,iBAAV,CAAN;AACD;;AAEDC,YAAsB;AACpB,WAAO,UAAP;AACD;;AAEDC,cAA2B;AACzB,QAAIC,UAAU,KAAKC,UAAL,CAAgBC,GAAhB,CAAoB,QAApB,CAAd;AACA,4BAAUF,OAAV;AACA,QAAIG,OAAOH,QAAQI,UAAnB;AACA,4BAAUD,IAAV;AACA,QAAIE,QAAQF,KAAKE,KAAjB;AACA,QAAI,EAAEA,iBAAiBC,kBAAnB,CAAJ,EAAqC,OAAOC,SAAP;AACrC,WAAOF,MAAMA,KAAb;AACD;;AAEDG,qBAA4B;AAC1B,4BAAU,KAAV,EAAiB,kCAAjB;AACD;;AAEDC,iBAAuB;AACrB,WAAO,MAAMA,YAAN,MAAwB,KAAKb,OAAL,EAA/B;AACD;;AAxCoD","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\n\nimport type { ObjectKind } from \"../types.js\";\nimport type { LexicalEnvironment } from \"../environment.js\";\nimport type { Realm } from \"../realm.js\";\nimport { ObjectValue, NumberValue } from \"./index.js\";\nimport invariant from \"../invariant.js\";\n\n/* Abstract base class for all function objects */\nexport default class FunctionValue extends ObjectValue {\n constructor(realm: Realm, intrinsicName?: string) {\n super(realm, realm.intrinsics.FunctionPrototype, intrinsicName);\n }\n\n $Environment: LexicalEnvironment;\n $ScriptOrModule: any;\n\n // Indicates whether this function has been referenced by a __residual call.\n // If true, the serializer will check that the function does not access any\n // identifiers defined outside of the local scope.\n isResidual: void | true;\n\n // Allows for residual function with inference of parameters\n isUnsafeResidual: void | true;\n\n getName(): string {\n throw new Error(\"Abstract method\");\n }\n\n getKind(): ObjectKind {\n return \"Function\";\n }\n\n getLength(): void | number {\n let binding = this.properties.get(\"length\");\n invariant(binding);\n let desc = binding.descriptor;\n invariant(desc);\n let value = desc.value;\n if (!(value instanceof NumberValue)) return undefined;\n return value.value;\n }\n\n hasDefaultLength(): boolean {\n invariant(false, \"abstract method; please override\");\n }\n\n getDebugName(): string {\n return super.getDebugName() || this.getName();\n }\n}\n"],"file":"FunctionValue.js"}
\No newline at end of file