RuntimeFunction.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. #pragma once
  6. namespace Js
  7. {
  8. class RuntimeFunction : public JavascriptFunction
  9. {
  10. protected:
  11. DEFINE_VTABLE_CTOR(RuntimeFunction, JavascriptFunction);
  12. DEFINE_MARSHAL_OBJECT_TO_SCRIPT_CONTEXT(RuntimeFunction);
  13. RuntimeFunction(DynamicType * type);
  14. public:
  15. RuntimeFunction(DynamicType * type, FunctionInfo * functionInfo);
  16. RuntimeFunction(DynamicType * type, FunctionInfo * functionInfo, ConstructorCache* cache);
  17. void SetFunctionNameId(Var nameId);
  18. // This is for cached source string for the function. Possible values are:
  19. // NULL; initialized for anonymous methods.
  20. // propertyId in Int31 format; this is used for fastDOM function as well as library function
  21. // JavascriptString: composed using functionname from the propertyId, or fixed string for anonymous functions.
  22. // NOTE: This has a side-effect that after toString() is called for the first time on a built-in function the functionNameId gets replaced with a string like "function foo() { native code }".
  23. // As a result any code like debugger(F12) that shows the functionNameId to the user will need to pre-process this string as it may not be desirable to use this as-is in some cases.
  24. // See RuntimeFunction::EnsureSourceString() for details.
  25. Field(bool) isDisplayString;
  26. Field(Var) functionNameId;
  27. virtual Var GetSourceString() const { return functionNameId; }
  28. virtual JavascriptString * EnsureSourceString();
  29. #if ENABLE_TTD
  30. public:
  31. virtual void MarkVisitKindSpecificPtrs(TTD::SnapshotExtractor* extractor) override;
  32. virtual TTD::NSSnapObjects::SnapObjectType GetSnapTag_TTD() const override;
  33. virtual void ExtractSnapObjectDataInto(TTD::NSSnapObjects::SnapObject* objData, TTD::SlabAllocator& alloc) override;
  34. #endif
  35. };
  36. };