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.
Files changed (234) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +2 -2
  3. package/build/Compiler.js +104 -99
  4. package/build/Compiler.js.map +1 -1
  5. package/build/CompilerError.js +11 -0
  6. package/build/CompilerError.js.map +1 -0
  7. package/build/Scope.js +70 -60
  8. package/build/Scope.js.map +1 -1
  9. package/build/bin.js +74 -60
  10. package/build/bin.js.map +1 -1
  11. package/build/handlers/BlockStatement.js +13 -13
  12. package/build/handlers/BlockStatement.js.map +1 -1
  13. package/build/handlers/CallExpression.js +19 -19
  14. package/build/handlers/CallExpression.js.map +1 -1
  15. package/build/handlers/File.js +9 -0
  16. package/build/handlers/File.js.map +1 -0
  17. package/build/handlers/ForStatement.js +31 -31
  18. package/build/handlers/ForStatement.js.map +1 -1
  19. package/build/handlers/Function.js +46 -35
  20. package/build/handlers/Function.js.map +1 -1
  21. package/build/handlers/Identifier.js +7 -7
  22. package/build/handlers/IfStatement.js +24 -24
  23. package/build/handlers/IfStatement.js.map +1 -1
  24. package/build/handlers/Literal.js +14 -17
  25. package/build/handlers/Literal.js.map +1 -1
  26. package/build/handlers/Object.js +54 -43
  27. package/build/handlers/Object.js.map +1 -1
  28. package/build/handlers/OperationExpressions.js +37 -32
  29. package/build/handlers/OperationExpressions.js.map +1 -1
  30. package/build/handlers/Program.js +8 -8
  31. package/build/handlers/Program.js.map +1 -1
  32. package/build/handlers/Statements.js +29 -29
  33. package/build/handlers/Statements.js.map +1 -1
  34. package/build/handlers/TemplateExpression.js +17 -17
  35. package/build/handlers/TemplateExpression.js.map +1 -1
  36. package/build/handlers/VariableDeclaration.js +71 -55
  37. package/build/handlers/VariableDeclaration.js.map +1 -1
  38. package/build/handlers/WhileStatement.js +22 -22
  39. package/build/handlers/WhileStatement.js.map +1 -1
  40. package/build/handlers/index.js +31 -30
  41. package/build/handlers/index.js.map +1 -1
  42. package/build/index.js +7 -7
  43. package/build/index.js.map +1 -1
  44. package/build/initScope.js +39 -39
  45. package/build/instructions/AddressResolver.js +30 -30
  46. package/build/instructions/ControlInstructions.js +22 -22
  47. package/build/instructions/EndInstruction.js +10 -10
  48. package/build/instructions/InstructionBase.js +20 -20
  49. package/build/instructions/InstructionBase.js.map +1 -1
  50. package/build/instructions/JumpInstruction.js +21 -21
  51. package/build/instructions/JumpInstruction.js.map +1 -1
  52. package/build/instructions/OperationInstruction.js +10 -10
  53. package/build/instructions/OperationInstruction.js.map +1 -1
  54. package/build/instructions/SetCounterInstruction.js +10 -10
  55. package/build/instructions/SetInstruction.js +10 -10
  56. package/build/instructions/ZeroSpaceInstruction.js +10 -10
  57. package/build/instructions/index.js +25 -25
  58. package/build/macros/Building.js +88 -80
  59. package/build/macros/Building.js.map +1 -1
  60. package/build/macros/Function.js +19 -19
  61. package/build/macros/Function.js.map +1 -1
  62. package/build/macros/Math.js +61 -56
  63. package/build/macros/Math.js.map +1 -1
  64. package/build/macros/Memory.js +62 -60
  65. package/build/macros/Memory.js.map +1 -1
  66. package/build/macros/Namespace.js +110 -97
  67. package/build/macros/Namespace.js.map +1 -1
  68. package/build/macros/Other.js +20 -19
  69. package/build/macros/Other.js.map +1 -1
  70. package/build/macros/RawValue.js +16 -15
  71. package/build/macros/RawValue.js.map +1 -1
  72. package/build/macros/commands/Control.js +25 -24
  73. package/build/macros/commands/Control.js.map +1 -1
  74. package/build/macros/commands/Draw.js +39 -38
  75. package/build/macros/commands/Draw.js.map +1 -1
  76. package/build/macros/commands/DrawFlush.js +17 -16
  77. package/build/macros/commands/DrawFlush.js.map +1 -1
  78. package/build/macros/commands/GetLink.js +24 -20
  79. package/build/macros/commands/GetLink.js.map +1 -1
  80. package/build/macros/commands/Lookup.js +24 -23
  81. package/build/macros/commands/Lookup.js.map +1 -1
  82. package/build/macros/commands/Print.js +17 -13
  83. package/build/macros/commands/Print.js.map +1 -1
  84. package/build/macros/commands/PrintFlush.js +17 -16
  85. package/build/macros/commands/PrintFlush.js.map +1 -1
  86. package/build/macros/commands/Radar.js +64 -60
  87. package/build/macros/commands/Radar.js.map +1 -1
  88. package/build/macros/commands/Sensor.js +20 -19
  89. package/build/macros/commands/Sensor.js.map +1 -1
  90. package/build/macros/commands/UnitBind.js +17 -16
  91. package/build/macros/commands/UnitBind.js.map +1 -1
  92. package/build/macros/commands/UnitControl.js +72 -67
  93. package/build/macros/commands/UnitControl.js.map +1 -1
  94. package/build/macros/commands/UnitLocate.js +75 -54
  95. package/build/macros/commands/UnitLocate.js.map +1 -1
  96. package/build/macros/commands/UnitRadar.js +47 -40
  97. package/build/macros/commands/UnitRadar.js.map +1 -1
  98. package/build/macros/commands/Wait.js +18 -17
  99. package/build/macros/commands/Wait.js.map +1 -1
  100. package/build/macros/commands/index.js +32 -32
  101. package/build/macros/index.js +39 -39
  102. package/build/operators.js +101 -101
  103. package/build/operators.js.map +1 -1
  104. package/build/types.js +27 -27
  105. package/build/types.js.map +1 -1
  106. package/build/utils.js +17 -12
  107. package/build/utils.js.map +1 -1
  108. package/build/values/BaseValue.js +111 -111
  109. package/build/values/BaseValue.js.map +1 -1
  110. package/build/values/FunctionValue.js +115 -103
  111. package/build/values/FunctionValue.js.map +1 -1
  112. package/build/values/LiteralValue.js +88 -87
  113. package/build/values/LiteralValue.js.map +1 -1
  114. package/build/values/ObjectValue.js +54 -49
  115. package/build/values/ObjectValue.js.map +1 -1
  116. package/build/values/StoreValue.js +31 -30
  117. package/build/values/StoreValue.js.map +1 -1
  118. package/build/values/TempValue.js +77 -66
  119. package/build/values/TempValue.js.map +1 -1
  120. package/build/values/VoidValue.js +31 -30
  121. package/build/values/VoidValue.js.map +1 -1
  122. package/build/values/index.js +22 -22
  123. package/dist/bin.cjs +82 -0
  124. package/dist/bin.cjs.map +1 -0
  125. package/dist/index.cjs +2220 -0
  126. package/dist/index.cjs.map +1 -0
  127. package/dist/index.mjs +2195 -0
  128. package/dist/index.mjs.map +1 -0
  129. package/dist/types/Compiler.d.ts +26 -0
  130. package/dist/types/CompilerError.d.ts +9 -0
  131. package/dist/types/Scope.d.ts +24 -0
  132. package/dist/types/bin.d.ts +1 -0
  133. package/dist/types/handlers/BlockStatement.d.ts +2 -0
  134. package/dist/types/handlers/CallExpression.d.ts +3 -0
  135. package/dist/types/handlers/File.d.ts +2 -0
  136. package/dist/types/handlers/ForStatement.d.ts +2 -0
  137. package/{build → dist/types}/handlers/Function.d.ts +5 -4
  138. package/{build → dist/types}/handlers/Identifier.d.ts +2 -2
  139. package/dist/types/handlers/IfStatement.d.ts +2 -0
  140. package/dist/types/handlers/Literal.d.ts +5 -0
  141. package/{build → dist/types}/handlers/Object.d.ts +6 -4
  142. package/{build → dist/types}/handlers/OperationExpressions.d.ts +8 -7
  143. package/dist/types/handlers/Program.d.ts +2 -0
  144. package/dist/types/handlers/Statements.d.ts +5 -0
  145. package/dist/types/handlers/TemplateExpression.d.ts +2 -0
  146. package/dist/types/handlers/Typescript.d.ts +7 -0
  147. package/dist/types/handlers/VariableDeclaration.d.ts +3 -0
  148. package/dist/types/handlers/WhileStatement.d.ts +3 -0
  149. package/{build → dist/types}/handlers/index.d.ts +16 -14
  150. package/dist/types/index.d.ts +2 -0
  151. package/{build → dist/types}/initScope.d.ts +5 -2
  152. package/{build → dist/types}/instructions/AddressResolver.d.ts +12 -12
  153. package/{build → dist/types}/instructions/ControlInstructions.d.ts +8 -11
  154. package/{build → dist/types}/instructions/EndInstruction.d.ts +4 -4
  155. package/{build → dist/types}/instructions/InstructionBase.d.ts +10 -10
  156. package/{build → dist/types}/instructions/JumpInstruction.d.ts +15 -15
  157. package/{build → dist/types}/instructions/OperationInstruction.d.ts +5 -5
  158. package/{build → dist/types}/instructions/SetCounterInstruction.d.ts +5 -5
  159. package/{build → dist/types}/instructions/SetInstruction.d.ts +6 -5
  160. package/{build → dist/types}/instructions/ZeroSpaceInstruction.d.ts +4 -4
  161. package/{build → dist/types}/instructions/index.d.ts +9 -9
  162. package/{build → dist/types}/macros/Building.d.ts +10 -11
  163. package/dist/types/macros/Entities.d.ts +11 -0
  164. package/dist/types/macros/Function.d.ts +13 -0
  165. package/dist/types/macros/GetGlobal.d.ts +5 -0
  166. package/{build → dist/types}/macros/Math.d.ts +5 -5
  167. package/{build → dist/types}/macros/Memory.d.ts +5 -5
  168. package/{build → dist/types}/macros/Namespace.d.ts +16 -21
  169. package/{build → dist/types}/macros/Other.d.ts +5 -5
  170. package/{build → dist/types}/macros/RawValue.d.ts +5 -5
  171. package/{build → dist/types}/macros/commands/Control.d.ts +5 -5
  172. package/dist/types/macros/commands/Draw.d.ts +5 -0
  173. package/{build → dist/types}/macros/commands/DrawFlush.d.ts +5 -5
  174. package/{build/macros/commands/Draw.d.ts → dist/types/macros/commands/End.d.ts} +5 -5
  175. package/{build → dist/types}/macros/commands/GetLink.d.ts +5 -5
  176. package/{build → dist/types}/macros/commands/Lookup.d.ts +5 -5
  177. package/{build → dist/types}/macros/commands/Print.d.ts +5 -5
  178. package/{build → dist/types}/macros/commands/PrintFlush.d.ts +5 -5
  179. package/{build → dist/types}/macros/commands/Radar.d.ts +7 -7
  180. package/{build → dist/types}/macros/commands/Sensor.d.ts +5 -5
  181. package/{build → dist/types}/macros/commands/UnitBind.d.ts +5 -5
  182. package/dist/types/macros/commands/UnitControl.d.ts +5 -0
  183. package/{build → dist/types}/macros/commands/UnitLocate.d.ts +5 -5
  184. package/{build → dist/types}/macros/commands/UnitRadar.d.ts +5 -5
  185. package/{build → dist/types}/macros/commands/Wait.d.ts +5 -5
  186. package/{build → dist/types}/macros/commands/index.d.ts +15 -14
  187. package/{build → dist/types}/macros/index.d.ts +6 -7
  188. package/{build → dist/types}/operators.d.ts +25 -25
  189. package/dist/types/types.d.ts +224 -0
  190. package/dist/types/utils.d.ts +30 -0
  191. package/dist/types/values/BaseValue.d.ts +7 -0
  192. package/dist/types/values/DestructuringValue.d.ts +17 -0
  193. package/dist/types/values/FunctionValue.d.ts +47 -0
  194. package/{build → dist/types}/values/LiteralValue.d.ts +13 -12
  195. package/dist/types/values/ObjectValue.d.ts +23 -0
  196. package/dist/types/values/SenseableValue.d.ts +23 -0
  197. package/dist/types/values/StackValue.d.ts +16 -0
  198. package/dist/types/values/StoreValue.d.ts +15 -0
  199. package/{build → dist/types}/values/TempValue.d.ts +19 -12
  200. package/dist/types/values/ValueOwner.d.ts +27 -0
  201. package/dist/types/values/VoidValue.d.ts +16 -0
  202. package/{build → dist/types}/values/index.d.ts +7 -6
  203. package/lib/commands.d.ts +242 -36
  204. package/lib/eslib/lib.es5.d.ts +1 -1
  205. package/lib/globals.d.ts +172 -159
  206. package/lib/helpers.d.ts +2 -2
  207. package/lib/memory.d.ts +1 -1
  208. package/lib/traits.d.ts +130 -110
  209. package/package.json +33 -38
  210. package/build/Compiler.d.ts +0 -18
  211. package/build/Scope.d.ts +0 -26
  212. package/build/bin.d.ts +0 -2
  213. package/build/handlers/BlockStatement.d.ts +0 -2
  214. package/build/handlers/CallExpression.d.ts +0 -3
  215. package/build/handlers/ForStatement.d.ts +0 -2
  216. package/build/handlers/IfStatement.d.ts +0 -2
  217. package/build/handlers/Literal.d.ts +0 -2
  218. package/build/handlers/Program.d.ts +0 -2
  219. package/build/handlers/Statements.d.ts +0 -5
  220. package/build/handlers/TemplateExpression.d.ts +0 -2
  221. package/build/handlers/VariableDeclaration.d.ts +0 -3
  222. package/build/handlers/WhileStatement.d.ts +0 -2
  223. package/build/index.d.ts +0 -1
  224. package/build/macros/Function.d.ts +0 -12
  225. package/build/macros/commands/UnitControl.d.ts +0 -5
  226. package/build/types.d.ts +0 -49
  227. package/build/utils.d.ts +0 -3
  228. package/build/values/BaseValue.d.ts +0 -5
  229. package/build/values/FunctionValue.d.ts +0 -34
  230. package/build/values/ObjectValue.d.ts +0 -17
  231. package/build/values/StoreValue.d.ts +0 -11
  232. package/build/values/VoidValue.d.ts +0 -11
  233. package/dist/mlogjs.es.js +0 -6366
  234. package/dist/mlogjs.umd.js +0 -8
