mlogjs 0.2.1 → 0.2.2

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 (218) hide show
  1. package/build/bin.cjs +69 -0
  2. package/dist/bin.cjs +69 -0
  3. package/dist/index.cjs +1817 -0
  4. package/dist/index.mjs +1813 -0
  5. package/dist/types/Compiler.d.ts +18 -0
  6. package/{build → dist/types}/Scope.d.ts +23 -26
  7. package/dist/types/bin.d.ts +1 -0
  8. package/dist/types/handlers/BlockStatement.d.ts +2 -0
  9. package/dist/types/handlers/CallExpression.d.ts +3 -0
  10. package/dist/types/handlers/ForStatement.d.ts +2 -0
  11. package/{build → dist/types}/handlers/Function.d.ts +4 -4
  12. package/{build → dist/types}/handlers/Identifier.d.ts +2 -2
  13. package/dist/types/handlers/IfStatement.d.ts +2 -0
  14. package/{build → dist/types}/handlers/Literal.d.ts +2 -2
  15. package/{build → dist/types}/handlers/Object.d.ts +4 -4
  16. package/{build → dist/types}/handlers/OperationExpressions.d.ts +7 -7
  17. package/dist/types/handlers/Program.d.ts +2 -0
  18. package/dist/types/handlers/Statements.d.ts +5 -0
  19. package/dist/types/handlers/TemplateExpression.d.ts +2 -0
  20. package/dist/types/handlers/VariableDeclaration.d.ts +3 -0
  21. package/dist/types/handlers/WhileStatement.d.ts +2 -0
  22. package/{build → dist/types}/handlers/index.d.ts +14 -14
  23. package/dist/types/index.d.ts +1 -0
  24. package/{build → dist/types}/initScope.d.ts +2 -2
  25. package/{build → dist/types}/instructions/AddressResolver.d.ts +12 -12
  26. package/{build → dist/types}/instructions/ControlInstructions.d.ts +11 -11
  27. package/{build → dist/types}/instructions/EndInstruction.d.ts +4 -4
  28. package/{build → dist/types}/instructions/InstructionBase.d.ts +10 -10
  29. package/{build → dist/types}/instructions/JumpInstruction.d.ts +15 -15
  30. package/{build → dist/types}/instructions/OperationInstruction.d.ts +5 -5
  31. package/{build → dist/types}/instructions/SetCounterInstruction.d.ts +5 -5
  32. package/{build → dist/types}/instructions/SetInstruction.d.ts +5 -5
  33. package/{build → dist/types}/instructions/ZeroSpaceInstruction.d.ts +4 -4
  34. package/{build → dist/types}/instructions/index.d.ts +9 -9
  35. package/{build → dist/types}/macros/Building.d.ts +11 -11
  36. package/dist/types/macros/Function.d.ts +12 -0
  37. package/{build → dist/types}/macros/Math.d.ts +5 -5
  38. package/{build → dist/types}/macros/Memory.d.ts +5 -5
  39. package/{build → dist/types}/macros/Namespace.d.ts +21 -21
  40. package/{build → dist/types}/macros/Other.d.ts +5 -5
  41. package/{build → dist/types}/macros/RawValue.d.ts +5 -5
  42. package/{build → dist/types}/macros/commands/Control.d.ts +5 -5
  43. package/{build → dist/types}/macros/commands/Draw.d.ts +5 -5
  44. package/{build → dist/types}/macros/commands/DrawFlush.d.ts +5 -5
  45. package/{build → dist/types}/macros/commands/GetLink.d.ts +5 -5
  46. package/{build → dist/types}/macros/commands/Lookup.d.ts +5 -5
  47. package/{build → dist/types}/macros/commands/Print.d.ts +5 -5
  48. package/{build → dist/types}/macros/commands/PrintFlush.d.ts +5 -5
  49. package/{build → dist/types}/macros/commands/Radar.d.ts +7 -7
  50. package/{build → dist/types}/macros/commands/Sensor.d.ts +5 -5
  51. package/{build → dist/types}/macros/commands/UnitBind.d.ts +5 -5
  52. package/dist/types/macros/commands/UnitControl.d.ts +5 -0
  53. package/{build → dist/types}/macros/commands/UnitLocate.d.ts +5 -5
  54. package/{build → dist/types}/macros/commands/UnitRadar.d.ts +5 -5
  55. package/{build → dist/types}/macros/commands/Wait.d.ts +5 -5
  56. package/{build → dist/types}/macros/commands/index.d.ts +14 -14
  57. package/{build → dist/types}/macros/index.d.ts +7 -7
  58. package/{build → dist/types}/operators.d.ts +25 -25
  59. package/dist/types/types.d.ts +100 -0
  60. package/{build → dist/types}/utils.d.ts +3 -3
  61. package/{build → dist/types}/values/BaseValue.d.ts +5 -5
  62. package/{build → dist/types}/values/FunctionValue.d.ts +34 -34
  63. package/{build → dist/types}/values/LiteralValue.d.ts +12 -12
  64. package/dist/types/values/ObjectValue.d.ts +19 -0
  65. package/{build → dist/types}/values/StoreValue.d.ts +11 -11
  66. package/{build → dist/types}/values/TempValue.d.ts +12 -12
  67. package/{build → dist/types}/values/VoidValue.d.ts +13 -11
  68. package/{build → dist/types}/values/index.d.ts +6 -6
  69. package/doc/README.md +9 -0
  70. package/lib/eslib/lib.es5.d.ts +1 -1
  71. package/lib/traits.d.ts +0 -1
  72. package/package.json +17 -27
  73. package/build/Compiler.d.ts +0 -18
  74. package/build/Compiler.js +0 -100
  75. package/build/Compiler.js.map +0 -1
  76. package/build/Scope.js +0 -61
  77. package/build/Scope.js.map +0 -1
  78. package/build/bin.d.ts +0 -2
  79. package/build/bin.js +0 -61
  80. package/build/bin.js.map +0 -1
  81. package/build/handlers/BlockStatement.d.ts +0 -2
  82. package/build/handlers/BlockStatement.js +0 -14
  83. package/build/handlers/BlockStatement.js.map +0 -1
  84. package/build/handlers/CallExpression.d.ts +0 -3
  85. package/build/handlers/CallExpression.js +0 -20
  86. package/build/handlers/CallExpression.js.map +0 -1
  87. package/build/handlers/ForStatement.d.ts +0 -2
  88. package/build/handlers/ForStatement.js +0 -32
  89. package/build/handlers/ForStatement.js.map +0 -1
  90. package/build/handlers/Function.js +0 -36
  91. package/build/handlers/Function.js.map +0 -1
  92. package/build/handlers/Identifier.js +0 -8
  93. package/build/handlers/Identifier.js.map +0 -1
  94. package/build/handlers/IfStatement.d.ts +0 -2
  95. package/build/handlers/IfStatement.js +0 -25
  96. package/build/handlers/IfStatement.js.map +0 -1
  97. package/build/handlers/Literal.js +0 -18
  98. package/build/handlers/Literal.js.map +0 -1
  99. package/build/handlers/Object.js +0 -44
  100. package/build/handlers/Object.js.map +0 -1
  101. package/build/handlers/OperationExpressions.js +0 -33
  102. package/build/handlers/OperationExpressions.js.map +0 -1
  103. package/build/handlers/Program.d.ts +0 -2
  104. package/build/handlers/Program.js +0 -9
  105. package/build/handlers/Program.js.map +0 -1
  106. package/build/handlers/Statements.d.ts +0 -5
  107. package/build/handlers/Statements.js +0 -30
  108. package/build/handlers/Statements.js.map +0 -1
  109. package/build/handlers/TemplateExpression.d.ts +0 -2
  110. package/build/handlers/TemplateExpression.js +0 -18
  111. package/build/handlers/TemplateExpression.js.map +0 -1
  112. package/build/handlers/VariableDeclaration.d.ts +0 -3
  113. package/build/handlers/VariableDeclaration.js +0 -56
  114. package/build/handlers/VariableDeclaration.js.map +0 -1
  115. package/build/handlers/WhileStatement.d.ts +0 -2
  116. package/build/handlers/WhileStatement.js +0 -23
  117. package/build/handlers/WhileStatement.js.map +0 -1
  118. package/build/handlers/index.js +0 -31
  119. package/build/handlers/index.js.map +0 -1
  120. package/build/index.d.ts +0 -1
  121. package/build/index.js +0 -8
  122. package/build/index.js.map +0 -1
  123. package/build/initScope.js +0 -40
  124. package/build/initScope.js.map +0 -1
  125. package/build/instructions/AddressResolver.js +0 -31
  126. package/build/instructions/AddressResolver.js.map +0 -1
  127. package/build/instructions/ControlInstructions.js +0 -23
  128. package/build/instructions/ControlInstructions.js.map +0 -1
  129. package/build/instructions/EndInstruction.js +0 -11
  130. package/build/instructions/EndInstruction.js.map +0 -1
  131. package/build/instructions/InstructionBase.js +0 -21
  132. package/build/instructions/InstructionBase.js.map +0 -1
  133. package/build/instructions/JumpInstruction.js +0 -22
  134. package/build/instructions/JumpInstruction.js.map +0 -1
  135. package/build/instructions/OperationInstruction.js +0 -11
  136. package/build/instructions/OperationInstruction.js.map +0 -1
  137. package/build/instructions/SetCounterInstruction.js +0 -11
  138. package/build/instructions/SetCounterInstruction.js.map +0 -1
  139. package/build/instructions/SetInstruction.js +0 -11
  140. package/build/instructions/SetInstruction.js.map +0 -1
  141. package/build/instructions/ZeroSpaceInstruction.js +0 -11
  142. package/build/instructions/ZeroSpaceInstruction.js.map +0 -1
  143. package/build/instructions/index.js +0 -26
  144. package/build/instructions/index.js.map +0 -1
  145. package/build/macros/Building.js +0 -81
  146. package/build/macros/Building.js.map +0 -1
  147. package/build/macros/Function.d.ts +0 -12
  148. package/build/macros/Function.js +0 -20
  149. package/build/macros/Function.js.map +0 -1
  150. package/build/macros/Math.js +0 -57
  151. package/build/macros/Math.js.map +0 -1
  152. package/build/macros/Memory.js +0 -61
  153. package/build/macros/Memory.js.map +0 -1
  154. package/build/macros/Namespace.js +0 -98
  155. package/build/macros/Namespace.js.map +0 -1
  156. package/build/macros/Other.js +0 -20
  157. package/build/macros/Other.js.map +0 -1
  158. package/build/macros/RawValue.js +0 -16
  159. package/build/macros/RawValue.js.map +0 -1
  160. package/build/macros/commands/Control.js +0 -25
  161. package/build/macros/commands/Control.js.map +0 -1
  162. package/build/macros/commands/Draw.js +0 -39
  163. package/build/macros/commands/Draw.js.map +0 -1
  164. package/build/macros/commands/DrawFlush.js +0 -17
  165. package/build/macros/commands/DrawFlush.js.map +0 -1
  166. package/build/macros/commands/GetLink.js +0 -21
  167. package/build/macros/commands/GetLink.js.map +0 -1
  168. package/build/macros/commands/Lookup.js +0 -24
  169. package/build/macros/commands/Lookup.js.map +0 -1
  170. package/build/macros/commands/Print.js +0 -14
  171. package/build/macros/commands/Print.js.map +0 -1
  172. package/build/macros/commands/PrintFlush.js +0 -17
  173. package/build/macros/commands/PrintFlush.js.map +0 -1
  174. package/build/macros/commands/Radar.js +0 -61
  175. package/build/macros/commands/Radar.js.map +0 -1
  176. package/build/macros/commands/Sensor.js +0 -20
  177. package/build/macros/commands/Sensor.js.map +0 -1
  178. package/build/macros/commands/UnitBind.js +0 -17
  179. package/build/macros/commands/UnitBind.js.map +0 -1
  180. package/build/macros/commands/UnitControl.d.ts +0 -5
  181. package/build/macros/commands/UnitControl.js +0 -68
  182. package/build/macros/commands/UnitControl.js.map +0 -1
  183. package/build/macros/commands/UnitLocate.js +0 -55
  184. package/build/macros/commands/UnitLocate.js.map +0 -1
  185. package/build/macros/commands/UnitRadar.js +0 -41
  186. package/build/macros/commands/UnitRadar.js.map +0 -1
  187. package/build/macros/commands/Wait.js +0 -18
  188. package/build/macros/commands/Wait.js.map +0 -1
  189. package/build/macros/commands/index.js +0 -33
  190. package/build/macros/commands/index.js.map +0 -1
  191. package/build/macros/index.js +0 -40
  192. package/build/macros/index.js.map +0 -1
  193. package/build/operators.js +0 -102
  194. package/build/operators.js.map +0 -1
  195. package/build/types.d.ts +0 -49
  196. package/build/types.js +0 -28
  197. package/build/types.js.map +0 -1
  198. package/build/utils.js +0 -13
  199. package/build/utils.js.map +0 -1
  200. package/build/values/BaseValue.js +0 -112
  201. package/build/values/BaseValue.js.map +0 -1
  202. package/build/values/FunctionValue.js +0 -104
  203. package/build/values/FunctionValue.js.map +0 -1
  204. package/build/values/LiteralValue.js +0 -88
  205. package/build/values/LiteralValue.js.map +0 -1
  206. package/build/values/ObjectValue.d.ts +0 -17
  207. package/build/values/ObjectValue.js +0 -50
  208. package/build/values/ObjectValue.js.map +0 -1
  209. package/build/values/StoreValue.js +0 -31
  210. package/build/values/StoreValue.js.map +0 -1
  211. package/build/values/TempValue.js +0 -67
  212. package/build/values/TempValue.js.map +0 -1
  213. package/build/values/VoidValue.js +0 -31
  214. package/build/values/VoidValue.js.map +0 -1
  215. package/build/values/index.js +0 -23
  216. package/build/values/index.js.map +0 -1
  217. package/dist/mlogjs.es.js +0 -6366
  218. package/dist/mlogjs.umd.js +0 -8
