mlogjs 0.3.0 → 0.4.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.
Files changed (278) hide show
  1. package/dist/Compiler.d.ts +39 -0
  2. package/dist/CompilerError.d.ts +33 -0
  3. package/dist/Scope.d.ts +24 -0
  4. package/dist/assertions.d.ts +28 -0
  5. package/dist/bin.cjs +7 -14
  6. package/dist/bin.cjs.map +1 -1
  7. package/dist/bin.d.ts +1 -0
  8. package/dist/handlers/BlockStatement.d.ts +2 -0
  9. package/dist/handlers/CallExpression.d.ts +4 -0
  10. package/dist/handlers/File.d.ts +2 -0
  11. package/dist/handlers/ForStatement.d.ts +2 -0
  12. package/dist/handlers/Function.d.ts +5 -0
  13. package/dist/handlers/Identifier.d.ts +2 -0
  14. package/dist/handlers/IfStatement.d.ts +2 -0
  15. package/dist/handlers/Literal.d.ts +5 -0
  16. package/dist/handlers/Object.d.ts +6 -0
  17. package/dist/handlers/OperationExpressions.d.ts +8 -0
  18. package/dist/handlers/Program.d.ts +2 -0
  19. package/dist/handlers/Statements.d.ts +5 -0
  20. package/dist/handlers/SwitchStatement.d.ts +2 -0
  21. package/dist/handlers/TemplateExpression.d.ts +2 -0
  22. package/dist/handlers/Typescript.d.ts +7 -0
  23. package/dist/handlers/VariableDeclaration.d.ts +3 -0
  24. package/dist/handlers/WhileStatement.d.ts +3 -0
  25. package/dist/handlers/index.d.ts +17 -0
  26. package/dist/index.cjs +1037 -315
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.ts +3 -0
  29. package/dist/index.mjs +1037 -315
  30. package/dist/index.mjs.map +1 -1
  31. package/dist/initScope.d.ts +5 -0
  32. package/dist/instructions/AddressResolver.d.ts +12 -0
  33. package/dist/instructions/ControlInstructions.d.ts +10 -0
  34. package/dist/instructions/EndInstruction.d.ts +4 -0
  35. package/dist/instructions/InstructionBase.d.ts +14 -0
  36. package/dist/instructions/JumpInstruction.d.ts +16 -0
  37. package/dist/instructions/OperationInstruction.d.ts +5 -0
  38. package/dist/instructions/SetCounterInstruction.d.ts +5 -0
  39. package/dist/instructions/SetInstruction.d.ts +6 -0
  40. package/dist/instructions/ZeroSpaceInstruction.d.ts +4 -0
  41. package/dist/instructions/index.d.ts +9 -0
  42. package/dist/{types/macros/RawValue.d.ts → macros/Asm.d.ts} +1 -1
  43. package/dist/macros/Function.d.ts +13 -0
  44. package/dist/macros/GetGlobal.d.ts +5 -0
  45. package/dist/macros/Math.d.ts +5 -0
  46. package/dist/macros/Memory.d.ts +5 -0
  47. package/dist/macros/Namespace.d.ts +13 -0
  48. package/dist/macros/Other.d.ts +5 -0
  49. package/dist/macros/commands/ApplyStatus.d.ts +5 -0
  50. package/dist/macros/commands/Control.d.ts +5 -0
  51. package/dist/macros/commands/Cutscene.d.ts +5 -0
  52. package/dist/macros/commands/Draw.d.ts +5 -0
  53. package/dist/macros/commands/DrawFlush.d.ts +5 -0
  54. package/dist/macros/commands/End.d.ts +5 -0
  55. package/dist/macros/commands/Explosion.d.ts +5 -0
  56. package/dist/macros/commands/Fetch.d.ts +5 -0
  57. package/dist/macros/commands/FlushMessage.d.ts +5 -0
  58. package/dist/macros/commands/GetBlock.d.ts +5 -0
  59. package/dist/macros/commands/GetFlag.d.ts +5 -0
  60. package/dist/macros/commands/GetLink.d.ts +5 -0
  61. package/dist/macros/commands/Lookup.d.ts +5 -0
  62. package/dist/macros/commands/PackColor.d.ts +5 -0
  63. package/dist/macros/commands/Print.d.ts +5 -0
  64. package/dist/macros/commands/PrintFlush.d.ts +5 -0
  65. package/dist/macros/commands/Radar.d.ts +7 -0
  66. package/dist/macros/commands/Sensor.d.ts +5 -0
  67. package/dist/macros/commands/SetBlock.d.ts +5 -0
  68. package/dist/macros/commands/SetFlag.d.ts +5 -0
  69. package/dist/macros/commands/SetRate.d.ts +5 -0
  70. package/dist/macros/commands/SetRule.d.ts +5 -0
  71. package/dist/macros/commands/SpawnUnit.d.ts +5 -0
  72. package/dist/macros/commands/SpawnWave.d.ts +5 -0
  73. package/dist/macros/commands/Stop.d.ts +5 -0
  74. package/dist/macros/commands/UnitBind.d.ts +5 -0
  75. package/dist/macros/commands/UnitControl.d.ts +5 -0
  76. package/dist/macros/commands/UnitLocate.d.ts +5 -0
  77. package/dist/macros/commands/UnitRadar.d.ts +5 -0
  78. package/dist/macros/commands/Wait.d.ts +5 -0
  79. package/dist/macros/commands/index.d.ts +30 -0
  80. package/dist/macros/index.d.ts +6 -0
  81. package/dist/macros/util.d.ts +18 -0
  82. package/dist/operators.d.ts +25 -0
  83. package/dist/types/Compiler.d.ts +17 -4
  84. package/dist/types/CompilerError.d.ts +28 -4
  85. package/dist/types/assertions.d.ts +28 -0
  86. package/dist/types/handlers/CallExpression.d.ts +1 -0
  87. package/dist/types/handlers/SwitchStatement.d.ts +2 -0
  88. package/dist/types/handlers/index.d.ts +1 -0
  89. package/dist/types/index.d.ts +1 -0
  90. package/dist/types/instructions/ControlInstructions.d.ts +3 -1
  91. package/dist/types/instructions/InstructionBase.d.ts +5 -1
  92. package/dist/types/instructions/JumpInstruction.d.ts +1 -0
  93. package/dist/types/macros/Asm.d.ts +5 -0
  94. package/dist/types/macros/Namespace.d.ts +0 -3
  95. package/dist/types/macros/commands/ApplyStatus.d.ts +5 -0
  96. package/dist/types/macros/commands/Control.d.ts +2 -2
  97. package/dist/types/macros/commands/Cutscene.d.ts +5 -0
  98. package/dist/types/macros/commands/Draw.d.ts +2 -2
  99. package/dist/types/macros/commands/Explosion.d.ts +5 -0
  100. package/dist/types/macros/commands/Fetch.d.ts +5 -0
  101. package/dist/types/macros/commands/FlushMessage.d.ts +5 -0
  102. package/dist/types/macros/commands/GetBlock.d.ts +5 -0
  103. package/dist/types/macros/commands/GetFlag.d.ts +5 -0
  104. package/dist/types/macros/commands/Lookup.d.ts +2 -2
  105. package/dist/types/macros/commands/PackColor.d.ts +5 -0
  106. package/dist/types/macros/commands/Radar.d.ts +2 -2
  107. package/dist/types/macros/commands/SetBlock.d.ts +5 -0
  108. package/dist/types/macros/commands/SetFlag.d.ts +5 -0
  109. package/dist/types/macros/commands/SetRate.d.ts +5 -0
  110. package/dist/types/macros/commands/SetRule.d.ts +5 -0
  111. package/dist/types/macros/commands/SpawnUnit.d.ts +5 -0
  112. package/dist/types/macros/commands/SpawnWave.d.ts +5 -0
  113. package/dist/types/macros/commands/Stop.d.ts +5 -0
  114. package/dist/types/macros/commands/UnitControl.d.ts +3 -3
  115. package/dist/types/macros/commands/UnitLocate.d.ts +2 -2
  116. package/dist/types/macros/commands/index.d.ts +15 -0
  117. package/dist/types/macros/util.d.ts +18 -0
  118. package/dist/types/types.d.ts +14 -0
  119. package/dist/types/utils.d.ts +19 -2
  120. package/dist/types/values/BaseValue.d.ts +2 -0
  121. package/dist/types/values/FunctionValue.d.ts +1 -1
  122. package/dist/types/values/ObjectValue.d.ts +1 -1
  123. package/dist/types.d.ts +238 -0
  124. package/dist/utils.d.ts +47 -0
  125. package/dist/values/BaseValue.d.ts +9 -0
  126. package/dist/values/DestructuringValue.d.ts +17 -0
  127. package/dist/values/FunctionValue.d.ts +47 -0
  128. package/dist/values/LiteralValue.d.ts +13 -0
  129. package/dist/values/ObjectValue.d.ts +23 -0
  130. package/dist/values/SenseableValue.d.ts +23 -0
  131. package/dist/{types/values/StackValue.d.ts → values/StoreValue.d.ts} +5 -6
  132. package/dist/values/ValueOwner.d.ts +27 -0
  133. package/dist/values/VoidValue.d.ts +16 -0
  134. package/dist/values/index.d.ts +7 -0
  135. package/lib/commands.d.ts +849 -418
  136. package/lib/eslib/lib.es2015.core.d.ts +3 -0
  137. package/lib/globals.d.ts +331 -19
  138. package/lib/helpers.d.ts +14 -0
  139. package/lib/kinds.d.ts +3 -2
  140. package/lib/memory.d.ts +1 -1
  141. package/lib/traits.d.ts +6 -0
  142. package/lib/util.d.ts +16 -0
  143. package/package.json +15 -16
  144. package/build/Compiler.js +0 -105
  145. package/build/Compiler.js.map +0 -1
  146. package/build/CompilerError.js +0 -11
  147. package/build/CompilerError.js.map +0 -1
  148. package/build/Scope.js +0 -71
  149. package/build/Scope.js.map +0 -1
  150. package/build/bin.js +0 -75
  151. package/build/bin.js.map +0 -1
  152. package/build/handlers/BlockStatement.js +0 -14
  153. package/build/handlers/BlockStatement.js.map +0 -1
  154. package/build/handlers/CallExpression.js +0 -20
  155. package/build/handlers/CallExpression.js.map +0 -1
  156. package/build/handlers/File.js +0 -9
  157. package/build/handlers/File.js.map +0 -1
  158. package/build/handlers/ForStatement.js +0 -32
  159. package/build/handlers/ForStatement.js.map +0 -1
  160. package/build/handlers/Function.js +0 -47
  161. package/build/handlers/Function.js.map +0 -1
  162. package/build/handlers/Identifier.js +0 -8
  163. package/build/handlers/Identifier.js.map +0 -1
  164. package/build/handlers/IfStatement.js +0 -25
  165. package/build/handlers/IfStatement.js.map +0 -1
  166. package/build/handlers/Literal.js +0 -15
  167. package/build/handlers/Literal.js.map +0 -1
  168. package/build/handlers/Object.js +0 -55
  169. package/build/handlers/Object.js.map +0 -1
  170. package/build/handlers/OperationExpressions.js +0 -38
  171. package/build/handlers/OperationExpressions.js.map +0 -1
  172. package/build/handlers/Program.js +0 -9
  173. package/build/handlers/Program.js.map +0 -1
  174. package/build/handlers/Statements.js +0 -30
  175. package/build/handlers/Statements.js.map +0 -1
  176. package/build/handlers/TemplateExpression.js +0 -18
  177. package/build/handlers/TemplateExpression.js.map +0 -1
  178. package/build/handlers/VariableDeclaration.js +0 -72
  179. package/build/handlers/VariableDeclaration.js.map +0 -1
  180. package/build/handlers/WhileStatement.js +0 -23
  181. package/build/handlers/WhileStatement.js.map +0 -1
  182. package/build/handlers/index.js +0 -32
  183. package/build/handlers/index.js.map +0 -1
  184. package/build/index.js +0 -8
  185. package/build/index.js.map +0 -1
  186. package/build/initScope.js +0 -40
  187. package/build/initScope.js.map +0 -1
  188. package/build/instructions/AddressResolver.js +0 -31
  189. package/build/instructions/AddressResolver.js.map +0 -1
  190. package/build/instructions/ControlInstructions.js +0 -23
  191. package/build/instructions/ControlInstructions.js.map +0 -1
  192. package/build/instructions/EndInstruction.js +0 -11
  193. package/build/instructions/EndInstruction.js.map +0 -1
  194. package/build/instructions/InstructionBase.js +0 -21
  195. package/build/instructions/InstructionBase.js.map +0 -1
  196. package/build/instructions/JumpInstruction.js +0 -22
  197. package/build/instructions/JumpInstruction.js.map +0 -1
  198. package/build/instructions/OperationInstruction.js +0 -11
  199. package/build/instructions/OperationInstruction.js.map +0 -1
  200. package/build/instructions/SetCounterInstruction.js +0 -11
  201. package/build/instructions/SetCounterInstruction.js.map +0 -1
  202. package/build/instructions/SetInstruction.js +0 -11
  203. package/build/instructions/SetInstruction.js.map +0 -1
  204. package/build/instructions/ZeroSpaceInstruction.js +0 -11
  205. package/build/instructions/ZeroSpaceInstruction.js.map +0 -1
  206. package/build/instructions/index.js +0 -26
  207. package/build/instructions/index.js.map +0 -1
  208. package/build/macros/Building.js +0 -89
  209. package/build/macros/Building.js.map +0 -1
  210. package/build/macros/Function.js +0 -20
  211. package/build/macros/Function.js.map +0 -1
  212. package/build/macros/Math.js +0 -62
  213. package/build/macros/Math.js.map +0 -1
  214. package/build/macros/Memory.js +0 -63
  215. package/build/macros/Memory.js.map +0 -1
  216. package/build/macros/Namespace.js +0 -111
  217. package/build/macros/Namespace.js.map +0 -1
  218. package/build/macros/Other.js +0 -21
  219. package/build/macros/Other.js.map +0 -1
  220. package/build/macros/RawValue.js +0 -17
  221. package/build/macros/RawValue.js.map +0 -1
  222. package/build/macros/commands/Control.js +0 -26
  223. package/build/macros/commands/Control.js.map +0 -1
  224. package/build/macros/commands/Draw.js +0 -40
  225. package/build/macros/commands/Draw.js.map +0 -1
  226. package/build/macros/commands/DrawFlush.js +0 -18
  227. package/build/macros/commands/DrawFlush.js.map +0 -1
  228. package/build/macros/commands/GetLink.js +0 -25
  229. package/build/macros/commands/GetLink.js.map +0 -1
  230. package/build/macros/commands/Lookup.js +0 -25
  231. package/build/macros/commands/Lookup.js.map +0 -1
  232. package/build/macros/commands/Print.js +0 -18
  233. package/build/macros/commands/Print.js.map +0 -1
  234. package/build/macros/commands/PrintFlush.js +0 -18
  235. package/build/macros/commands/PrintFlush.js.map +0 -1
  236. package/build/macros/commands/Radar.js +0 -65
  237. package/build/macros/commands/Radar.js.map +0 -1
  238. package/build/macros/commands/Sensor.js +0 -21
  239. package/build/macros/commands/Sensor.js.map +0 -1
  240. package/build/macros/commands/UnitBind.js +0 -18
  241. package/build/macros/commands/UnitBind.js.map +0 -1
  242. package/build/macros/commands/UnitControl.js +0 -73
  243. package/build/macros/commands/UnitControl.js.map +0 -1
  244. package/build/macros/commands/UnitLocate.js +0 -76
  245. package/build/macros/commands/UnitLocate.js.map +0 -1
  246. package/build/macros/commands/UnitRadar.js +0 -48
  247. package/build/macros/commands/UnitRadar.js.map +0 -1
  248. package/build/macros/commands/Wait.js +0 -19
  249. package/build/macros/commands/Wait.js.map +0 -1
  250. package/build/macros/commands/index.js +0 -33
  251. package/build/macros/commands/index.js.map +0 -1
  252. package/build/macros/index.js +0 -40
  253. package/build/macros/index.js.map +0 -1
  254. package/build/operators.js +0 -102
  255. package/build/operators.js.map +0 -1
  256. package/build/types.js +0 -28
  257. package/build/types.js.map +0 -1
  258. package/build/utils.js +0 -18
  259. package/build/utils.js.map +0 -1
  260. package/build/values/BaseValue.js +0 -112
  261. package/build/values/BaseValue.js.map +0 -1
  262. package/build/values/FunctionValue.js +0 -116
  263. package/build/values/FunctionValue.js.map +0 -1
  264. package/build/values/LiteralValue.js +0 -89
  265. package/build/values/LiteralValue.js.map +0 -1
  266. package/build/values/ObjectValue.js +0 -55
  267. package/build/values/ObjectValue.js.map +0 -1
  268. package/build/values/StoreValue.js +0 -32
  269. package/build/values/StoreValue.js.map +0 -1
  270. package/build/values/TempValue.js +0 -78
  271. package/build/values/TempValue.js.map +0 -1
  272. package/build/values/VoidValue.js +0 -32
  273. package/build/values/VoidValue.js.map +0 -1
  274. package/build/values/index.js +0 -23
  275. package/build/values/index.js.map +0 -1
  276. package/dist/types/macros/Building.d.ts +0 -10
  277. package/dist/types/macros/Entities.d.ts +0 -11
  278. package/dist/types/values/TempValue.d.ts +0 -19