package/package.json CHANGED
@@ -1,33 +1,15 @@
1
1
  {
2
2
  "name": "mlogjs",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "Compiler that compiles Javascript to Mindustry Logic Code.",
5
- "main": "build/index.js",
6
- "bin": "./build/bin.js",
7
- "scripts": {
8
- "clean": "rm -rf docs dist build",
9
- "build": "tsc && vite build",
10
- "build:editor": "cd editor && vite build",
11
- "dev": "ts-node src/bin",
12
- "dev:editor": "cd editor && vite",
13
- "test": "jest",
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",
18
- "docs": "run-p docs:lib docs:src docs:doc",
19
- "start": "npm run build && npm i -g . && mlogjs",
20
- "prepublishOnly": "npm run build"
21
- },
22
- "exports": {
23
- "require": "./build/index.js",
24
- "import": "./dist/index.js"
25
- },
5
+ "main": "./dist/index.cjs",
6
+ "module": "./dist/index.mjs",
7
+ "bin": "./dist/bin.cjs",
8
+ "types": "./dist/types",
26
9
  "repository": {
27
10
  "type": "git",
28
11
  "url": "git+https://github.com/weisrc/mlogjs.git"
29
12
  },
30
- "packageManager": "yarn@3.2.0",
31
13
  "keywords": [],
32
14
  "author": "str1z",
33
15
  "license": "MIT",
@@ -36,32 +18,31 @@
36
18
  },