@@ -1,5 +1,5 @@
1
- import { MacroFunction } from "..";
2
- import { IScope } from "../../types";
3
- export declare class UnitBind extends MacroFunction {
4
- constructor(scope: IScope);
5
- }
1
+ import { MacroFunction } from "..";
2
+ import { IScope } from "../../types";
3
+ export declare class UnitBind extends MacroFunction<null> {
4
+ constructor(scope: IScope);
5
+ }
@@ -0,0 +1,5 @@
1
+ import { MacroFunction } from "..";
2
+ import { IScope, IValue } from "../../types";
3
+ export declare class UnitControl extends MacroFunction<IValue | null> {
4
+ constructor(scope: IScope);
5
+ }
@@ -1,5 +1,5 @@
1
- import { MacroFunction } from "..";
2
- import { IScope } from "../../types";
3
- export declare class UnitLocate extends MacroFunction {
4
- constructor(scope: IScope);
5
- }
1
+ import { MacroFunction } from "..";
2
+ import { IScope } from "../../types";
3
+ export declare class UnitLocate extends MacroFunction {
4
+ constructor(scope: IScope);
5
+ }
@@ -1,5 +1,5 @@
1
- import { MacroFunction } from "..";
2
- import { IScope } from "../../types";
3
- export declare class UnitRadar extends MacroFunction {
4
- constructor(scope: IScope);
5
- }
1
+ import { MacroFunction } from "..";
2
+ import { IScope } from "../../types";
3
+ export declare class UnitRadar extends MacroFunction {
4
+ constructor(scope: IScope);
5
+ }
@@ -1,5 +1,5 @@
1
- import { MacroFunction } from "..";
2
- import { IScope } from "../../types";
3
- export declare class Wait extends MacroFunction {
4
- constructor(scope: IScope);
5
- }
1
+ import { MacroFunction } from "..";
2
+ import { IScope } from "../../types";
3
+ export declare class Wait extends MacroFunction<null> {
4
+ constructor(scope: IScope);
5
+ }
@@ -1,14 +1,14 @@
1
- export * from "./Draw";
2
- export * from "./Print";
3
- export * from "./PrintFlush";
4
- export * from "./DrawFlush";
5
- export * from "./GetLink";
6
- export * from "./Control";
7
- export { Radar } from "./Radar";
8
- export * from "./Sensor";
9
- export * from "./Wait";
10
- export * from "./Lookup";
11
- export * from "./UnitBind";
12
- export * from "./UnitControl";
13
- export * from "./UnitRadar";
14
- export * from "./UnitLocate";
1
+ export * from "./Draw";
2
+ export * from "./Print";
3
+ export * from "./PrintFlush";
4
+ export * from "./DrawFlush";
5
+ export * from "./GetLink";
6
+ export * from "./Control";
7
+ export { Radar } from "./Radar";
8
+ export * from "./Sensor";
9
+ export * from "./Wait";
10
+ export * from "./Lookup";
11
+ export * from "./UnitBind";
12
+ export * from "./UnitControl";
13
+ export * from "./UnitRadar";
14
+ export * from "./UnitLocate";
@@ -1,7 +1,7 @@
1
- export * from "./Function";
2
- export * from "./Math";
3
- export * from "./Other";
4
- export * as commands from "./commands";
5
- export * from "./Memory";
6
- export { BuildingBuilder } from "./Building";
7
- export { NamespaceMacro, VarsNamespace } from "./Namespace";
1
+ export * from "./Function";
2
+ export * from "./Math";
3
+ export * from "./Other";
4
+ export * as commands from "./commands";
5
+ export * from "./Memory";
6
+ export { BuildingBuilder } from "./Building";
7
+ export { NamespaceMacro, VarsNamespace } from "./Namespace";
@@ -1,25 +1,25 @@
1
- export declare const arithmeticBinaryOperators: readonly ["*", "**", "+", "-", "/", "%"];
2
- export declare const comparisonBinaryOperators: readonly ["!=", "!==", "<", "<=", "==", "===", ">", ">="];
3
- export declare const bitwiseBinaryOperators: readonly ["&", "<<", ">>", ">>>", "^", "|"];
4
- export declare const binaryOperators: readonly ["*", "**", "+", "-", "/", "%", "!=", "!==", "<", "<=", "==", "===", ">", ">=", "&", "<<", ">>", ">>>", "^", "|", "instanceof", "in"];
5
- export declare type BinaryOperator = typeof binaryOperators[number];
6
- export declare const logicalOperators: readonly ["&&", "??", "||"];
7
- export declare type LogicalOperator = typeof logicalOperators[number];
8
- export declare const arithmeticAssignmentOperators: readonly ["%=", "&=", "*=", "**=", "+=", "-=", "/="];
9
- export declare const logicalAssignmentOperators: readonly ["&&=", "||="];
10
- export declare const bitwiseAssignmentOperators: readonly ["<<=", ">>=", ">>>=", "^=", "|="];
11
- export declare const assignmentOperators: readonly ["%=", "&=", "*=", "**=", "+=", "-=", "/=", "&&=", "||=", "<<=", ">>=", ">>>=", "^=", "|=", "="];
12
- export declare type AssignementOperator = typeof assignmentOperators[number];
13
- export declare const leftRightOperators: readonly ["*", "**", "+", "-", "/", "%", "!=", "!==", "<", "<=", "==", "===", ">", ">=", "&", "<<", ">>", ">>>", "^", "|", "instanceof", "in", "&&", "??", "||", "%=", "&=", "*=", "**=", "+=", "-=", "/=", "&&=", "||=", "<<=", ">>=", ">>>=", "^=", "|=", "="];
14
- export declare type LeftRightOperator = typeof leftRightOperators[number];
15
- export declare const unaryOperators: readonly ["!", "u+", "u-", "delete", "typeof", "void", "~"];
16
- export declare type UnaryOperator = typeof unaryOperators[number];
17
- export declare const updateOperators: readonly ["++", "--"];
18
- export declare type UpdateOperator = typeof updateOperators[number];
19
- export declare const singleOperators: readonly ["!", "u+", "u-", "delete", "typeof", "void", "~", "++", "--"];
20
- export declare type SingleOperator = typeof singleOperators[number];
21
- export declare const operators: readonly ["*", "**", "+", "-", "/", "%", "!=", "!==", "<", "<=", "==", "===", ">", ">=", "&", "<<", ">>", ">>>", "^", "|", "instanceof", "in", "&&", "??", "||", "%=", "&=", "*=", "**=", "+=", "-=", "/=", "&&=", "||=", "<<=", ">>=", ">>>=", "^=", "|=", "=", "!", "u+", "u-", "delete", "typeof", "void", "~", "++", "--"];
22
- export declare type Operator = typeof operators[number];
23
- export declare const operatorMap: {
24
- [k in BinaryOperator | LogicalOperator]?: string;
25
- };
1
+ export declare const arithmeticBinaryOperators: readonly ["*", "**", "+", "-", "/", "%"];
2
+ export declare const comparisonBinaryOperators: readonly ["!=", "!==", "<", "<=", "==", "===", ">", ">="];
3
+ export declare const bitwiseBinaryOperators: readonly ["&", "<<", ">>", ">>>", "^", "|"];
4
+ export declare const binaryOperators: readonly ["*", "**", "+", "-", "/", "%", "!=", "!==", "<", "<=", "==", "===", ">", ">=", "&", "<<", ">>", ">>>", "^", "|", "instanceof", "in"];
5
+ export declare type BinaryOperator = typeof binaryOperators[number];
6
+ export declare const logicalOperators: readonly ["&&", "??", "||"];
7
+ export declare type LogicalOperator = typeof logicalOperators[number];
8
+ export declare const arithmeticAssignmentOperators: readonly ["%=", "&=", "*=", "**=", "+=", "-=", "/="];
9
+ export declare const logicalAssignmentOperators: readonly ["&&=", "||="];
10
+ export declare const bitwiseAssignmentOperators: readonly ["<<=", ">>=", ">>>=", "^=", "|="];
11
+ export declare const assignmentOperators: readonly ["%=", "&=", "*=", "**=", "+=", "-=", "/=", "&&=", "||=", "<<=", ">>=", ">>>=", "^=", "|=", "="];
12
+ export declare type AssignementOperator = typeof assignmentOperators[number];
13
+ export declare const leftRightOperators: readonly ["*", "**", "+", "-", "/", "%", "!=", "!==", "<", "<=", "==", "===", ">", ">=", "&", "<<", ">>", ">>>", "^", "|", "instanceof", "in", "&&", "??", "||", "%=", "&=", "*=", "**=", "+=", "-=", "/=", "&&=", "||=", "<<=", ">>=", ">>>=", "^=", "|=", "="];
14
+ export declare type LeftRightOperator = typeof leftRightOperators[number];
15
+ export declare const unaryOperators: readonly ["!", "u+", "u-", "delete", "typeof", "void", "~"];
16
+ export declare type UnaryOperator = typeof unaryOperators[number];
17
+ export declare const updateOperators: readonly ["++", "--"];
18
+ export declare type UpdateOperator = typeof updateOperators[number];
19
+ export declare const singleOperators: readonly ["!", "u+", "u-", "delete", "typeof", "void", "~", "++", "--"];
20
+ export declare type SingleOperator = typeof singleOperators[number];
21
+ export declare const operators: readonly ["*", "**", "+", "-", "/", "%", "!=", "!==", "<", "<=", "==", "===", ">", ">=", "&", "<<", ">>", ">>>", "^", "|", "instanceof", "in", "&&", "??", "||", "%=", "&=", "*=", "**=", "+=", "-=", "/=", "&&=", "||=", "<<=", ">>=", ">>>=", "^=", "|=", "=", "!", "u+", "u-", "delete", "typeof", "void", "~", "++", "--"];
22
+ export declare type Operator = typeof operators[number];
23
+ export declare const operatorMap: {
24
+ [k in Exclude<BinaryOperator, "instanceof" | "in"> | Extract<LogicalOperator, "&&" | "||">]: string;
25
+ };
@@ -0,0 +1,100 @@
1
+ export * as es from "estree";
2
+ import { Compiler } from "./Compiler";
3
+ import { AddressResolver } from "./instructions";
4
+ import { MacroFunction } from "./macros";
5
+ import { LeftRightOperator, UnaryOperator, UpdateOperator } from "./operators";
6
+ import { StoreValue } from "./values";
7
+ export interface IInstruction {
8
+ hidden: boolean;
9
+ resolve(i: number): void;
10
+ }
11
+ export declare type THandler<T extends IValue | null = IValue> = (compiler: Compiler, scope: IScope, node: any, arg: any) => TValueInstructions<T>;
12
+ export interface IScope {
13
+ parent: IScope | null;
14
+ data: {};
15
+ name: string;
16
+ inst: IInstruction[];
17
+ break: AddressResolver;
18
+ continue: AddressResolver;
19
+ function: IFunctionValue;
20
+ ntemp: number;
21
+ createScope(): IScope;
22
+ createFunction(name: string, stacked?: boolean): IScope;
23
+ has(name: string): boolean;
24
+ get(name: string): IValue;
25
+ set<T extends IValue>(name: string, value: T): T;
26
+ hardSet<T extends IValue>(name: string, value: T): T;
27
+ make(name: string, storeName: string): StoreValue;
28
+ copy(): IScope;
29
+ }
30
+ export interface IValue {
31
+ scope: IScope;
32
+ constant: boolean;
33
+ macro: boolean;
34
+ eval(scope: IScope): TValueInstructions;
35
+ call(scope: IScope, args: IValue[]): TValueInstructions<IValue | null>;
36
+ get(scope: IScope, name: IValue): TValueInstructions;
37
+ "!"(scope: IScope): TValueInstructions;
38
+ "u+"(scope: IScope): TValueInstructions;
39
+ "u-"(scope: IScope): TValueInstructions;
40
+ "delete"(scope: IScope): TValueInstructions;
41
+ "typeof"(scope: IScope): TValueInstructions;
42
+ "void"(scope: IScope): TValueInstructions;
43
+ "~"(scope: IScope): TValueInstructions;
44
+ "++"(scope: IScope, prefix: boolean): TValueInstructions;
45
+ "--"(scope: IScope, prefix: boolean): TValueInstructions;
46
+ "*"(scope: IScope, value: IValue): TValueInstructions;
47
+ "**"(scope: IScope, value: IValue): TValueInstructions;
48
+ "+"(scope: IScope, value: IValue): TValueInstructions;
49
+ "-"(scope: IScope, value: IValue): TValueInstructions;
50
+ "/"(scope: IScope, value: IValue): TValueInstructions;
51
+ "%"(scope: IScope, value: IValue): TValueInstructions;
52
+ "!="(scope: IScope, value: IValue): TValueInstructions;
53
+ "!=="(scope: IScope, value: IValue): TValueInstructions;
54
+ "<"(scope: IScope, value: IValue): TValueInstructions;
55
+ "<="(scope: IScope, value: IValue): TValueInstructions;
56
+ "=="(scope: IScope, value: IValue): TValueInstructions;
57
+ "==="(scope: IScope, value: IValue): TValueInstructions;
58
+ ">"(scope: IScope, value: IValue): TValueInstructions;
59
+ ">="(scope: IScope, value: IValue): TValueInstructions;
60
+ "&"(scope: IScope, value: IValue): TValueInstructions;
61
+ "<<"(scope: IScope, value: IValue): TValueInstructions;
62
+ ">>"(scope: IScope, value: IValue): TValueInstructions;
63
+ ">>>"(scope: IScope, value: IValue): TValueInstructions;
64
+ "^"(scope: IScope, value: IValue): TValueInstructions;
65
+ "|"(scope: IScope, value: IValue): TValueInstructions;
66
+ instanceof(scope: IScope, value: IValue): TValueInstructions;
67
+ in(scope: IScope, value: IValue): TValueInstructions;
68
+ "&&"(scope: IScope, value: IValue): TValueInstructions;
69
+ "??"(scope: IScope, value: IValue): TValueInstructions;
70
+ "||"(scope: IScope, value: IValue): TValueInstructions;
71
+ "%="(scope: IScope, value: IValue): TValueInstructions;
72
+ "&="(scope: IScope, value: IValue): TValueInstructions;
73
+ "*="(scope: IScope, value: IValue): TValueInstructions;
74
+ "**="(scope: IScope, value: IValue): TValueInstructions;
75
+ "+="(scope: IScope, value: IValue): TValueInstructions;
76
+ "-="(scope: IScope, value: IValue): TValueInstructions;
77
+ "/="(scope: IScope, value: IValue): TValueInstructions;
78
+ "&&="(scope: IScope, value: IValue): TValueInstructions;
79
+ "||="(scope: IScope, value: IValue): TValueInstructions;
80
+ "<<="(scope: IScope, value: IValue): TValueInstructions;
81
+ ">>="(scope: IScope, value: IValue): TValueInstructions;
82
+ ">>>="(scope: IScope, value: IValue): TValueInstructions;
83
+ "^="(scope: IScope, value: IValue): TValueInstructions;
84
+ "|="(scope: IScope, value: IValue): TValueInstructions;
85
+ "="(scope: IScope, value: IValue): TValueInstructions;
86
+ }
87
+ export declare type TLiteral = string | number;
88
+ export interface IBindableValue extends IValue {
89
+ data: TLiteral;
90
+ }
91
+ export interface IFunctionValue extends IValue {
92
+ return(scope: IScope, argument: IValue): TValueInstructions<IValue | null>;
93
+ }
94
+ export declare type TValueInstructions<Content extends IValue | null = IValue> = [
95
+ Content,
96
+ IInstruction[]
97
+ ];
98
+ export declare type TOperatorMacroMap = {
99
+ [K in UnaryOperator | UpdateOperator | LeftRightOperator as `$${K}`]?: MacroFunction;
100
+ };
@@ -1,3 +1,3 @@
1
- import { es } from "./types";
2
- export declare function nodeName(node: es.Node): string;
3
- export declare function camelToDashCase(name: string): string;
1
+ import { es } from "./types";
2
+ export declare function nodeName(node: es.Node): string;
3
+ export declare function camelToDashCase(name: string): string;
@@ -1,5 +1,5 @@
1
- import { IScope, IValue, TValueInstructions } from "../types";
2
- import { VoidValue } from ".";
3
- export declare class BaseValue extends VoidValue implements IValue {
4
- "u-"(scope: IScope): TValueInstructions;
5
- }
1
+ import { IScope, IValue, TValueInstructions } from "../types";
2
+ import { VoidValue } from ".";
3
+ export declare class BaseValue extends VoidValue implements IValue {
4
+ "u-"(scope: IScope): TValueInstructions;
5
+ }
@@ -1,34 +1,34 @@
1
- import { Compiler } from "../Compiler";
2
- import { es, IFunctionValue, IScope, IValue, TValueInstructions } from "../types";
3
- import { StoreValue } from "./StoreValue";
4
- import { VoidValue } from "./VoidValue";
5
- export declare class FunctionValue extends VoidValue implements IFunctionValue {
6
- constant: boolean;
7
- macro: boolean;
8
- private paramStores;
9
- private paramNames;
10
- private inst;
11
- private addr;
12
- private temp;
13
- private ret;
14
- private inline;
15
- private tryingInline;
16
- private body;
17
- private name;
18
- private c;
19
- private callSize;
20
- private inlineTemp;
21
- private inlineEnd;
22
- private bundled;
23
- private createValues;
24
- typeof(scope: IScope): TValueInstructions;
25
- private createInst;
26
- constructor(scope: IScope, name: string, paramNames: string[], paramStores: StoreValue[], body: es.BlockStatement, c: Compiler);
27
- private normalReturn;
28
- private normalCall;
29
- private inlineReturn;
30
- private inlineCall;
31
- call(scope: IScope, args: IValue[]): TValueInstructions;
32
- return(scope: IScope, arg: IValue): TValueInstructions;
33
- eval(scope: IScope): TValueInstructions;
34
- }
1
+ import { Compiler } from "../Compiler";
2
+ import { es, IFunctionValue, IScope, IValue, TValueInstructions } from "../types";
3
+ import { StoreValue } from "./StoreValue";
4
+ import { VoidValue } from "./VoidValue";
5
+ export declare class FunctionValue extends VoidValue implements IFunctionValue {
6
+ constant: boolean;
7
+ macro: boolean;
8
+ private paramStores;
9
+ private paramNames;
10
+ private inst;
11
+ private addr;
12
+ private temp;
13
+ private ret;
14
+ private inline;
15
+ private tryingInline;
16
+ private body;
17
+ private name;
18
+ private c;
19
+ private callSize;
20
+ private inlineTemp;
21
+ private inlineEnd;
22
+ private bundled;
23
+ private createValues;
24
+ typeof(scope: IScope): TValueInstructions;
25
+ private createInst;
26
+ constructor(scope: IScope, name: string, paramNames: string[], paramStores: StoreValue[], body: es.BlockStatement, c: Compiler);
27
+ private normalReturn;
28
+ private normalCall;
29
+ private inlineReturn;
30
+ private inlineCall;
31
+ call(scope: IScope, args: IValue[]): TValueInstructions;
32
+ return(scope: IScope, arg: IValue): TValueInstructions<IValue | null>;
33
+ eval(scope: IScope): TValueInstructions;
34
+ }
@@ -1,12 +1,12 @@
1
- import { IScope, IBindableValue, TLiteral, TValueInstructions, IValue } from "../types";
2
- import { BaseValue } from ".";
3
- export declare class LiteralValue extends BaseValue implements IBindableValue {
4
- data: TLiteral;
5
- constant: boolean;
6
- constructor(scope: IScope, data: TLiteral);
7
- eval(scope: IScope): TValueInstructions;
8
- toString(): string;
9
- get(scope: IScope, name: IValue): TValueInstructions;
10
- get num(): number;
11
- typeof(scope: IScope): TValueInstructions;
12
- }
1
+ import { IScope, IBindableValue, TLiteral, TValueInstructions, IValue } from "../types";
2
+ import { BaseValue } from ".";
3
+ export declare class LiteralValue extends BaseValue implements IBindableValue {
4
+ data: TLiteral;
5
+ constant: boolean;
6
+ constructor(scope: IScope, data: TLiteral);
7
+ eval(scope: IScope): TValueInstructions;
8
+ toString(): string;
9
+ get(scope: IScope, name: IValue): TValueInstructions;
10
+ get num(): number;
11
+ typeof(scope: IScope): TValueInstructions;
12
+ }
@@ -0,0 +1,19 @@
1
+ import { MacroFunction } from "../macros";
2
+ import { IScope, IValue, TOperatorMacroMap, TValueInstructions } from "../types";
3
+ import { LiteralValue } from "./LiteralValue";
4
+ import { VoidValue } from "./VoidValue";
5
+ export interface IObjectValueData extends TOperatorMacroMap {
6
+ [k: string]: IValue | undefined;
7
+ $get?: MacroFunction<IValue>;
8
+ $eval?: MacroFunction<IValue>;
9
+ }
10
+ export declare class ObjectValue extends VoidValue {
11
+ constant: boolean;
12
+ macro: boolean;
13
+ data: IObjectValueData;
14
+ constructor(scope: IScope, data?: IObjectValueData);
15
+ typeof(scope: IScope): TValueInstructions;
16
+ get(scope: IScope, key: LiteralValue): TValueInstructions;
17
+ eval(scope: IScope): TValueInstructions;
18
+ call(scope: IScope, args: IValue[]): TValueInstructions<IValue | null>;
19
+ }
@@ -1,11 +1,11 @@
1
- import { BaseValue } from ".";
2
- import { IScope, IValue, TValueInstructions } from "../types";
3
- export declare class StoreValue extends BaseValue implements IValue {
4
- name: string;
5
- constant: boolean;
6
- constructor(scope: IScope, name: string);
7
- typeof(scope: IScope): TValueInstructions;
8
- "="(scope: IScope, value: IValue): TValueInstructions;
9
- eval(scope: IScope): TValueInstructions;
10
- toString(): string;
11
- }
1
+ import { BaseValue } from ".";
2
+ import { IScope, IValue, TValueInstructions } from "../types";
3
+ export declare class StoreValue extends BaseValue implements IValue {
4
+ name: string;
5
+ constant: boolean;
6
+ constructor(scope: IScope, name: string);
7
+ typeof(scope: IScope): TValueInstructions;
8
+ "="(scope: IScope, value: IValue): TValueInstructions;
9
+ eval(scope: IScope): TValueInstructions;
10
+ toString(): string;
11
+ }
@@ -1,12 +1,12 @@
1
- import { IInstruction, IScope, IValue, TValueInstructions } from "../types";
2
- import { StoreValue } from "./";
3
- export declare class TempValue extends StoreValue {
4
- proxied: IValue;
5
- canProxy: boolean;
6
- setInst: IInstruction;
7
- constructor(scope: IScope, name?: string);
8
- eval(scope: IScope): TValueInstructions;
9
- "="(scope: IScope, value: IValue): TValueInstructions;
10
- proxy(value: IValue): TValueInstructions;
11
- noProxy(): void;
12
- }
1
+ import { IInstruction, IScope, IValue, TValueInstructions } from "../types";
2
+ import { StoreValue } from "./";
3
+ export declare class TempValue extends StoreValue {
4
+ proxied: IValue;
5
+ canProxy: boolean;
6
+ setInst: IInstruction;
7
+ constructor(scope: IScope, name?: string);
8
+ eval(scope: IScope): TValueInstructions;
9
+ "="(scope: IScope, value: IValue): TValueInstructions;
10
+ proxy(value: IValue): TValueInstructions;
11
+ noProxy(): void;
12
+ }
@@ -1,11 +1,13 @@
1
- import { IScope, IValue, TValueInstructions } from "../types";
2
- export declare class VoidValue implements IValue {
3
- scope: IScope;
4
- constant: boolean;
5
- macro: boolean;
6
- constructor(scope: IScope);
7
- eval(scope: IScope): TValueInstructions;
8
- call(scope: IScope, args: IValue[]): TValueInstructions;
9
- get(scope: IScope, name: IValue): TValueInstructions;
10
- toString(): string;
11
- }
1
+ import { IScope, IValue, TValueInstructions } from "../types";
2
+ export declare class VoidValue implements IValue {
3
+ scope: IScope;
4
+ constant: boolean;
5
+ macro: boolean;
6
+ constructor(scope: IScope);
7
+ eval(scope: IScope): TValueInstructions;
8
+ call(scope: IScope, args: IValue[]): TValueInstructions<IValue | null>;
9
+ get(scope: IScope, name: IValue): TValueInstructions;
10
+ toString(): string;
11
+ }
12
+ export interface VoidValue extends IValue {
13
+ }
@@ -1,6 +1,6 @@
1
- export * from "./VoidValue";
2
- export * from "./BaseValue";
3
- export * from "./LiteralValue";
4
- export * from "./StoreValue";
5
- export * from "./TempValue";
6
- export * from "./ObjectValue";
1
+ export * from "./VoidValue";
2
+ export * from "./BaseValue";
3
+ export * from "./LiteralValue";
4
+ export * from "./StoreValue";
5
+ export * from "./TempValue";
6
+ export * from "./ObjectValue";
package/doc/README.md ADDED
@@ -0,0 +1,9 @@
1
+ # MlogJS
2
+
3
+ MlogJS is a compiler that allows users to compile complex JavaScript programs into Mindustry Logic Code.
4
+
5
+ ## Discord
6
+
7
+ You can join the Discord server for more information and for help.
8
+
9
+ <iframe src="https://discord.com/widget?id=841105039211888710&theme=dark" width="350" height="300" allowtransparency="true" frameborder="0" sandbox="allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts"></iframe>
@@ -120,7 +120,7 @@ interface Math {
120
120
  sqrt(x: number): number;
121
121
 
122
122
  /**
123
- * Returns a random floating point number from 0 to `range` (excluding `range` istself)
123
+ * Returns a random floating point number from 0 to `range` (excluding `range` itself)
124
124
  * @param range
125
125
  */
126
126
  rand(range: number): number;
package/lib/traits.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import "./globals";
2
- import "./custom-lib";
3
2
 
4
3
  type LogicSymbols = typeof Items & typeof Liquids & typeof LAccess;
5
4
 
package/package.json CHANGED
@@ -1,28 +1,24 @@
1
1
  {
2
2
  "name": "mlogjs",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Compiler that compiles Javascript to Mindustry Logic Code.",
5
- "main": "build/index.js",
6
- "bin": "./build/bin.js",
5
+ "main": "./dist/index.cjs",
6
+ "module": "./dist/index.mjs",
7
+ "bin": "./dist/index.cjs",
8
+ "types": "./dist/types",
7
9
  "scripts": {
8
- "clean": "rm -rf docs dist build",
9
- "build": "tsc && vite build",
10
- "build:editor": "cd editor && vite build",
10
+ "clean": "rm -rf ../docs dist build",
11
+ "build": "rollup -c",
11
12
  "dev": "ts-node src/bin",
12
- "dev:editor": "cd editor && vite",
13
13
  "test": "jest",
14
14
  "coverage": "jest --coverage",
15
- "docs:doc": "mkdir -p docs && cp -r doc/. docs",
16
- "docs:lib": "typedoc --out docs/lib lib/*",
17
- "docs:src": "typedoc --out docs/src src/index.ts",
15
+ "docs:doc": "mkdir -p ../docs && cp -r doc/. ../docs",
16
+ "docs:lib": "typedoc --out ../docs/lib lib/*",
17
+ "docs:src": "typedoc --out ../docs/src src/index.ts",
18
18
  "docs": "run-p docs:lib docs:src docs:doc",
19
19
  "start": "npm run build && npm i -g . && mlogjs",
20
20
  "prepublishOnly": "npm run build"
21
21
  },
22
- "exports": {
23
- "require": "./build/index.js",
24
- "import": "./dist/index.js"
25
- },
26
22
  "repository": {
27
23
  "type": "git",
28
24
  "url": "git+https://github.com/weisrc/mlogjs.git"
@@ -41,27 +37,21 @@
41
37
  "yargs": "^17.0.1"
42
38
  },
43
39
  "devDependencies": {
44
- "@monaco-editor/react": "^4.3.1",
40
+ "@rollup/plugin-alias": "^3.1.9",
41
+ "@rollup/plugin-replace": "^4.0.0",
42
+ "@rollup/plugin-typescript": "^8.3.1",
45
43
  "@types/estree": "^0.0.51",
46
44
  "@types/jest": "^27.4.1",
47
45
  "@types/node": "^15.3.0",
48
- "@types/react": "^17.0.39",
49
- "@types/react-dom": "^17.0.13",
50
- "@types/react-split-pane": "^0.1.67",
51
46
  "@types/yargs": "^16.0.1",
52
- "@vitejs/plugin-react": "^1.2.0",
53
47
  "jest": "^27.5.1",
54
- "monaco-editor": "^0.32.1",
55
48
  "npm-run-all": "^4.1.5",
56
- "prettier": "^2.5.1",
57
- "react": "^17.0.2",
58
- "react-dom": "^17.0.2",
59
- "react-split-pane": "^0.1.92",
49
+ "rollup": "^2.70.1",
60
50
  "ts-jest": "^27.1.3",
61
51
  "ts-node": "^10.6.0",
52
+ "tslib": "^2.3.1",
62
53
  "typedoc": "^0.22.12",
63
- "typescript": "^4.6.2",
64
- "vite": "^2.8.6"
54
+ "typescript": "*"
65
55
  },
66
56
  "files": [
67
57
  "build",
@@ -70,4 +60,4 @@
70
60
  "LICENSE",
71
61
  "README.md"
72
62
  ]
73
- }
63
+ }
@@ -1,18 +0,0 @@
1
- import { es, IScope, THandler, TValueInstructions } from "./types";
2
- declare type THandlerMap = {
3
- [k in es.Node["type"]]?: THandler;
4
- };
5
- export declare class Compiler {
6
- protected stackName?: string;
7
- protected usingStack: boolean;
8
- protected handlers: THandlerMap;
9
- constructor(stackName?: string);
10
- compile(script: string): [string, Error, es.Node[]];
11
- protected resolve(valueInst: TValueInstructions): void;
12
- protected serialize(resLines: TValueInstructions): string;
13
- protected parse(script: string): es.Node;
14
- handle(scope: IScope, node: es.Node): TValueInstructions;
15
- handleEval(scope: IScope, node: es.Node): TValueInstructions;
16
- handleMany(scope: IScope, nodes: es.Node[], handler?: typeof Compiler.prototype.handle): TValueInstructions;
17
- }
18
- export {};