mlogjs 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +2 -2
- package/build/Compiler.js +104 -99
- package/build/Compiler.js.map +1 -1
- package/build/CompilerError.js +11 -0
- package/build/CompilerError.js.map +1 -0
- package/build/Scope.js +70 -60
- package/build/Scope.js.map +1 -1
- package/build/bin.js +74 -60
- package/build/bin.js.map +1 -1
- package/build/handlers/BlockStatement.js +13 -13
- package/build/handlers/BlockStatement.js.map +1 -1
- package/build/handlers/CallExpression.js +19 -19
- package/build/handlers/CallExpression.js.map +1 -1
- package/build/handlers/File.js +9 -0
- package/build/handlers/File.js.map +1 -0
- package/build/handlers/ForStatement.js +31 -31
- package/build/handlers/ForStatement.js.map +1 -1
- package/build/handlers/Function.js +46 -35
- package/build/handlers/Function.js.map +1 -1
- package/build/handlers/Identifier.js +7 -7
- package/build/handlers/IfStatement.js +24 -24
- package/build/handlers/IfStatement.js.map +1 -1
- package/build/handlers/Literal.js +14 -17
- package/build/handlers/Literal.js.map +1 -1
- package/build/handlers/Object.js +54 -43
- package/build/handlers/Object.js.map +1 -1
- package/build/handlers/OperationExpressions.js +37 -32
- package/build/handlers/OperationExpressions.js.map +1 -1
- package/build/handlers/Program.js +8 -8
- package/build/handlers/Program.js.map +1 -1
- package/build/handlers/Statements.js +29 -29
- package/build/handlers/Statements.js.map +1 -1
- package/build/handlers/TemplateExpression.js +17 -17
- package/build/handlers/TemplateExpression.js.map +1 -1
- package/build/handlers/VariableDeclaration.js +71 -55
- package/build/handlers/VariableDeclaration.js.map +1 -1
- package/build/handlers/WhileStatement.js +22 -22
- package/build/handlers/WhileStatement.js.map +1 -1
- package/build/handlers/index.js +31 -30
- package/build/handlers/index.js.map +1 -1
- package/build/index.js +7 -7
- package/build/index.js.map +1 -1
- package/build/initScope.js +39 -39
- package/build/instructions/AddressResolver.js +30 -30
- package/build/instructions/ControlInstructions.js +22 -22
- package/build/instructions/EndInstruction.js +10 -10
- package/build/instructions/InstructionBase.js +20 -20
- package/build/instructions/InstructionBase.js.map +1 -1
- package/build/instructions/JumpInstruction.js +21 -21
- package/build/instructions/JumpInstruction.js.map +1 -1
- package/build/instructions/OperationInstruction.js +10 -10
- package/build/instructions/OperationInstruction.js.map +1 -1
- package/build/instructions/SetCounterInstruction.js +10 -10
- package/build/instructions/SetInstruction.js +10 -10
- package/build/instructions/ZeroSpaceInstruction.js +10 -10
- package/build/instructions/index.js +25 -25
- package/build/macros/Building.js +88 -80
- package/build/macros/Building.js.map +1 -1
- package/build/macros/Function.js +19 -19
- package/build/macros/Function.js.map +1 -1
- package/build/macros/Math.js +61 -56
- package/build/macros/Math.js.map +1 -1
- package/build/macros/Memory.js +62 -60
- package/build/macros/Memory.js.map +1 -1
- package/build/macros/Namespace.js +110 -97
- package/build/macros/Namespace.js.map +1 -1
- package/build/macros/Other.js +20 -19
- package/build/macros/Other.js.map +1 -1
- package/build/macros/RawValue.js +16 -15
- package/build/macros/RawValue.js.map +1 -1
- package/build/macros/commands/Control.js +25 -24
- package/build/macros/commands/Control.js.map +1 -1
- package/build/macros/commands/Draw.js +39 -38
- package/build/macros/commands/Draw.js.map +1 -1
- package/build/macros/commands/DrawFlush.js +17 -16
- package/build/macros/commands/DrawFlush.js.map +1 -1
- package/build/macros/commands/GetLink.js +24 -20
- package/build/macros/commands/GetLink.js.map +1 -1
- package/build/macros/commands/Lookup.js +24 -23
- package/build/macros/commands/Lookup.js.map +1 -1
- package/build/macros/commands/Print.js +17 -13
- package/build/macros/commands/Print.js.map +1 -1
- package/build/macros/commands/PrintFlush.js +17 -16
- package/build/macros/commands/PrintFlush.js.map +1 -1
- package/build/macros/commands/Radar.js +64 -60
- package/build/macros/commands/Radar.js.map +1 -1
- package/build/macros/commands/Sensor.js +20 -19
- package/build/macros/commands/Sensor.js.map +1 -1
- package/build/macros/commands/UnitBind.js +17 -16
- package/build/macros/commands/UnitBind.js.map +1 -1
- package/build/macros/commands/UnitControl.js +72 -67
- package/build/macros/commands/UnitControl.js.map +1 -1
- package/build/macros/commands/UnitLocate.js +75 -54
- package/build/macros/commands/UnitLocate.js.map +1 -1
- package/build/macros/commands/UnitRadar.js +47 -40
- package/build/macros/commands/UnitRadar.js.map +1 -1
- package/build/macros/commands/Wait.js +18 -17
- package/build/macros/commands/Wait.js.map +1 -1
- package/build/macros/commands/index.js +32 -32
- package/build/macros/index.js +39 -39
- package/build/operators.js +101 -101
- package/build/operators.js.map +1 -1
- package/build/types.js +27 -27
- package/build/types.js.map +1 -1
- package/build/utils.js +17 -12
- package/build/utils.js.map +1 -1
- package/build/values/BaseValue.js +111 -111
- package/build/values/BaseValue.js.map +1 -1
- package/build/values/FunctionValue.js +115 -103
- package/build/values/FunctionValue.js.map +1 -1
- package/build/values/LiteralValue.js +88 -87
- package/build/values/LiteralValue.js.map +1 -1
- package/build/values/ObjectValue.js +54 -49
- package/build/values/ObjectValue.js.map +1 -1
- package/build/values/StoreValue.js +31 -30
- package/build/values/StoreValue.js.map +1 -1
- package/build/values/TempValue.js +77 -66
- package/build/values/TempValue.js.map +1 -1
- package/build/values/VoidValue.js +31 -30
- package/build/values/VoidValue.js.map +1 -1
- package/build/values/index.js +22 -22
- package/dist/bin.cjs +82 -0
- package/dist/bin.cjs.map +1 -0
- package/dist/index.cjs +2220 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.mjs +2195 -0
- package/dist/index.mjs.map +1 -0
- package/dist/types/Compiler.d.ts +26 -0
- package/dist/types/CompilerError.d.ts +9 -0
- package/dist/types/Scope.d.ts +24 -0
- package/dist/types/bin.d.ts +1 -0
- package/dist/types/handlers/BlockStatement.d.ts +2 -0
- package/dist/types/handlers/CallExpression.d.ts +3 -0
- package/dist/types/handlers/File.d.ts +2 -0
- package/dist/types/handlers/ForStatement.d.ts +2 -0
- package/{build → dist/types}/handlers/Function.d.ts +5 -4
- package/{build → dist/types}/handlers/Identifier.d.ts +2 -2
- package/dist/types/handlers/IfStatement.d.ts +2 -0
- package/dist/types/handlers/Literal.d.ts +5 -0
- package/{build → dist/types}/handlers/Object.d.ts +6 -4
- package/{build → dist/types}/handlers/OperationExpressions.d.ts +8 -7
- package/dist/types/handlers/Program.d.ts +2 -0
- package/dist/types/handlers/Statements.d.ts +5 -0
- package/dist/types/handlers/TemplateExpression.d.ts +2 -0
- package/dist/types/handlers/Typescript.d.ts +7 -0
- package/dist/types/handlers/VariableDeclaration.d.ts +3 -0
- package/dist/types/handlers/WhileStatement.d.ts +3 -0
- package/{build → dist/types}/handlers/index.d.ts +16 -14
- package/dist/types/index.d.ts +2 -0
- package/{build → dist/types}/initScope.d.ts +5 -2
- package/{build → dist/types}/instructions/AddressResolver.d.ts +12 -12
- package/{build → dist/types}/instructions/ControlInstructions.d.ts +8 -11
- package/{build → dist/types}/instructions/EndInstruction.d.ts +4 -4
- package/{build → dist/types}/instructions/InstructionBase.d.ts +10 -10
- package/{build → dist/types}/instructions/JumpInstruction.d.ts +15 -15
- package/{build → dist/types}/instructions/OperationInstruction.d.ts +5 -5
- package/{build → dist/types}/instructions/SetCounterInstruction.d.ts +5 -5
- package/{build → dist/types}/instructions/SetInstruction.d.ts +6 -5
- package/{build → dist/types}/instructions/ZeroSpaceInstruction.d.ts +4 -4
- package/{build → dist/types}/instructions/index.d.ts +9 -9
- package/{build → dist/types}/macros/Building.d.ts +10 -11
- package/dist/types/macros/Entities.d.ts +11 -0
- package/dist/types/macros/Function.d.ts +13 -0
- package/dist/types/macros/GetGlobal.d.ts +5 -0
- package/{build → dist/types}/macros/Math.d.ts +5 -5
- package/{build → dist/types}/macros/Memory.d.ts +5 -5
- package/{build → dist/types}/macros/Namespace.d.ts +16 -21
- package/{build → dist/types}/macros/Other.d.ts +5 -5
- package/{build → dist/types}/macros/RawValue.d.ts +5 -5
- package/{build → dist/types}/macros/commands/Control.d.ts +5 -5
- package/dist/types/macros/commands/Draw.d.ts +5 -0
- package/{build → dist/types}/macros/commands/DrawFlush.d.ts +5 -5
- package/{build/macros/commands/Draw.d.ts → dist/types/macros/commands/End.d.ts} +5 -5
- package/{build → dist/types}/macros/commands/GetLink.d.ts +5 -5
- package/{build → dist/types}/macros/commands/Lookup.d.ts +5 -5
- package/{build → dist/types}/macros/commands/Print.d.ts +5 -5
- package/{build → dist/types}/macros/commands/PrintFlush.d.ts +5 -5
- package/{build → dist/types}/macros/commands/Radar.d.ts +7 -7
- package/{build → dist/types}/macros/commands/Sensor.d.ts +5 -5
- package/{build → dist/types}/macros/commands/UnitBind.d.ts +5 -5
- package/dist/types/macros/commands/UnitControl.d.ts +5 -0
- package/{build → dist/types}/macros/commands/UnitLocate.d.ts +5 -5
- package/{build → dist/types}/macros/commands/UnitRadar.d.ts +5 -5
- package/{build → dist/types}/macros/commands/Wait.d.ts +5 -5
- package/{build → dist/types}/macros/commands/index.d.ts +15 -14
- package/{build → dist/types}/macros/index.d.ts +6 -7
- package/{build → dist/types}/operators.d.ts +25 -25
- package/dist/types/types.d.ts +224 -0
- package/dist/types/utils.d.ts +30 -0
- package/dist/types/values/BaseValue.d.ts +7 -0
- package/dist/types/values/DestructuringValue.d.ts +17 -0
- package/dist/types/values/FunctionValue.d.ts +47 -0
- package/{build → dist/types}/values/LiteralValue.d.ts +13 -12
- package/dist/types/values/ObjectValue.d.ts +23 -0
- package/dist/types/values/SenseableValue.d.ts +23 -0
- package/dist/types/values/StackValue.d.ts +16 -0
- package/dist/types/values/StoreValue.d.ts +15 -0
- package/{build → dist/types}/values/TempValue.d.ts +19 -12
- package/dist/types/values/ValueOwner.d.ts +27 -0
- package/dist/types/values/VoidValue.d.ts +16 -0
- package/{build → dist/types}/values/index.d.ts +7 -6
- package/lib/commands.d.ts +242 -36
- package/lib/eslib/lib.es5.d.ts +1 -1
- package/lib/globals.d.ts +172 -159
- package/lib/helpers.d.ts +2 -2
- package/lib/memory.d.ts +1 -1
- package/lib/traits.d.ts +130 -110
- package/package.json +33 -38
- package/build/Compiler.d.ts +0 -18
- package/build/Scope.d.ts +0 -26
- package/build/bin.d.ts +0 -2
- package/build/handlers/BlockStatement.d.ts +0 -2
- package/build/handlers/CallExpression.d.ts +0 -3
- package/build/handlers/ForStatement.d.ts +0 -2
- package/build/handlers/IfStatement.d.ts +0 -2
- package/build/handlers/Literal.d.ts +0 -2
- package/build/handlers/Program.d.ts +0 -2
- package/build/handlers/Statements.d.ts +0 -5
- package/build/handlers/TemplateExpression.d.ts +0 -2
- package/build/handlers/VariableDeclaration.d.ts +0 -3
- package/build/handlers/WhileStatement.d.ts +0 -2
- package/build/index.d.ts +0 -1
- package/build/macros/Function.d.ts +0 -12
- package/build/macros/commands/UnitControl.d.ts +0 -5
- package/build/types.d.ts +0 -49
- package/build/utils.d.ts +0 -3
- package/build/values/BaseValue.d.ts +0 -5
- package/build/values/FunctionValue.d.ts +0 -34
- package/build/values/ObjectValue.d.ts +0 -17
- package/build/values/StoreValue.d.ts +0 -11
- package/build/values/VoidValue.d.ts +0 -11
- package/dist/mlogjs.es.js +0 -6366
- package/dist/mlogjs.umd.js +0 -8
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NewExpression = exports.CallExpression = void 0;
|
|
4
|
-
const CallExpression = (c, scope, node) => {
|
|
5
|
-
const inst = [];
|
|
6
|
-
const args = node.arguments.map(node => {
|
|
7
|
-
// TODO: this might be why t0 did not increment
|
|
8
|
-
const [v, i] = c.handleEval(scope, node);
|
|
9
|
-
inst.push(...i);
|
|
10
|
-
return v;
|
|
11
|
-
});
|
|
12
|
-
const [callee, calleeInst] = c.handleEval(scope, node.callee);
|
|
13
|
-
inst.push(...calleeInst);
|
|
14
|
-
const [callValue, callInst] = callee.call(scope, args);
|
|
15
|
-
inst.push(...callInst);
|
|
16
|
-
return [callValue, inst];
|
|
17
|
-
};
|
|
18
|
-
exports.CallExpression = CallExpression;
|
|
19
|
-
exports.NewExpression = exports.CallExpression;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NewExpression = exports.CallExpression = void 0;
|
|
4
|
+
const CallExpression = (c, scope, node) => {
|
|
5
|
+
const inst = [];
|
|
6
|
+
const args = node.arguments.map(node => {
|
|
7
|
+
// TODO: this might be why t0 did not increment
|
|
8
|
+
const [v, i] = c.handleEval(scope, node);
|
|
9
|
+
inst.push(...i);
|
|
10
|
+
return v;
|
|
11
|
+
});
|
|
12
|
+
const [callee, calleeInst] = c.handleEval(scope, node.callee);
|
|
13
|
+
inst.push(...calleeInst);
|
|
14
|
+
const [callValue, callInst] = callee.call(scope, args);
|
|
15
|
+
inst.push(...callInst);
|
|
16
|
+
return [callValue, inst];
|
|
17
|
+
};
|
|
18
|
+
exports.CallExpression = CallExpression;
|
|
19
|
+
exports.NewExpression = exports.CallExpression;
|
|
20
20
|
//# sourceMappingURL=CallExpression.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CallExpression.js","sourceRoot":"","sources":["../../src/handlers/CallExpression.ts"],"names":[],"mappings":";;;AAEO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"CallExpression.js","sourceRoot":"","sources":["../../src/handlers/CallExpression.ts"],"names":[],"mappings":";;;AAEO,MAAM,cAAc,GAA4B,CACrD,CAAC,EACD,KAAK,EACL,IAAuB,EACvB,EAAE;IACF,MAAM,IAAI,GAAmB,EAAE,CAAC;IAEhC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QACrC,+CAA+C;QAC/C,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QAChB,OAAO,CAAC,CAAC;IACX,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9D,IAAI,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,CAAC;IAEzB,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACvD,IAAI,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAC;IAEvB,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;AAC3B,CAAC,CAAC;AArBW,QAAA,cAAc,kBAqBzB;AAEW,QAAA,aAAa,GAAG,sBAAc,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.File = void 0;
|
|
4
|
+
const Scope_1 = require("../Scope");
|
|
5
|
+
const File = (c, scope, node) => {
|
|
6
|
+
return c.handle(scope ?? new Scope_1.Scope({}), node.program);
|
|
7
|
+
};
|
|
8
|
+
exports.File = File;
|
|
9
|
+
//# sourceMappingURL=File.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"File.js","sourceRoot":"","sources":["../../src/handlers/File.ts"],"names":[],"mappings":";;;AAAA,oCAAiC;AAG1B,MAAM,IAAI,GAA4B,CAAC,CAAC,EAAE,KAAK,EAAE,IAAa,EAAE,EAAE;IACvE,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,IAAI,IAAI,aAAK,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;AACxD,CAAC,CAAC;AAFW,QAAA,IAAI,QAEf"}
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ForStatement = void 0;
|
|
4
|
-
const instructions_1 = require("../instructions");
|
|
5
|
-
const values_1 = require("../values");
|
|
6
|
-
const ForStatement = (c, scope, node) => {
|
|
7
|
-
scope = scope.createScope();
|
|
8
|
-
const initInst = node.init ? c.handle(scope, node.init)[1] : [];
|
|
9
|
-
const [test, testLines] = node.test
|
|
10
|
-
? c.handleEval(scope, node.test)
|
|
11
|
-
: [new values_1.LiteralValue(scope, 1), []];
|
|
12
|
-
const updateLines = node.update ? c.handle(scope, node.update)[1] : [];
|
|
13
|
-
const startLoopAddr = new values_1.LiteralValue(scope, null);
|
|
14
|
-
const endLoopAddr = new values_1.LiteralValue(scope, null);
|
|
15
|
-
const startLoopLine = new instructions_1.AddressResolver(startLoopAddr).bindContinue(scope);
|
|
16
|
-
const endLoopLine = new instructions_1.AddressResolver(endLoopAddr).bindBreak(scope);
|
|
17
|
-
return [
|
|
18
|
-
null,
|
|
19
|
-
[
|
|
20
|
-
...initInst,
|
|
21
|
-
startLoopLine,
|
|
22
|
-
...testLines,
|
|
23
|
-
new instructions_1.JumpInstruction(endLoopAddr, instructions_1.EJumpKind.Equal, test, new values_1.LiteralValue(scope, 0)),
|
|
24
|
-
...c.handle(scope, node.body)[1],
|
|
25
|
-
...updateLines,
|
|
26
|
-
new instructions_1.JumpInstruction(startLoopAddr, instructions_1.EJumpKind.Always),
|
|
27
|
-
endLoopLine,
|
|
28
|
-
],
|
|
29
|
-
];
|
|
30
|
-
};
|
|
31
|
-
exports.ForStatement = ForStatement;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ForStatement = void 0;
|
|
4
|
+
const instructions_1 = require("../instructions");
|
|
5
|
+
const values_1 = require("../values");
|
|
6
|
+
const ForStatement = (c, scope, node) => {
|
|
7
|
+
scope = scope.createScope();
|
|
8
|
+
const initInst = node.init ? c.handle(scope, node.init)[1] : [];
|
|
9
|
+
const [test, testLines] = node.test
|
|
10
|
+
? c.handleEval(scope, node.test)
|
|
11
|
+
: [new values_1.LiteralValue(scope, 1), []];
|
|
12
|
+
const updateLines = node.update ? c.handle(scope, node.update)[1] : [];
|
|
13
|
+
const startLoopAddr = new values_1.LiteralValue(scope, null);
|
|
14
|
+
const endLoopAddr = new values_1.LiteralValue(scope, null);
|
|
15
|
+
const startLoopLine = new instructions_1.AddressResolver(startLoopAddr).bindContinue(scope);
|
|
16
|
+
const endLoopLine = new instructions_1.AddressResolver(endLoopAddr).bindBreak(scope);
|
|
17
|
+
return [
|
|
18
|
+
null,
|
|
19
|
+
[
|
|
20
|
+
...initInst,
|
|
21
|
+
startLoopLine,
|
|
22
|
+
...testLines,
|
|
23
|
+
new instructions_1.JumpInstruction(endLoopAddr, instructions_1.EJumpKind.Equal, test, new values_1.LiteralValue(scope, 0)),
|
|
24
|
+
...c.handle(scope, node.body)[1],
|
|
25
|
+
...updateLines,
|
|
26
|
+
new instructions_1.JumpInstruction(startLoopAddr, instructions_1.EJumpKind.Always),
|
|
27
|
+
endLoopLine,
|
|
28
|
+
],
|
|
29
|
+
];
|
|
30
|
+
};
|
|
31
|
+
exports.ForStatement = ForStatement;
|
|
32
32
|
//# sourceMappingURL=ForStatement.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ForStatement.js","sourceRoot":"","sources":["../../src/handlers/ForStatement.ts"],"names":[],"mappings":";;;AAAA,kDAA8E;AAE9E,sCAAyC;AAElC,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"ForStatement.js","sourceRoot":"","sources":["../../src/handlers/ForStatement.ts"],"names":[],"mappings":";;;AAAA,kDAA8E;AAE9E,sCAAyC;AAElC,MAAM,YAAY,GAAmB,CAC1C,CAAC,EACD,KAAK,EACL,IAAqB,EACrB,EAAE;IACF,KAAK,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;IAE5B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAA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47 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FunctionExpression = exports.FunctionDeclaration = exports.ArrowFunctionExpression = void 0;
|
|
4
|
-
const utils_1 = require("../utils");
|
|
5
|
-
const FunctionValue_1 = require("../values/FunctionValue");
|
|
6
|
-
const ArrowFunctionExpression = (c, scope, node) => {
|
|
7
|
-
const name = (0, utils_1.nodeName)(node);
|
|
8
|
-
|
|
9
|
-
let { params, body } = node;
|
|
10
|
-
if (node.expression) {
|
|
11
|
-
body = {
|
|
12
|
-
type: "BlockStatement",
|
|
13
|
-
body: [
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ObjectMethod = exports.FunctionExpression = exports.FunctionDeclaration = exports.ArrowFunctionExpression = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
const FunctionValue_1 = require("../values/FunctionValue");
|
|
6
|
+
const ArrowFunctionExpression = (c, scope, node) => {
|
|
7
|
+
const name = (0, utils_1.nodeName)(node);
|
|
8
|
+
const functionScope = scope.createFunction(name);
|
|
9
|
+
let { params, body } = node;
|
|
10
|
+
if (node.expression) {
|
|
11
|
+
body = {
|
|
12
|
+
type: "BlockStatement",
|
|
13
|
+
body: [
|
|
14
|
+
{ ...body, type: "ReturnStatement", argument: body },
|
|
15
|
+
],
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
const paramNames = [];
|
|
19
|
+
const paramStores = [];
|
|
20
|
+
for (const id of params) {
|
|
21
|
+
paramNames.push(id.name);
|
|
22
|
+
paramStores.push(functionScope.make(id.name, c.compactNames ? (0, utils_1.nodeName)(id) : functionScope.formatName(id.name)));
|
|
23
|
+
}
|
|
24
|
+
return [
|
|
25
|
+
new FunctionValue_1.FunctionValue({
|
|
26
|
+
scope: functionScope,
|
|
27
|
+
name,
|
|
28
|
+
paramNames,
|
|
29
|
+
paramStores,
|
|
30
|
+
body: body,
|
|
31
|
+
c,
|
|
32
|
+
renameable: true,
|
|
33
|
+
}),
|
|
34
|
+
[],
|
|
35
|
+
];
|
|
36
|
+
};
|
|
37
|
+
exports.ArrowFunctionExpression = ArrowFunctionExpression;
|
|
38
|
+
const FunctionDeclaration = (c, scope, node) => {
|
|
39
|
+
const functionIns = (0, exports.ArrowFunctionExpression)(c, scope, node, null);
|
|
40
|
+
const name = node.id.name;
|
|
41
|
+
functionIns[0].rename?.(c.compactNames ? (0, utils_1.nodeName)(node) : scope.formatName(name));
|
|
42
|
+
return [scope.set(name, functionIns[0]), []];
|
|
43
|
+
};
|
|
44
|
+
exports.FunctionDeclaration = FunctionDeclaration;
|
|
45
|
+
exports.FunctionExpression = exports.ArrowFunctionExpression;
|
|
46
|
+
exports.ObjectMethod = exports.ArrowFunctionExpression;
|
|
36
47
|
//# sourceMappingURL=Function.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Function.js","sourceRoot":"","sources":["../../src/handlers/Function.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Function.js","sourceRoot":"","sources":["../../src/handlers/Function.ts"],"names":[],"mappings":";;;AACA,oCAAoC;AAEpC,2DAAwD;AAEjD,MAAM,uBAAuB,GAAa,CAC/C,CAAC,EACD,KAAK,EACL,IAAgC,EAChC,EAAE;IACF,MAAM,IAAI,GAAG,IAAA,gBAAQ,EAAC,IAAI,CAAC,CAAC;IAC5B,MAAM,aAAa,GAAG,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;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,CAAC,IAAA,gBAAQ,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CACzD,CAAC;IACF,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC/C,CAAC,CAAC;AAXW,QAAA,mBAAmB,uBAW9B;AAEW,QAAA,kBAAkB,GAAa,+BAAuB,CAAC;AACvD,QAAA,YAAY,GAAa,+BAAuB,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Identifier = void 0;
|
|
4
|
-
const Identifier = (c, scope, node) => {
|
|
5
|
-
return [scope.get(node.name), []];
|
|
6
|
-
};
|
|
7
|
-
exports.Identifier = Identifier;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Identifier = void 0;
|
|
4
|
+
const Identifier = (c, scope, node) => {
|
|
5
|
+
return [scope.get(node.name), []];
|
|
6
|
+
};
|
|
7
|
+
exports.Identifier = Identifier;
|
|
8
8
|
//# sourceMappingURL=Identifier.js.map
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IfStatement = void 0;
|
|
4
|
-
const instructions_1 = require("../instructions");
|
|
5
|
-
const instructions_2 = require("../instructions");
|
|
6
|
-
const values_1 = require("../values");
|
|
7
|
-
const IfStatement = (c, scope, node) => {
|
|
8
|
-
const inst = [];
|
|
9
|
-
const [test, testInst] = c.handleEval(scope, node.test);
|
|
10
|
-
if (test instanceof values_1.LiteralValue) {
|
|
11
|
-
if (test.data)
|
|
12
|
-
inst.push(...c.handle(scope, node.consequent)[1]);
|
|
13
|
-
else if (node.alternate)
|
|
14
|
-
inst.push(...c.handle(scope, node.alternate)[1]);
|
|
15
|
-
return [null, inst];
|
|
16
|
-
}
|
|
17
|
-
const endIfAddr = new values_1.LiteralValue(scope, null);
|
|
18
|
-
inst.push(...testInst, new instructions_1.JumpInstruction(endIfAddr, instructions_2.EJumpKind.Equal, test, new values_1.LiteralValue(scope, 0)), ...c.handle(scope, node.consequent)[1], new instructions_1.AddressResolver(endIfAddr));
|
|
19
|
-
const endElseAddr = new values_1.LiteralValue(scope, null);
|
|
20
|
-
if (node.alternate)
|
|
21
|
-
inst.push(new instructions_1.JumpInstruction(endElseAddr, instructions_2.EJumpKind.Always), new instructions_1.AddressResolver(endIfAddr), ...c.handle(scope, node.alternate)[1], new instructions_1.AddressResolver(endElseAddr));
|
|
22
|
-
return [null, inst];
|
|
23
|
-
};
|
|
24
|
-
exports.IfStatement = IfStatement;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IfStatement = void 0;
|
|
4
|
+
const instructions_1 = require("../instructions");
|
|
5
|
+
const instructions_2 = require("../instructions");
|
|
6
|
+
const values_1 = require("../values");
|
|
7
|
+
const IfStatement = (c, scope, node) => {
|
|
8
|
+
const inst = [];
|
|
9
|
+
const [test, testInst] = c.handleEval(scope, node.test);
|
|
10
|
+
if (test instanceof values_1.LiteralValue) {
|
|
11
|
+
if (test.data)
|
|
12
|
+
inst.push(...c.handle(scope, node.consequent)[1]);
|
|
13
|
+
else if (node.alternate)
|
|
14
|
+
inst.push(...c.handle(scope, node.alternate)[1]);
|
|
15
|
+
return [null, inst];
|
|
16
|
+
}
|
|
17
|
+
const endIfAddr = new values_1.LiteralValue(scope, null);
|
|
18
|
+
inst.push(...testInst, new instructions_1.JumpInstruction(endIfAddr, instructions_2.EJumpKind.Equal, test, new values_1.LiteralValue(scope, 0)), ...c.handle(scope, node.consequent)[1], new instructions_1.AddressResolver(endIfAddr));
|
|
19
|
+
const endElseAddr = new values_1.LiteralValue(scope, null);
|
|
20
|
+
if (node.alternate)
|
|
21
|
+
inst.push(new instructions_1.JumpInstruction(endElseAddr, instructions_2.EJumpKind.Always), new instructions_1.AddressResolver(endIfAddr), ...c.handle(scope, node.alternate)[1], new instructions_1.AddressResolver(endElseAddr));
|
|
22
|
+
return [null, inst];
|
|
23
|
+
};
|
|
24
|
+
exports.IfStatement = IfStatement;
|
|
25
25
|
//# sourceMappingURL=IfStatement.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IfStatement.js","sourceRoot":"","sources":["../../src/handlers/IfStatement.ts"],"names":[],"mappings":";;;AAAA,kDAAmE;AACnE,kDAA4C;AAE5C,sCAAyC;AAElC,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"IfStatement.js","sourceRoot":"","sources":["../../src/handlers/IfStatement.ts"],"names":[],"mappings":";;;AAAA,kDAAmE;AACnE,kDAA4C;AAE5C,sCAAyC;AAElC,MAAM,WAAW,GAAmB,CAAC,CAAC,EAAE,KAAK,EAAE,IAAoB,EAAE,EAAE;IAC5E,MAAM,IAAI,GAAG,EAAE,CAAC;IAChB,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IAExD,IAAI,IAAI,YAAY,qBAAY,EAAE;QAChC,IAAI,IAAI,CAAC,IAAI;YAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;aAC5D,IAAI,IAAI,CAAC,SAAS;YAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1E,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;KACrB;IAED,MAAM,SAAS,GAAG,IAAI,qBAAY,CAAC,KAAK,EAAE,IAAa,CAAC,CAAC;IACzD,IAAI,CAAC,IAAI,CACP,GAAG,QAAQ,EACX,IAAI,8BAAe,CACjB,SAAS,EACT,wBAAS,CAAC,KAAK,EACf,IAAI,EACJ,IAAI,qBAAY,CAAC,KAAK,EAAE,CAAC,CAAC,CAC3B,EACD,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EACtC,IAAI,8BAAe,CAAC,SAAS,CAAC,CAC/B,CAAC;IACF,MAAM,WAAW,GAAG,IAAI,qBAAY,CAAC,KAAK,EAAE,IAAa,CAAC,CAAC;IAC3D,IAAI,IAAI,CAAC,SAAS;QAChB,IAAI,CAAC,IAAI,CACP,IAAI,8BAAe,CAAC,WAAW,EAAE,wBAAS,CAAC,MAAM,CAAC,EAClD,IAAI,8BAAe,CAAC,SAAS,CAAC,EAC9B,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EACrC,IAAI,8BAAe,CAAC,WAAW,CAAC,CACjC,CAAC;IACJ,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACtB,CAAC,CAAC;AA/BW,QAAA,WAAW,eA+BtB"}
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const values_1 = require("../values");
|
|
5
|
-
const Literal = (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
throw Error("Cannot create literal " + typeof value);
|
|
16
|
-
};
|
|
17
|
-
exports.Literal = Literal;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BooleanLiteral = exports.NullLiteral = exports.StringLiteral = exports.NumericLiteral = void 0;
|
|
4
|
+
const values_1 = require("../values");
|
|
5
|
+
const Literal = (_c, scope, node) => [new values_1.LiteralValue(scope, node.value), []];
|
|
6
|
+
exports.NumericLiteral = Literal;
|
|
7
|
+
exports.StringLiteral = Literal;
|
|
8
|
+
const NullLiteral = (_c, scope) => [
|
|
9
|
+
new values_1.LiteralValue(scope, null),
|
|
10
|
+
[],
|
|
11
|
+
];
|
|
12
|
+
exports.NullLiteral = NullLiteral;
|
|
13
|
+
const BooleanLiteral = (_c, scope, node) => [new values_1.LiteralValue(scope, +node.value), []];
|
|
14
|
+
exports.BooleanLiteral = BooleanLiteral;
|
|
18
15
|
//# sourceMappingURL=Literal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Literal.js","sourceRoot":"","sources":["../../src/handlers/Literal.ts"],"names":[],"mappings":";;;AACA,sCAAyC;
|
|
1
|
+
{"version":3,"file":"Literal.js","sourceRoot":"","sources":["../../src/handlers/Literal.ts"],"names":[],"mappings":";;;AACA,sCAAyC;AAEzC,MAAM,OAAO,GAAa,CACxB,EAAE,EACF,KAAK,EACL,IAA0C,EAC1C,EAAE,CAAC,CAAC,IAAI,qBAAY,CAAC,KAAK,EAAE,IAAI,CAAC,KAAiB,CAAC,EAAE,EAAE,CAAC,CAAC;AAE9C,QAAA,cAAc,GAAG,OAAO,CAAC;AACzB,QAAA,aAAa,GAAG,OAAO,CAAC;AAE9B,MAAM,WAAW,GAAa,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC;IAClD,IAAI,qBAAY,CAAC,KAAK,EAAE,IAA2B,CAAC;IACpD,EAAE;CACH,CAAC;AAHW,QAAA,WAAW,eAGtB;AAEK,MAAM,cAAc,GAAa,CACtC,EAAE,EACF,KAAK,EACL,IAAuB,EACvB,EAAE,CAAC,CAAC,IAAI,qBAAY,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;AAJnC,QAAA,cAAc,kBAIqB"}
|
package/build/handlers/Object.js
CHANGED
|
@@ -1,44 +1,55 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MemberExpression = exports.ArrayExpression = exports.ObjectExpression = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const
|
|
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
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
};
|
|
43
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MemberExpression = exports.ArrayExpression = exports.ObjectExpression = void 0;
|
|
4
|
+
const CompilerError_1 = require("../CompilerError");
|
|
5
|
+
const values_1 = require("../values");
|
|
6
|
+
const ObjectExpression = (c, scope, node) => {
|
|
7
|
+
const data = {};
|
|
8
|
+
const inst = [];
|
|
9
|
+
for (const prop of node.properties) {
|
|
10
|
+
if (prop.type === "SpreadElement")
|
|
11
|
+
throw new CompilerError_1.CompilerError("Cannot handle spread element");
|
|
12
|
+
if (prop.computed)
|
|
13
|
+
throw new CompilerError_1.CompilerError("Cannot handle computed property.");
|
|
14
|
+
const { key } = prop;
|
|
15
|
+
const value = prop.type === "ObjectProperty" ? prop.value : prop;
|
|
16
|
+
let index;
|
|
17
|
+
if (key.type === "Identifier") {
|
|
18
|
+
index = key.name;
|
|
19
|
+
}
|
|
20
|
+
else if (key.type === "StringLiteral" || key.type === "NumericLiteral") {
|
|
21
|
+
index = `${key.value}`;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
throw new CompilerError_1.CompilerError(`Unsupported object key type: ${key.type}`);
|
|
25
|
+
}
|
|
26
|
+
const [member, memberInst] = c.handleEval(scope, value);
|
|
27
|
+
data[index] = member;
|
|
28
|
+
inst.push(...memberInst);
|
|
29
|
+
}
|
|
30
|
+
return [new values_1.ObjectValue(scope, data), inst];
|
|
31
|
+
};
|
|
32
|
+
exports.ObjectExpression = ObjectExpression;
|
|
33
|
+
const ArrayExpression = (c, scope, node) => {
|
|
34
|
+
const data = {};
|
|
35
|
+
const inst = [];
|
|
36
|
+
node.elements.forEach((element, i) => {
|
|
37
|
+
if (!element)
|
|
38
|
+
return;
|
|
39
|
+
const [value, valueInst] = c.handleEval(scope, element);
|
|
40
|
+
data[i] = value;
|
|
41
|
+
inst.push(...valueInst);
|
|
42
|
+
});
|
|
43
|
+
return [new values_1.ObjectValue(scope, data), inst];
|
|
44
|
+
};
|
|
45
|
+
exports.ArrayExpression = ArrayExpression;
|
|
46
|
+
const MemberExpression = (c, scope, node) => {
|
|
47
|
+
const [obj, objInst] = c.handleEval(scope, node.object);
|
|
48
|
+
const [prop, propInst] = node.computed
|
|
49
|
+
? c.handleEval(scope, node.property)
|
|
50
|
+
: [new values_1.LiteralValue(scope, node.property.name), []];
|
|
51
|
+
const [got, gotInst] = obj.get(scope, prop);
|
|
52
|
+
return [got, [...objInst, ...propInst, ...gotInst]];
|
|
53
|
+
};
|
|
54
|
+
exports.MemberExpression = MemberExpression;
|
|
44
55
|
//# sourceMappingURL=Object.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Object.js","sourceRoot":"","sources":["../../src/handlers/Object.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Object.js","sourceRoot":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C,KAAK,EAAE,IAAI,CAAC,CAAC;IAC5C,OAAO,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO,EAAE,GAAG,QAAQ,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC;AACtD,CAAC,CAAC;AAbW,QAAA,gBAAgB,oBAa3B"}
|
|
@@ -1,33 +1,38 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UpdateExpression = exports.UnaryExpression = exports.AssignmentExpression = exports.LogicalExpression = exports.BinaryExpression = exports.LRExpression = void 0;
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
const [
|
|
7
|
-
const [
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
exports.
|
|
12
|
-
exports.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const [
|
|
16
|
-
const [
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const [
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UpdateExpression = exports.UnaryExpression = exports.AssignmentExpression = exports.LogicalExpression = exports.BinaryExpression = exports.LRExpression = void 0;
|
|
4
|
+
const CompilerError_1 = require("../CompilerError");
|
|
5
|
+
const LRExpression = (c, scope, node) => {
|
|
6
|
+
const [left, leftInst] = c.handleEval(scope, node.left);
|
|
7
|
+
const [right, rightInst] = c.handleEval(scope, node.right);
|
|
8
|
+
const [op, opInst] = left[node.operator](scope, right);
|
|
9
|
+
return [op, [...leftInst, ...rightInst, ...opInst]];
|
|
10
|
+
};
|
|
11
|
+
exports.LRExpression = LRExpression;
|
|
12
|
+
exports.BinaryExpression = exports.LRExpression;
|
|
13
|
+
exports.LogicalExpression = exports.LRExpression;
|
|
14
|
+
const AssignmentExpression = (c, scope, node) => {
|
|
15
|
+
const [left, leftInst] = c.handle(scope, node.left);
|
|
16
|
+
const [right, rightInst] = c.handleEval(scope, node.right);
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
18
|
+
const [op, opInst] = left[node.operator](scope, right);
|
|
19
|
+
return [op, [...leftInst, ...rightInst, ...opInst]];
|
|
20
|
+
};
|
|
21
|
+
exports.AssignmentExpression = AssignmentExpression;
|
|
22
|
+
const UnaryExpression = (c, scope, { argument, operator }) => {
|
|
23
|
+
const [arg, argInst] = c.handleEval(scope, argument);
|
|
24
|
+
const operatorId = operator == "+" || operator == "-" ? `u${operator}` : operator;
|
|
25
|
+
if (operatorId === "throw")
|
|
26
|
+
throw new CompilerError_1.CompilerError("throw operator is not supported");
|
|
27
|
+
const [op, opInst] = arg[operatorId](scope);
|
|
28
|
+
return [op, [...argInst, ...opInst]];
|
|
29
|
+
};
|
|
30
|
+
exports.UnaryExpression = UnaryExpression;
|
|
31
|
+
const UpdateExpression = (c, scope, { argument, operator, prefix }) => {
|
|
32
|
+
const [arg, argInst] = c.handle(scope, argument);
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
34
|
+
const [op, opInst] = arg[operator](scope, prefix);
|
|
35
|
+
return [op, [...argInst, ...opInst]];
|
|
36
|
+
};
|
|
37
|
+
exports.UpdateExpression = UpdateExpression;
|
|
33
38
|
//# sourceMappingURL=OperationExpressions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OperationExpressions.js","sourceRoot":"","sources":["../../src/handlers/OperationExpressions.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"OperationExpressions.js","sourceRoot":"","sources":["../../src/handlers/OperationExpressions.ts"],"names":[],"mappings":";;;AAAA,oDAAiD;AAQ1C,MAAM,YAAY,GAAa,CACpC,CAAC,EACD,KAAK,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= (c, scope, node) => {
|
|
6
|
-
return c.handleMany(scope ?? new Scope_1.Scope({}), node.body);
|
|
7
|
-
};
|
|
8
|
-
exports.Program = Program;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Program = void 0;
|
|
4
|
+
const Scope_1 = require("../Scope");
|
|
5
|
+
const Program = (c, scope, node) => {
|
|
6
|
+
return c.handleMany(scope ?? new Scope_1.Scope({}), node.body);
|
|
7
|
+
};
|
|
8
|
+
exports.Program = Program;
|
|
9
9
|
//# sourceMappingURL=Program.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Program.js","sourceRoot":"","sources":["../../src/handlers/Program.ts"],"names":[],"mappings":";;;AAAA,oCAAiC;AAG1B,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"Program.js","sourceRoot":"","sources":["../../src/handlers/Program.ts"],"names":[],"mappings":";;;AAAA,oCAAiC;AAG1B,MAAM,OAAO,GAAmB,CAAC,CAAC,EAAE,KAAK,EAAE,IAAgB,EAAE,EAAE;IACpE,OAAO,CAAC,CAAC,UAAU,CAAC,KAAK,IAAI,IAAI,aAAK,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;AACzD,CAAC,CAAC;AAFW,QAAA,OAAO,WAElB"}
|