@@ -1,116 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FunctionValue = void 0;
4
- const utils_1 = require("src/utils");
5
- const CompilerError_1 = require("../CompilerError");
6
- const instructions_1 = require("../instructions");
7
- const LiteralValue_1 = require("./LiteralValue");
8
- const StoreValue_1 = require("./StoreValue");
9
- const TempValue_1 = require("./TempValue");
10
- const VoidValue_1 = require("./VoidValue");
11
- class FunctionValue extends VoidValue_1.VoidValue {
12
- constructor({ scope, name, paramNames, paramStores, body, c, renameable = false, }) {
13
- super(scope);
14
- this.constant = true;
15
- this.macro = true;
16
- this.bundled = false;
17
- this.initialized = false;
18
- this.name = name;
19
- this.paramNames = paramNames;
20
- this.paramStores = paramStores;
21
- this.body = body;
22
- this.c = c;
23
- this.renameable = renameable;
24
- this.callSize = paramStores.length + 2;
25
- scope.function = this;
26
- }
27
- typeof(scope) {
28
- return [new LiteralValue_1.LiteralValue(scope, "function"), []];
29
- }
30
- ensureInit() {
31
- if (this.initialized)
32
- return;
33
- this.initialized = true;
34
- this.addr = new LiteralValue_1.LiteralValue(this.scope, null);
35
- this.temp = new StoreValue_1.StoreValue(this.scope, `${utils_1.internalPrefix}f${this.name}`);
36
- this.ret = new StoreValue_1.StoreValue(this.scope, `${utils_1.internalPrefix}r${this.name}`);
37
- this.inst = [
38
- new instructions_1.AddressResolver(this.addr),
39
- ...this.c.handle(this.scope, this.body)[1],
40
- ];
41
- this.inst.push(new instructions_1.SetCounterInstruction(this.ret));
42
- }
43
- normalReturn(scope, arg) {
44
- const argInst = arg ? this.temp["="](scope, arg)[1] : [];
45
- return [null, [...argInst, new instructions_1.SetCounterInstruction(this.ret)]];
46
- }
47
- normalCall(scope, args) {
48
- if (!this.bundled)
49
- this.scope.inst.push(...this.inst);
50
- this.bundled = true;
51
- const callAddressLiteral = new LiteralValue_1.LiteralValue(scope, null);
52
- const inst = this.paramStores
53
- .map((param, i) => param["="](scope, args[i])[1])
54
- .reduce((s, c) => s.concat(c), [])
55
- .concat(...this.ret["="](scope, callAddressLiteral)[1], new instructions_1.JumpInstruction(this.addr, instructions_1.EJumpKind.Always), new instructions_1.AddressResolver(callAddressLiteral));
56
- return [this.temp, inst];
57
- }
58
- inlineReturn(scope, arg) {
59
- const argInst = arg ? this.inlineTemp["="](scope, arg)[1] : [];
60
- return [null, [...argInst, new instructions_1.ReturnInstruction(this.inlineEnd)]];
61
- }
62
- inlineCall(scope, args) {
63
- // create return value
64
- this.inlineTemp = new TempValue_1.TempValue({ scope });
65
- this.inlineEnd = new LiteralValue_1.LiteralValue(scope, null);
66
- // make a copy of the function scope
67
- const fnScope = this.scope.copy();
68
- // hard set variables within the function scope
69
- this.paramNames.forEach((name, i) => fnScope.hardSet(name, args[i]));
70
- this.tryingInline = true;
71
- const inst = this.c.handle(fnScope, this.body)[1];
72
- this.tryingInline = false;
73
- // removing useless instruction
74
- // get the last instructions
75
- // const [jump] = inst.slice(-1);
76
- // if (jump instanceof JumpInstruction) {
77
- // // remove useless jump
78
- // if (jump.args[1] === this.inlineEnd) inst.pop();
79
- // }
80
- inst.push(new instructions_1.AddressResolver(this.inlineEnd));
81
- // return the function value
82
- return [this.inlineTemp, inst];
83
- }
84
- call(scope, args) {
85
- this.ensureInit();
86
- if (args.length !== this.paramStores.length)
87
- throw new CompilerError_1.CompilerError("Cannot call: argument count not matching.");
88
- const inlineCall = this.inlineCall(scope, args);
89
- const inlineSize = inlineCall[1].filter(i => !i.hidden).length;
90
- if (this.inline || inlineSize <= this.callSize)
91
- return inlineCall;
92
- return this.normalCall(scope, args);
93
- }
94
- return(scope, arg) {
95
- this.ensureInit();
96
- if (arg && arg.macro) {
97
- this.inline = true;
98
- return [null, []];
99
- }
100
- if (this.inline || this.tryingInline)
101
- return this.inlineReturn(scope, arg);
102
- return this.normalReturn(scope, arg);
103
- }
104
- eval(_scope) {
105
- return [this, []];
106
- }
107
- rename(name) {
108
- if (!this.renameable)
109
- return;
110
- this.name = name;
111
- this.scope.name = name;
112
- this.renameable = false;
113
- }
114
- }
115
- exports.FunctionValue = FunctionValue;
116
- //# sourceMappingURL=FunctionValue.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FunctionValue.js","sourceRoot":"","sources":["../../src/values/FunctionValue.ts"],"names":[],"mappings":";;;AAAA,qCAA2C;AAE3C,oDAAiD;AACjD,kDAMyB;AASzB,iDAA8C;AAC9C,6CAA0C;AAC1C,2CAAwC;AACxC,2CAAwC;AAExC,MAAa,aAAc,SAAQ,qBAAS;IAsC1C,YAAY,EACV,KAAK,EACL,IAAI,EACJ,UAAU,EACV,WAAW,EACX,IAAI,EACJ,CAAC,EACD,UAAU,GAAG,KAAK,GASnB;QACC,KAAK,CAAC,KAAK,CAAC,CAAC;QAtDf,aAAQ,GAAG,IAAI,CAAC;QAChB,UAAK,GAAG,IAAI,CAAC;QAeL,YAAO,GAAG,KAAK,CAAC;QAEhB,gBAAW,GAAG,KAAK,CAAC;QAsC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QACX,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAE7B,IAAI,CAAC,QAAQ,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC;QACvC,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC;IACxB,CAAC;IA7CD,MAAM,CAAC,KAAa;QAClB,OAAO,CAAC,IAAI,2BAAY,CAAC,KAAK,EAAE,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC;IACnD,CAAC;IAEO,UAAU;QAChB,IAAI,IAAI,CAAC,WAAW;YAAE,OAAO;Q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Q;YAAE,OAAO,UAAU,CAAC;QAClE,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACtC,CAAC;IAED,MAAM,CAAC,KAAa,EAAE,GAAkB;QACtC,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,IAAI,GAAG,IAAI,GAAG,CAAC,KAAK,EAAE;YACpB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;YACnB,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;SACnB;QACD,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,YAAY;YAAE,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC3E,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACvC,CAAC;IAED,IAAI,CAAC,MAAc;QACjB,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACpB,CAAC;IAED,MAAM,CAAC,IAAY;QACjB,IAAI,CAAC,IAAI,CAAC,UAAU;YAAE,OAAO;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;IAC1B,CAAC;CACF;AA7JD,sCA6JC"}
@@ -1,89 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LiteralValue = void 0;
4
- const _1 = require(".");
5
- const CompilerError_1 = require("../CompilerError");
6
- const literalMethods = {
7
- length: function (scope) {
8
- if (typeof this.data !== "string")
9
- throw new CompilerError_1.CompilerError("Length method only works on string literal values.");
10
- return new LiteralValue(scope, this.data.length);
11
- },
12
- };
13
- class LiteralValue extends _1.BaseValue {
14
- constructor(scope, data) {
15
- super(scope);
16
- this.constant = true;
17
- this.data = data;
18
- }
19
- eval(_scope) {
20
- return [this, []];
21
- }
22
- toString() {
23
- return JSON.stringify(this.data);
24
- }
25
- get(scope, name) {
26
- if (!(name instanceof LiteralValue && typeof name.data === "string"))
27
- return super.get(scope, name);
28
- const method = literalMethods[name.data];
29
- if (!method)
30
- throw new CompilerError_1.CompilerError(`Method ${name.data} does not exist on literal values.`);
31
- return [method.apply(this, [scope]), []];
32
- }
33
- get num() {
34
- if (this.data === null)
35
- return 0;
36
- if (typeof this.data === "string")
37
- return 1;
38
- return this.data;
39
- }
40
- typeof(scope) {
41
- return [new LiteralValue(scope, "literal"), []];
42
- }
43
- }
44
- exports.LiteralValue = LiteralValue;
45
- const operatorMap = {
46
- "==": (a, b) => +(a == b),
47
- "===": (a, b) => +(a === b),
48
- "!=": (a, b) => +(a != b),
49
- "!==": (a, b) => +(a !== b),
50
- "<": (a, b) => +(a < b),
51
- ">": (a, b) => +(a > b),
52
- "<=": (a, b) => +(a <= b),
53
- ">=": (a, b) => +(a >= b),
54
- "+": (a, b) => a + b,
55
- "-": (a, b) => a - b,
56
- "*": (a, b) => a * b,
57
- "/": (a, b) => a / b,
58
- "%": (a, b) => a % b,
59
- "**": (a, b) => a ** b,
60
- "|": (a, b) => a | b,
61
- "&": (a, b) => a & b,
62
- "^": (a, b) => a ^ b,
63
- ">>": (a, b) => a >> b,
64
- ">>>": (a, b) => a >> b,
65
- "<<": (a, b) => a << b,
66
- "&&": (a, b) => +(a && b),
67
- "||": (a, b) => +(a || b),
68
- };
69
- for (const key in operatorMap) {
70
- const fn = operatorMap[key];
71
- LiteralValue.prototype[key] = function (scope, value) {
72
- if (!(value instanceof LiteralValue)) {
73
- return _1.BaseValue.prototype[key].apply(this, [scope, value]);
74
- }
75
- return [new LiteralValue(scope, fn(this.num, value.num)), []];
76
- };
77
- }
78
- const unaryOperatorMap = {
79
- "!": v => +!v,
80
- "~": v => ~v,
81
- "u-": v => -v,
82
- };
83
- for (const key in unaryOperatorMap) {
84
- LiteralValue.prototype[key] = function (scope) {
85
- const fn = unaryOperatorMap[key];
86
- return [new LiteralValue(scope, fn(this.num)), []];
87
- };
88
- }
89
- //# sourceMappingURL=LiteralValue.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LiteralValue.js","sourceRoot":"","sources":["../../src/values/LiteralValue.ts"],"names":[],"mappings":";;;AAOA,wBAA8B;AAE9B,oDAAiD;AAEjD,MAAM,cAAc,GAGhB;IACF,MAAM,EAAE,UAA8B,KAAa;QACjD,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ;YAC/B,MAAM,IAAI,6BAAa,CACrB,oDAAoD,CACrD,CAAC;QACJ,OAAO,IAAI,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACnD,CAAC;CACF,CAAC;AAEF,MAAa,YAAa,SAAQ,YAAS;IAGzC,YAAY,KAAa,EAAE,IAAc;QACvC,KAAK,CAAC,KAAK,CAAC,CAAC;QAFf,aAAQ,GAAG,IAAI,CAAC;QAGd,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IACD,IAAI,CAAC,MAAc;QACjB,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACpB,CAAC;IACD,QAAQ;QACN,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;IACD,GAAG,CAAC,KAAa,EAAE,IAAY;QAC7B,IAAI,CAAC,CAAC,IAAI,YAAY,YAAY,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC;YAClE,OAAO,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAChC,MAAM,MAAM,GAAG,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,MAAM;YACT,MAAM,IAAI,6BAAa,CACrB,UAAU,IAAI,CAAC,IAAI,oCAAoC,CACxD,CAAC;QACJ,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,KA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,GAAQ,CAAC,GAAG,UAEjC,KAAa,EACb,KAAmB;QAEnB,IAAI,CAAC,CAAC,KAAK,YAAY,YAAY,CAAC,EAAE;YACpC,OAAO,YAAS,CAAC,SAAS,CAAC,GAAQ,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;SAClE;QACD,OAAO,CAAC,IAAI,YAAY,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAChE,CAAC,CAAC;CACH;AAED,MAAM,gBAAgB,GAKlB;IACF,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACb,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACZ,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CACL,CAAC;AAEX,KAAK,MAAM,GAAG,IAAI,gBAAgB,EAAE;IAElC,YAAY,CAAC,SAAS,CAAC,GAAQ,CAAC,GAAG,UAEjC,KAAa;QAEb,MAAM,EAAE,GAAG,gBAAgB,CAAC,GAAQ,CAAC,CAAC;QACtC,OAAO,CAAC,IAAI,YAAY,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACrD,CAAC,CAAC;CACH"}
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ObjectValue = void 0;
4
- const CompilerError_1 = require("../CompilerError");
5
- const operators_1 = require("../operators");
6
- const LiteralValue_1 = require("./LiteralValue");
7
- const VoidValue_1 = require("./VoidValue");
8
- class ObjectValue extends VoidValue_1.VoidValue {
9
- constructor(scope, data = {}) {
10
- super(scope);
11
- this.constant = true;
12
- this.macro = true;
13
- this.data = data;
14
- }
15
- typeof(scope) {
16
- return [new LiteralValue_1.LiteralValue(scope, "object"), []];
17
- }
18
- get(scope, key) {
19
- // avoids naming collisions with keys like
20
- // constructor or toString
21
- if (Object.prototype.hasOwnProperty.call(this.data, key.data)) {
22
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
23
- const member = this.data[key.data];
24
- return [member, []];
25
- }
26
- const { $get } = this.data;
27
- if (!$get)
28
- throw new CompilerError_1.CompilerError("Cannot get undefined member.");
29
- return $get.call(scope, [key]);
30
- }
31
- eval(scope) {
32
- const { $eval } = this.data;
33
- if (!$eval)
34
- return [this, []];
35
- return $eval.call(scope, []);
36
- }
37
- call(scope, args) {
38
- const { $call } = this.data;
39
- if (!$call)
40
- return super.call(scope, args);
41
- return $call.call(scope, args);
42
- }
43
- }
44
- exports.ObjectValue = ObjectValue;
45
- for (const op of operators_1.operators) {
46
- ObjectValue.prototype[op] = function (...args) {
47
- const $ = this.data[`$${op}`];
48
- // eslint-disable-next-line @typescript-eslint/ban-types, @typescript-eslint/no-unsafe-return
49
- if (!$)
50
- return VoidValue_1.VoidValue.prototype[op].apply(this, args);
51
- const [scope, ...fnArgs] = args;
52
- return $.call(scope, fnArgs);
53
- };
54
- }
55
- //# sourceMappingURL=ObjectValue.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ObjectValue.js","sourceRoot":"","sources":["../../src/values/ObjectValue.ts"],"names":[],"mappings":";;;AAAA,oDAAiD;AAEjD,4CAAyC;AAOzC,iDAA8C;AAC9C,2CAAwC;AAOxC,MAAa,WAAY,SAAQ,qBAAS;IAKxC,YAAY,KAAa,EAAE,OAAyB,EAAE;QACpD,KAAK,CAAC,KAAK,CAAC,CAAC;QALf,aAAQ,GAAG,IAAI,CAAC;QAChB,UAAK,GAAG,IAAI,CAAC;QAKX,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,MAAM,CAAC,KAAa;QAClB,OAAO,CAAC,IAAI,2BAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC;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I,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC9B,6FAA6F;QAC7F,IAAI,CAAC,CAAC;YAAE,OAAQ,qBAAS,CAAC,SAAS,CAAC,EAAE,CAAc,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACvE,MAAM,CAAC,KAAK,EAAE,GAAG,MAAM,CAAC,GAAG,IAAI,CAAC;QAChC,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC/B,CAAC,CAAC;CACH"}
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StoreValue = void 0;
4
- const _1 = require(".");
5
- const CompilerError_1 = require("../CompilerError");
6
- const instructions_1 = require("../instructions");
7
- class StoreValue extends _1.BaseValue {
8
- constructor(scope, name) {
9
- super(scope);
10
- this.constant = false;
11
- this.name = name;
12
- }
13
- typeof(scope) {
14
- return [new _1.LiteralValue(scope, "store"), []];
15
- }
16
- "="(scope, value) {
17
- if (this.constant)
18
- throw new CompilerError_1.CompilerError(`Cannot assign to unmutable store '${this.name}'.`);
19
- if (value instanceof _1.TempValue && value.canProxy)
20
- return value.proxy(this);
21
- const [evalValue, evalInst] = value.eval(scope);
22
- return [this, [...evalInst, new instructions_1.SetInstruction(this, evalValue)]];
23
- }
24
- eval(_scope) {
25
- return [this, []];
26
- }
27
- toString() {
28
- return this.name;
29
- }
30
- }
31
- exports.StoreValue = StoreValue;
32
- //# sourceMappingURL=StoreValue.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"StoreValue.js","sourceRoot":"","sources":["../../src/values/StoreValue.ts"],"names":[],"mappings":";;;AAAA,wBAAuD;AACvD,oDAAiD;AACjD,kDAAiD;AAGjD,MAAa,UAAW,SAAQ,YAAS;IAGvC,YAAY,KAAa,EAAE,IAAY;QACrC,KAAK,CAAC,KAAK,CAAC,CAAC;QAFf,aAAQ,GAAG,KAAK,CAAC;QAGf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,MAAM,CAAC,KAAa;QAClB,OAAO,CAAC,IAAI,eAAY,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;IAChD,CAAC;IAED,GAAG,CAAC,KAAa,EAAE,KAAa;QAC9B,IAAI,IAAI,CAAC,QAAQ;YACf,MAAM,IAAI,6BAAa,CACrB,qCAAqC,IAAI,CAAC,IAAI,IAAI,CACnD,CAAC;QACJ,IAAI,KAAK,YAAY,YAAS,IAAI,KAAK,CAAC,QAAQ;YAAE,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC3E,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAChD,OAAO,CAAC,IAAI,EAAE,CAAC,GAAG,QAAQ,EAAE,IAAI,6BAAc,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACpE,CAAC;IACD,IAAI,CAAC,MAAc;QACjB,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACpB,CAAC;IACD,QAAQ;QACN,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;CACF;AA3BD,gCA2BC"}
@@ -1,78 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TempValue = void 0;
4
- const CompilerError_1 = require("../CompilerError");
5
- const instructions_1 = require("../instructions");
6
- const operators_1 = require("../operators");
7
- const _1 = require("./");
8
- const LiteralValue_1 = require("./LiteralValue");
9
- class TempValue extends _1.StoreValue {
10
- constructor({ scope, name, renameable = true }) {
11
- super(scope, name ?? scope.makeTempName());
12
- this.canProxy = true;
13
- this.renameable = renameable;
14
- }
15
- eval(scope) {
16
- return super.eval(scope);
17
- }
18
- "="(scope, value) {
19
- if (this.proxied) {
20
- this.noProxy();
21
- return [this, [new instructions_1.SetInstruction(this, value)]];
22
- }
23
- if (value instanceof LiteralValue_1.LiteralValue && this.canProxy) {
24
- return this.proxy(value);
25
- }
26
- return super["="](scope, value);
27
- }
28
- proxy(value) {
29
- if (!this.canProxy) {
30
- console.log(this.proxied);
31
- throw new CompilerError_1.CompilerError("Cannot proxy (canProxy = false).");
32
- }
33
- if (this.proxied)
34
- throw new CompilerError_1.CompilerError("Cannot proxy multiple times.");
35
- this.proxied = value;
36
- this.canProxy = false;
37
- for (const key of [
38
- ...operators_1.operators,
39
- "eval",
40
- "get",
41
- "call",
42
- "toString",
43
- "proxy",
44
- "rename",
45
- ]) {
46
- if (key !== "=" && key in value)
47
- this[key] = (...args) => {
48
- // eslint-disable-next-line @typescript-eslint/ban-types, @typescript-eslint/no-unsafe-return
49
- return value[key].apply(value, args);
50
- };
51
- }
52
- this.setInst = new instructions_1.SetInstruction(this, value);
53
- this.setInst.hidden = true;
54
- return [this, [this.setInst]];
55
- }
56
- noProxy() {
57
- this.setInst.hidden = false;
58
- for (const key of [
59
- ...operators_1.operators,
60
- "eval",
61
- "get",
62
- "call",
63
- "toString",
64
- "proxy",
65
- "rename",
66
- ]) {
67
- this[key] = TempValue.prototype[key];
68
- }
69
- }
70
- rename(name) {
71
- if (!this.renameable)
72
- return;
73
- this.name = name;
74
- this.renameable = false;
75
- }
76
- }
77
- exports.TempValue = TempValue;
78
- //# sourceMappingURL=TempValue.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TempValue.js","sourceRoot":"","sources":["../../src/values/TempValue.ts"],"names":[],"mappings":";;;AAAA,oDAAiD;AACjD,kDAAiD;AACjD,4CAAyC;AAEzC,yBAAgC;AAChC,iDAA8C;AAQ9C,MAAa,SAAU,SAAQ,aAAU;IAMvC,YAAY,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI,EAAoB;QAC9D,KAAK,CAAC,KAAK,EAAE,IAAI,IAAI,KAAK,CAAC,YAAY,EAAE,CAAC,CAAC;QAL7C,aAAQ,GAAG,IAA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AAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;gBACrE,CAAC,CAAC;SACL;QACD,IAAI,CAAC,OAAO,GAAG,IAAI,6BAAc,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC/C,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;QAC3B,OAAO,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAChC,CAAC;IAED,OAAO;QACL,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC;QAC5B,KAAK,MAAM,GAAG,IAAI;YAChB,GAAG,qBAAS;YACZ,MAAM;YACN,KAAK;YACL,MAAM;YACN,UAAU;YACV,OAAO;YACP,QAAQ;SACA,EAAE;YACV,IAAI,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,SAAS,CAAC,GAAG,CAAU,CAAC;SAC/C;IACH,CAAC;IAED,MAAM,CAAC,IAAY;QACjB,IAAI,CAAC,IAAI,CAAC,UAAU;YAAE,OAAO;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;IAC1B,CAAC;CACF;AA1ED,8BA0EC"}
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VoidValue = void 0;
4
- const operators_1 = require("../operators");
5
- const CompilerError_1 = require("../CompilerError");
6
- class VoidValue {
7
- constructor(scope) {
8
- this.constant = false;
9
- this.macro = false;
10
- this.scope = scope;
11
- }
12
- eval(_scope) {
13
- throw new CompilerError_1.CompilerError(`${this} cannot eval.`);
14
- }
15
- call(_scope, _args) {
16
- throw new CompilerError_1.CompilerError(`${this} cannot call.`);
17
- }
18
- get(_scope, _name) {
19
- throw new CompilerError_1.CompilerError(`${this} cannot get.`);
20
- }
21
- toString() {
22
- return "void";
23
- }
24
- }
25
- exports.VoidValue = VoidValue;
26
- for (const key of operators_1.operators) {
27
- VoidValue.prototype[key] = function () {
28
- console.log(this);
29
- throw new CompilerError_1.CompilerError(`${this} cannot '${key}' operation.`);
30
- };
31
- }
32
- //# sourceMappingURL=VoidValue.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"VoidValue.js","sourceRoot":"","sources":["../../src/values/VoidValue.ts"],"names":[],"mappings":";;;AACA,4CAAyC;AACzC,oDAAiD;AAEjD,MAAa,SAAS;IAIpB,YAAY,KAAa;QAFzB,aAAQ,GAAG,KAAK,CAAC;QACjB,UAAK,GAAG,KAAK,CAAC;QAEZ,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IACD,IAAI,CAAC,MAAc;QACjB,MAAM,IAAI,6BAAa,CAAC,GAAG,IAAI,eAAe,CAAC,CAAC;IAClD,CAAC;IACD,IAAI,CAAC,MAAc,EAAE,KAAe;QAClC,MAAM,IAAI,6BAAa,CAAC,GAAG,IAAI,eAAe,CAAC,CAAC;IAClD,CAAC;IACD,GAAG,CAAC,MAAc,EAAE,KAAa;QAC/B,MAAM,IAAI,6BAAa,CAAC,GAAG,IAAI,cAAc,CAAC,CAAC;IACjD,CAAC;IACD,QAAQ;QACN,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAnBD,8BAmBC;AAKD,KAAK,MAAM,GAAG,IAAI,qBAAS,EAAE;IAC3B,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG;QACzB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAClB,MAAM,IAAI,6BAAa,CAAC,GAAG,IAAI,YAAY,GAAG,cAAc,CAAC,CAAC;IAChE,CAAC,CAAC;CACH"}
@@ -1,23 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./VoidValue"), exports);
18
- __exportStar(require("./BaseValue"), exports);
19
- __exportStar(require("./LiteralValue"), exports);
20
- __exportStar(require("./StoreValue"), exports);
21
- __exportStar(require("./TempValue"), exports);
22
- __exportStar(require("./ObjectValue"), exports);
23
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/values/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,8CAA4B;AAC5B,iDAA+B;AAC/B,+CAA6B;AAC7B,8CAA4B;AAC5B,gDAA8B"}
@@ -1,10 +0,0 @@
1
- import { IScope } from "../types";
2
- import { ObjectValue } from "../values";
3
- export declare const itemNames: string[];
4
- export declare class Building extends ObjectValue {
5
- toString(): string;
6
- constructor(scope: IScope);
7
- }
8
- export declare class BuildingBuilder extends ObjectValue {
9
- constructor(scope: IScope);
10
- }
@@ -1,11 +0,0 @@
1
- import { IScope, IValue } from "../types";
2
- import { ObjectValue } from "../values";
3
- export declare const itemNames: string[];
4
- export declare class Building extends ObjectValue {
5
- toString(): string;
6
- constructor(scope: IScope);
7
- }
8
- export declare class Unit extends ObjectValue implements IValue {
9
- constructor(scope: IScope);
10
- toString(): string;
11
- }
@@ -1,19 +0,0 @@
1
- import { IInstruction, IScope, IValue, TValueInstructions } from "../types";
2
- import { StoreValue } from "./";
3
- export interface TempValueOptions {
4
- scope: IScope;
5
- name?: string;
6
- renameable?: boolean;
7
- }
8
- export declare class TempValue extends StoreValue implements IValue {
9
- proxied: IValue;
10
- canProxy: boolean;
11
- setInst: IInstruction;
12
- renameable: boolean;
13
- constructor({ scope, name, renameable }: TempValueOptions);
14
- eval(scope: IScope): TValueInstructions;
15
- "="(scope: IScope, value: IValue): TValueInstructions;
16
- proxy(value: IValue): TValueInstructions;
17
- noProxy(): void;
18
- rename(name: string): void;
19
- }