37
19
  "homepage": "https://github.com/weisrc/mlogjs#readme",
38
20
  "dependencies": {
39
- "acorn": "^8.7.0",
21
+ "@babel/parser": "^7.17.7",
22
+ "chalk": "^4.1.2",
40
23
  "cli-highlight": "^2.1.11",
41
24
  "yargs": "^17.0.1"
42
25
  },
43
26
  "devDependencies": {
44
- "@monaco-editor/react": "^4.3.1",
27
+ "@babel/types": "^7.17.0",
28
+ "@rollup/plugin-alias": "^3.1.9",
29
+ "@rollup/plugin-replace": "^4.0.0",
30
+ "@rollup/plugin-typescript": "^8.3.1",
45
31
  "@types/estree": "^0.0.51",
46
32
  "@types/jest": "^27.4.1",
47
33
  "@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
34
  "@types/yargs": "^16.0.1",
52
- "@vitejs/plugin-react": "^1.2.0",
35
+ "@typescript-eslint/eslint-plugin": "^5.15.0",
36
+ "@typescript-eslint/parser": "^5.15.0",
37
+ "eslint": "^8.11.0",
53
38
  "jest": "^27.5.1",
54
- "monaco-editor": "^0.32.1",
55
39
  "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",
40
+ "rollup": "^2.70.1",
60
41
  "ts-jest": "^27.1.3",
61
42
  "ts-node": "^10.6.0",
43
+ "tslib": "^2.3.1",
62
44
  "typedoc": "^0.22.12",
63
- "typescript": "^4.6.2",
64
- "vite": "^2.8.6"
45
+ "typescript": "*"
65
46
  },
