forked from chakra-core/ChakraCore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModuleRecordBase.h
More file actions
56 lines (52 loc) · 2.52 KB
/
Copy pathModuleRecordBase.h
File metadata and controls
56 lines (52 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
#pragma once
namespace Js
{
class ModuleRecordBase;
class ModuleNamespace;
typedef SList<PropertyId> ExportedNames;
typedef SList<ModuleRecordBase*> ExportModuleRecordList;
struct ModuleNameRecord
{
ModuleNameRecord(const ModuleNameRecord& other)
:module(other.module), bindingName(other.bindingName)
{}
ModuleNameRecord(ModuleRecordBase* module, PropertyId bindingName)
:module(module), bindingName(bindingName)
{}
ModuleNameRecord() {}
Field(ModuleRecordBase*) module;
Field(PropertyId) bindingName;
};
typedef SList<ModuleNameRecord> ResolveSet;
// ModuleRecord need to keep rootFunction etc. alive.
class ModuleRecordBase : public FinalizableObject
{
public:
static const uint32 ModuleMagicNumber;
ModuleRecordBase(JavascriptLibrary* library) :
namespaceObject(nullptr), wasEvaluated(false),
javascriptLibrary(library), magicNumber(ModuleMagicNumber){};
bool WasEvaluated() { return wasEvaluated; }
void SetWasEvaluated() { Assert(!wasEvaluated); wasEvaluated = true; }
JavascriptLibrary* GetRealm() { return javascriptLibrary; } // TODO: do we need to provide this method ?
virtual ModuleNamespace* GetNamespace() { return namespaceObject; }
virtual void SetNamespace(ModuleNamespace* moduleNamespace) { namespaceObject = moduleNamespace; }
virtual ExportedNames* GetExportedNames(ExportModuleRecordList* exportStarSet) = 0;
// return false when "ambiguous".
// otherwise nullptr means "null" where we have circular reference/cannot resolve.
virtual bool ResolveExport(PropertyId exportName, ResolveSet* resolveSet, ModuleNameRecord** exportRecord) = 0;
virtual bool ModuleDeclarationInstantiation() = 0;
virtual void GenerateRootFunction() = 0;
virtual Var ModuleEvaluation() = 0;
virtual bool IsSourceTextModuleRecord() { return false; }
protected:
Field(uint32) magicNumber;
Field(ModuleNamespace*) namespaceObject;
Field(bool) wasEvaluated;
Field(JavascriptLibrary*) javascriptLibrary;
};
}