Skip to content

Commit d6f122b

Browse files
authored
Add Runtime + tests (sb#5)
* Emitting done * Finished Runtime with debugger * Added runtime tests
1 parent 2a66f7c commit d6f122b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+5987
-317
lines changed

build/generate-loc-strings.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ ${Object.keys(entries).map(entryName => ` ${entryName}`).join(",\n")}
1414
case Keys.${entryName}:
1515
return "${entries[entryName]}";`).join("")}
1616
default:
17-
throw "Key not found: " + key;
17+
throw new Error("Key not found: " + key);
1818
}
1919
}
2020
}

build/generate-models.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function generateContents(model: IModelDefinition): string {
6060
let memberType = member.attributes.type;
6161

6262
if (member.attributes.array && member.attributes.optional) {
63-
throw `Member ${memberName} cannot be an array and optional at the same time`;
63+
throw new Error(`Member ${memberName} cannot be an array and optional at the same time`);
6464
}
6565

6666
if (!includes(memberType, model.attributes.kind)) {
@@ -102,7 +102,7 @@ function generateContents(model: IModelDefinition): string {
102102
type.children = type.children || [];
103103

104104
if (!endsWith(typeName, model.attributes.kind)) {
105-
throw `Type ${typeName} doesn't end with ${model.attributes.kind}`;
105+
throw new Error(`Type ${typeName} doesn't end with ${model.attributes.kind}`);
106106
}
107107

108108
types.push({

build/models/bound-statements.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767

6868
<ArrayAssignmentBoundStatement>
6969
<identifier type="string" />
70-
<indexes type="BaseBoundExpression" array="true" />
70+
<indices type="BaseBoundExpression" array="true" />
7171
<value type="BaseBoundExpression" />
7272
</ArrayAssignmentBoundStatement>
7373

build/models/instructions.xml

+118
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
<root kind="Instruction">
2+
<StatementStartInstruction>
3+
<line type="number" />
4+
</StatementStartInstruction>
5+
6+
<TempLabelInstruction>
7+
<name type="string" />
8+
</TempLabelInstruction>
9+
10+
<TempJumpInstruction>
11+
<target type="string" />
12+
</TempJumpInstruction>
13+
14+
<TempConditionalJumpInstruction>
15+
<trueTarget type="string" optional="true" />
16+
<falseTarget type="string" optional="true" />
17+
</TempConditionalJumpInstruction>
18+
19+
<JumpInstruction>
20+
<target type="number" />
21+
</JumpInstruction>
22+
23+
<ConditionalJumpInstruction>
24+
<trueTarget type="number" optional="true" />
25+
<falseTarget type="number" optional="true" />
26+
</ConditionalJumpInstruction>
27+
28+
<CallSubModuleInstruction>
29+
<name type="string" />
30+
</CallSubModuleInstruction>
31+
32+
<CallLibraryMethodInstruction>
33+
<library type="string" />
34+
<method type="string" />
35+
</CallLibraryMethodInstruction>
36+
37+
<StoreVariableInstruction>
38+
<name type="string" />
39+
</StoreVariableInstruction>
40+
41+
<StoreArrayElementInstruction>
42+
<name type="string" />
43+
<indices type="number" />
44+
<sourceRange type="TextRange" />
45+
</StoreArrayElementInstruction>
46+
47+
<StorePropertyInstruction>
48+
<library type="string" />
49+
<property type="string" />
50+
</StorePropertyInstruction>
51+
52+
<LoadVariableInstruction>
53+
<name type="string" />
54+
</LoadVariableInstruction>
55+
56+
<LoadArrayElementInstruction>
57+
<name type="string" />
58+
<indices type="number" />
59+
<sourceRange type="TextRange" />
60+
</LoadArrayElementInstruction>
61+
62+
<LoadPropertyInstruction>
63+
<library type="string" />
64+
<property type="string" />
65+
</LoadPropertyInstruction>
66+
67+
<MethodCallInstruction>
68+
<library type="string" />
69+
<method type="string" />
70+
<argumentsCount type="number" />
71+
</MethodCallInstruction>
72+
73+
<NegateInstruction>
74+
<sourceRange type="TextRange" />
75+
</NegateInstruction>
76+
77+
<EqualInstruction>
78+
</EqualInstruction>
79+
80+
<LessThanInstruction>
81+
</LessThanInstruction>
82+
83+
<GreaterThanInstruction>
84+
</GreaterThanInstruction>
85+
86+
<LessThanOrEqualInstruction>
87+
</LessThanOrEqualInstruction>
88+
89+
<GreaterThanOrEqualInstruction>
90+
</GreaterThanOrEqualInstruction>
91+
92+
<AddInstruction>
93+
<sourceRange type="TextRange" />
94+
</AddInstruction>
95+
96+
<SubtractInstruction>
97+
<sourceRange type="TextRange" />
98+
</SubtractInstruction>
99+
100+
<MultiplyInstruction>
101+
<sourceRange type="TextRange" />
102+
</MultiplyInstruction>
103+
104+
<DivideInstruction>
105+
<sourceRange type="TextRange" />
106+
</DivideInstruction>
107+
108+
<PushNumberInstruction>
109+
<value type="number" />
110+
</PushNumberInstruction>
111+
112+
<PushStringInstruction>
113+
<value type="string" />
114+
</PushStringInstruction>
115+
116+
<ReturnInstruction>
117+
</ReturnInstruction>
118+
</root>

build/strings/en/errors.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,9 @@
2323
"UnsupportedDotBaseExpression": "You can only use dot access with a library. Did you mean to use an existing library instead?",
2424
"LibraryMemberNotFound": "The library '{0}' has no member named '{1}'.",
2525
"ValueIsNotANumber": "The value '{0}' is not a valid number.",
26-
"ValueIsNotAssignable": "You cannot assign to this expression. Did you mean to use a variable instead?"
26+
"ValueIsNotAssignable": "You cannot assign to this expression. Did you mean to use a variable instead?",
27+
"CannotUseAnArrayAsAnIndexToAnotherArray": "You cannot use an array as an index to access another array. Did you mean to use a string or a number instead?",
28+
"CannotUseOperatorWithAnArray": "You cannot use the operator '{0}' with an array value",
29+
"CannotUseOperatorWithAString": "You cannot use the operator '{0}' with a string value",
30+
"CannotDivideByZero": "You cannot divide by zero. Please consider checking the divisor before dividing."
2731
}

gulpfile.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ gulp.task("generate-syntax-commands", () => generateModels("syntax-commands"));
2020
gulp.task("generate-syntax-statements", () => generateModels("syntax-statements"));
2121
gulp.task("generate-bound-statements", () => generateModels("bound-statements"));
2222
gulp.task("generate-bound-expressions", () => generateModels("bound-expressions"));
23+
gulp.task("generate-instructions", () => generateModels("instructions"));
2324

2425
gulp.task("generate-models", [
2526
"generate-syntax-expressions",
2627
"generate-syntax-commands",
2728
"generate-syntax-statements",
2829
"generate-bound-expressions",
29-
"generate-bound-statements"
30+
"generate-bound-statements",
31+
"generate-instructions"
3032
]);
3133

3234
gulp.task("watch-source", ["generate-models", "generate-loc-strings"], () => {

0 commit comments

Comments
 (0)