66
47
  "files": [
67
48
  "build",
@@ -69,5 +50,19 @@
69
50
  "lib",
70
51
  "LICENSE",
71
52
  "README.md"
72
- ]
73
- }
53
+ ],
54
+ "scripts": {
55
+ "clean": "rm -rf ../docs dist build",
56
+ "build": "rollup -c",
57
+ "build:dev": "rollup -c --environment DEV",
58
+ "dev": "ts-node src/bin",
59
+ "test": "jest",
60
+ "lint": "eslint src/**/*.ts",
61
+ "coverage": "jest --coverage",
62
+ "docs:doc": "mkdir -p ../docs && cp -r doc/. ../docs",
63
+ "docs:lib": "typedoc --out ../docs/lib lib/*",
64
+ "docs:src": "typedoc --out ../docs/src src/index.ts",
65
+ "docs": "run-p docs:lib docs:src docs:doc",
66
+ "start": "npm run build && npm i -g . && mlogjs"
67
+ }
68
+ }
@@ -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 {};
package/build/Scope.d.ts DELETED
@@ -1,26 +0,0 @@
1
- import { AddressResolver } from "./instructions";
2
- import { IFunctionValue, IInstruction, IScope, IValue } from "./types";
3
- export declare class Scope implements IScope {
4
- parent: IScope;
5
- name: string;
6
- data: {
7
- [k: string]: IValue;
8
- };
9
- stacked: boolean;
10
- ntemp: number;
11
- inst: IInstruction[];
12
- break: AddressResolver;
13
- continue: AddressResolver;
14
- function: IFunctionValue;
15
- constructor(values: {
16
- [k: string]: IValue;
17
- }, parent?: IScope, stacked?: boolean, ntemp?: number, name?: string, inst?: any[]);
18
- copy(): IScope;
19
- createScope(): IScope;
20
- createFunction(name: string, stacked?: boolean): IScope;
21
- has(name: string): boolean;
22
- get(name: string): IValue;
23
- set(name: string, value: IValue): IValue;
24
- hardSet(name: string, value: IValue): IValue;
25
- make(name: string, storeName: string): IValue;
26
- }
package/build/bin.d.ts DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
@@ -1,2 +0,0 @@
1
- import { THandler } from "../types";
2
- export declare const BlockStatement: THandler;
@@ -1,3 +0,0 @@
1
- import { THandler } from "../types";
2
- export declare const CallExpression: THandler;
3
- export declare const NewExpression: THandler;
@@ -1,2 +0,0 @@
1
- import { THandler } from "../types";
2
- export declare const ForStatement: THandler;
@@ -1,2 +0,0 @@
1
- import { THandler } from "../types";
2
- export declare const IfStatement: THandler;
@@ -1,2 +0,0 @@
1
- import { THandler } from "../types";
2
- export declare const Literal: THandler;
@@ -1,2 +0,0 @@
1
- import { THandler } from "../types";
2
- export declare const Program: THandler;
@@ -1,5 +0,0 @@
1
- import { THandler } from "../types";
2
- export declare const ExpressionStatement: THandler;
3
- export declare const BreakStatement: THandler;
4
- export declare const ContinueStatement: THandler;
5
- export declare const ReturnStatement: THandler;
@@ -1,2 +0,0 @@
1
- import { THandler } from "../types";
2
- export declare const TemplateLiteral: THandler;
@@ -1,3 +0,0 @@
1
- import { THandler } from "../types";
2
- export declare const VariableDeclaration: THandler;
3
- export declare const VariableDeclarator: THandler;
@@ -1,2 +0,0 @@
1
- import { THandler } from "../types";
2
- export declare const WhileStatement: THandler;
package/build/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare const compile: (script: string) => [string, Error, import("estree").Node[]];
@@ -1,12 +0,0 @@
1
- import { IScope, IValue, TValueInstructions } from "../types";
2
- import { VoidValue } from "../values";
3
- declare type TFunction = (...args: IValue[]) => TValueInstructions;
4
- export declare class MacroFunction extends VoidValue {
5
- macro: boolean;
6
- constant: boolean;
7
- fn: TFunction;
8
- constructor(scope: IScope, fn: TFunction);
9
- call(scope: IScope, args: IValue[]): TValueInstructions;
10
- eval(scope: IScope): TValueInstructions;
11
- }
12
- export {};
@@ -1,5 +0,0 @@
1
- import { MacroFunction } from "..";
2
- import { IScope } from "../../types";
3
- export declare class UnitControl extends MacroFunction {
4
- constructor(scope: IScope);
5
- }
package/build/types.d.ts DELETED
@@ -1,49 +0,0 @@
1
- export * as es from "estree";
2
- import { Compiler } from "./Compiler";
3
- import { AddressResolver } from "./instructions";
4
- import { LeftRightOperator, UnaryOperator, UpdateOperator } from "./operators";
5
- export interface IInstruction {
6
- hidden: boolean;
7
- resolve(i: number): void;
8
- }
9
- export declare type THandler = (compiler: Compiler, scope: IScope, node: any, arg: any) => TValueInstructions;
10
- export interface IScope {
11
- parent: IScope;
12
- data: {};
13
- name: string;
14
- inst: IInstruction[];
15
- break: AddressResolver;
16
- continue: AddressResolver;
17
- function: IFunctionValue;
18
- ntemp: number;
19
- createScope(): IScope;
20
- createFunction(name: string, stacked?: boolean): IScope;
21
- has(name: string): boolean;
22
- get(name: string): IValue;
23
- set(name: string, value: IValue): IValue;
24
- hardSet(name: string, value: IValue): IValue;
25
- make(name: string, storeName: string): IValue;
26
- copy(): IScope;
27
- }
28
- export declare type IValue = {
29
- [k in UnaryOperator]?: (scope: IScope) => TValueInstructions;
30
- } & {
31
- [k in UpdateOperator]?: (scope: IScope, prefix: boolean) => TValueInstructions;
32
- } & {
33
- [k in LeftRightOperator]?: (scope: IScope, value: IValue) => TValueInstructions;
34
- } & {
35
- scope: IScope;
36
- constant: boolean;
37
- macro: boolean;
38
- eval(scope: IScope): TValueInstructions;
39
- call(scope: IScope, args: IValue[]): TValueInstructions;
40
- get(scope: IScope, name: IValue): TValueInstructions;
41
- };
42
- export declare type TLiteral = string | number;
43
- export interface IBindableValue extends IValue {
44
- data: TLiteral;
45
- }
46
- export interface IFunctionValue extends IValue {
47
- return(scope: IScope, argument: IValue): TValueInstructions;
48
- }
49
- export declare type TValueInstructions = [IValue, IInstruction[]];
package/build/utils.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import { es } from "./types";
2
- export declare function nodeName(node: es.Node): string;
3
- export declare function camelToDashCase(name: string): string;
@@ -1,5 +0,0 @@
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 +0,0 @@
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,17 +0,0 @@
1
- import { IScope, IValue, TValueInstructions } from "../types";
2
- import { LiteralValue } from "./LiteralValue";
3
- import { VoidValue } from "./VoidValue";
4
- export declare class ObjectValue extends VoidValue {
5
- constant: boolean;
6
- macro: boolean;
7
- data: {
8
- [k: string]: IValue;
9
- };
10
- constructor(scope: IScope, data?: {
11
- [k: string]: IValue;
12
- });
13
- typeof(scope: IScope): TValueInstructions;
14
- get(scope: IScope, key: LiteralValue): TValueInstructions;
15
- eval(scope: IScope): TValueInstructions;
16
- call(scope: IScope, args: IValue[]): TValueInstructions;
17
- }
@@ -1,11 +0,0 @@
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,11 +0,0 @@
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
- }