This repository was archived by the owner on Apr 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathInterpreterData.cs
More file actions
186 lines (148 loc) · 4.73 KB
/
Copy pathInterpreterData.cs
File metadata and controls
186 lines (148 loc) · 4.73 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
//------------------------------------------------------------------------------
// <license file="InterpreterData.cs">
//
// The use and distribution terms for this software are contained in the file
// named 'LICENSE', which can be found in the resources directory of this
// distribution.
//
// By using this software in any fashion, you are agreeing to be bound by the
// terms of this license.
//
// </license>
//------------------------------------------------------------------------------
using System;
using EcmaScript.NET.Debugging;
using EcmaScript.NET.Collections;
namespace EcmaScript.NET
{
internal sealed class InterpreterData : DebuggableScript
{
public bool TopLevel
{
get
{
return topLevel;
}
}
public string FunctionName
{
get
{
return itsName;
}
}
public int ParamCount
{
get
{
return argCount;
}
}
public int ParamAndVarCount
{
get
{
return argNames.Length;
}
}
public string SourceName
{
get
{
return itsSourceFile;
}
}
public bool GeneratedScript
{
get
{
return ScriptRuntime.isGeneratedScript (itsSourceFile);
}
}
public int [] LineNumbers
{
get
{
return Interpreter.getLineNumbers (this);
}
}
public int FunctionCount
{
get
{
return (itsNestedFunctions == null) ? 0 : itsNestedFunctions.Length;
}
}
public DebuggableScript Parent
{
get
{
return parentData;
}
}
internal const int INITIAL_MAX_ICODE_LENGTH = 1024;
internal const int INITIAL_STRINGTABLE_SIZE = 64;
internal const int INITIAL_NUMBERTABLE_SIZE = 64;
internal InterpreterData (Context.Versions languageVersion, string sourceFile, string encodedSource)
{
this.languageVersion = languageVersion;
this.itsSourceFile = sourceFile;
this.encodedSource = encodedSource;
Init ();
}
internal InterpreterData (InterpreterData parent)
{
this.parentData = parent;
this.languageVersion = parent.languageVersion;
this.itsSourceFile = parent.itsSourceFile;
this.encodedSource = parent.encodedSource;
Init ();
}
private void Init ()
{
itsICode = new sbyte [INITIAL_MAX_ICODE_LENGTH];
itsStringTable = new string [INITIAL_STRINGTABLE_SIZE];
}
internal string itsName;
internal string itsSourceFile;
internal bool itsNeedsActivation;
internal int itsFunctionType;
internal string [] itsStringTable;
internal double [] itsDoubleTable;
internal InterpreterData [] itsNestedFunctions;
internal object [] itsRegExpLiterals;
internal sbyte [] itsICode;
internal int [] itsExceptionTable;
internal int itsMaxVars;
internal int itsMaxLocals;
internal int itsMaxStack;
internal int itsMaxFrameArray;
// see comments in NativeFuncion for definition of argNames and argCount
internal string [] argNames;
internal int argCount;
internal int itsMaxCalleeArgs;
internal string encodedSource;
internal int encodedSourceStart;
internal int encodedSourceEnd;
internal Context.Versions languageVersion;
internal bool useDynamicScope;
internal bool topLevel;
internal object [] literalIds;
internal UintMap longJumps;
internal int firstLinePC = -1; // PC for the first LINE icode
internal InterpreterData parentData;
internal bool evalScriptFlag; // true if script corresponds to eval() code
public bool IsFunction ()
{
return itsFunctionType != 0;
}
public string GetParamOrVarName (int index)
{
return argNames [index];
}
public DebuggableScript GetFunction (int index)
{
return itsNestedFunctions [index];
}
}
}