@bikky/replication 1.0.3 → 1.0.4

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 (76) hide show
  1. package/.idea/Replication.iml +12 -0
  2. package/.idea/compiler.xml +6 -0
  3. package/.idea/inspectionProfiles/Project_Default.xml +6 -0
  4. package/.idea/modules.xml +8 -0
  5. package/.idea/vcs.xml +3 -1
  6. package/Expressions/Compiler/Grammar/Accessors.d.ts +32 -0
  7. package/Expressions/Compiler/Grammar/Accessors.js +227 -0
  8. package/Expressions/Compiler/Grammar/Accessors.js.map +1 -0
  9. package/Expressions/Compiler/Grammar/ControlFlow.d.ts +38 -0
  10. package/Expressions/Compiler/Grammar/ControlFlow.js +178 -0
  11. package/Expressions/Compiler/Grammar/ControlFlow.js.map +1 -0
  12. package/Expressions/Compiler/Grammar/Declarations.d.ts +22 -0
  13. package/Expressions/Compiler/Grammar/Declarations.js +84 -0
  14. package/Expressions/Compiler/Grammar/Declarations.js.map +1 -0
  15. package/Expressions/Compiler/Grammar/Function.d.ts +30 -0
  16. package/Expressions/Compiler/Grammar/Function.js +292 -0
  17. package/Expressions/Compiler/Grammar/Function.js.map +1 -0
  18. package/Expressions/Compiler/Grammar/General.d.ts +55 -0
  19. package/Expressions/Compiler/Grammar/General.js +248 -0
  20. package/Expressions/Compiler/Grammar/General.js.map +1 -0
  21. package/Expressions/Compiler/Grammar/Maths.d.ts +26 -0
  22. package/Expressions/Compiler/Grammar/Maths.js +164 -0
  23. package/Expressions/Compiler/Grammar/Maths.js.map +1 -0
  24. package/Expressions/Compiler/Grammar/Misc.d.ts +20 -0
  25. package/Expressions/Compiler/Grammar/Misc.js +50 -0
  26. package/Expressions/Compiler/Grammar/Misc.js.map +1 -0
  27. package/Expressions/Compiler/Grammar/Preprocessors.d.ts +18 -0
  28. package/Expressions/Compiler/Grammar/Preprocessors.js +43 -0
  29. package/Expressions/Compiler/Grammar/Preprocessors.js.map +1 -0
  30. package/Expressions/Compiler/Grammar/Struct.d.ts +21 -0
  31. package/Expressions/Compiler/Grammar/Struct.js +42 -0
  32. package/Expressions/Compiler/Grammar/Struct.js.map +1 -0
  33. package/Expressions/Compiler/Grammar/Tokens.d.ts +7 -0
  34. package/Expressions/Compiler/Grammar/Tokens.js +270 -0
  35. package/Expressions/Compiler/Grammar/Tokens.js.map +1 -0
  36. package/Expressions/Compiler/Grammar/Types.d.ts +35 -0
  37. package/Expressions/Compiler/Grammar/Types.js +230 -0
  38. package/Expressions/Compiler/Grammar/Types.js.map +1 -0
  39. package/Expressions/Compiler/GrammarRegistry.d.ts +20 -0
  40. package/Expressions/Compiler/GrammarRegistry.js +51 -0
  41. package/Expressions/Compiler/GrammarRegistry.js.map +1 -0
  42. package/Expressions/Compiler/Parser/Checks.d.ts +8 -0
  43. package/Expressions/Compiler/Parser/Checks.js +40 -0
  44. package/Expressions/Compiler/Parser/Checks.js.map +1 -0
  45. package/Expressions/Compiler/Parser/Enums.d.ts +73 -0
  46. package/Expressions/Compiler/Parser/Enums.js +77 -0
  47. package/Expressions/Compiler/Parser/Enums.js.map +1 -0
  48. package/Expressions/Compiler/Parser/Interfaces.d.ts +118 -0
  49. package/Expressions/Compiler/Parser/Interfaces.js +112 -0
  50. package/Expressions/Compiler/Parser/Interfaces.js.map +1 -0
  51. package/Expressions/Compiler/Parser/MatchGrammar.d.ts +15 -0
  52. package/Expressions/Compiler/Parser/MatchGrammar.js +128 -0
  53. package/Expressions/Compiler/Parser/MatchGrammar.js.map +1 -0
  54. package/Expressions/Compiler/Parser/MatchRepeatingRule.d.ts +4 -0
  55. package/Expressions/Compiler/Parser/MatchRepeatingRule.js +51 -0
  56. package/Expressions/Compiler/Parser/MatchRepeatingRule.js.map +1 -0
  57. package/Expressions/Compiler/Parser/MatchRule.d.ts +4 -0
  58. package/Expressions/Compiler/Parser/MatchRule.js +57 -0
  59. package/Expressions/Compiler/Parser/MatchRule.js.map +1 -0
  60. package/Expressions/Compiler/Parser/Parser.d.ts +26 -0
  61. package/Expressions/Compiler/Parser/Parser.js +67 -0
  62. package/Expressions/Compiler/Parser/Parser.js.map +1 -0
  63. package/Expressions/Compiler/Parser/Tokenizer.d.ts +12 -0
  64. package/Expressions/Compiler/Parser/Tokenizer.js +138 -0
  65. package/Expressions/Compiler/Parser/Tokenizer.js.map +1 -0
  66. package/Expressions/Compiler/Parser/TypesAndPrint.d.ts +29 -0
  67. package/Expressions/Compiler/Parser/TypesAndPrint.js +15 -0
  68. package/Expressions/Compiler/Parser/TypesAndPrint.js.map +1 -0
  69. package/Expressions/Compiler/Parser/Updates.d.ts +10 -0
  70. package/Expressions/Compiler/Parser/Updates.js +79 -0
  71. package/Expressions/Compiler/Parser/Updates.js.map +1 -0
  72. package/Networking.d.ts +3 -0
  73. package/Networking.js +19 -5
  74. package/Networking.js.map +1 -1
  75. package/package.json +28 -28
  76. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1,84 @@
1
+ import { NodeType, TokenType } from "../Parser/Enums.js";
2
+ import { GrammarRegistry } from "../GrammarRegistry.js";
3
+ import { Versions } from "../../../Constants/Versions.js";
4
+ var ExpressionSyntaxError = GrammarRegistry.ExpressionSyntaxError;
5
+ export function IsDeclarationEntryNode(node) {
6
+ return node.type === NodeType.DECLARATION_ENTRY;
7
+ }
8
+ GrammarRegistry.AddRule(Versions.v1_0_0, NodeType.DECLARATION_ENTRY, [[
9
+ { type: TokenType.IDENTIFIER, name: "name" },
10
+ { type: TokenType.OPERATOR, value: ":" },
11
+ { type: [NodeType.TYPE_UNION, NodeType.TYPE_DEFINITION], name: "type" }, //TODO: Make this optional - only if type can be inferred from initialiser?
12
+ { type: TokenType.OPERATOR, value: "=", optional: true },
13
+ { type: NodeType.EXPRESSION, name: "initialiser", optional: "previous" }
14
+ ]], {
15
+ runtimeExecute(scope, currentNode, outputType) {
16
+ if (outputType !== null) {
17
+ throw new ExpressionSyntaxError("Declarations do not return values", currentNode);
18
+ }
19
+ const type = currentNode.values.type.execute.runtimeExecute(scope, currentNode.values.type, outputType);
20
+ if (!type?.type) {
21
+ throw new ExpressionSyntaxError("Declaration type must not be never", currentNode);
22
+ }
23
+ if (currentNode.values.initialiser) {
24
+ const result = currentNode.values.initialiser.execute.runtimeExecute(scope, currentNode.values.initialiser, [type.type]);
25
+ return {
26
+ type: type.type,
27
+ value: result.value
28
+ };
29
+ }
30
+ return {
31
+ type: type.type,
32
+ value: undefined
33
+ };
34
+ },
35
+ compileTimeTraversal(scope, currentNode, outputType) {
36
+ if (outputType !== null) {
37
+ throw new ExpressionSyntaxError("Declarations do not return values", currentNode);
38
+ }
39
+ const type = currentNode.values.type.execute.compileTimeTraversal(scope, currentNode.values.type, outputType);
40
+ if (!type?.type) {
41
+ throw new ExpressionSyntaxError("Declaration type must not be never", currentNode);
42
+ }
43
+ if (currentNode.values.initialiser) {
44
+ currentNode.values.initialiser.execute.compileTimeTraversal(scope, currentNode.values.initialiser, type.type);
45
+ }
46
+ return type;
47
+ }
48
+ });
49
+ export function IsDeclarationNode(node) {
50
+ return node.type === NodeType.DECLARATION;
51
+ }
52
+ GrammarRegistry.AddRule(Versions.v1_0_0, NodeType.DECLARATION, [[
53
+ { type: TokenType.KEYWORD, values: ["const", "var"], name: "qualifiers", repeat: [1, Number.POSITIVE_INFINITY] },
54
+ {
55
+ type: NodeType.DECLARATION_ENTRY,
56
+ name: "declarations",
57
+ repeat: [1, Number.POSITIVE_INFINITY],
58
+ repeatSeparator: { type: TokenType.OPERATOR, value: "," }
59
+ },
60
+ { type: TokenType.OPERATOR, value: ";" }
61
+ ]], {
62
+ runtimeExecute(scope, currentNode, outputType) {
63
+ if (outputType !== null) {
64
+ throw new ExpressionSyntaxError("Declarations do not return values", currentNode);
65
+ }
66
+ for (const decl of currentNode.values.declarations) {
67
+ decl.execute.runtimeExecute(scope, decl, null);
68
+ }
69
+ return {
70
+ type: null,
71
+ value: null
72
+ };
73
+ },
74
+ compileTimeTraversal(scope, currentNode, outputType) {
75
+ if (outputType !== null) {
76
+ throw new ExpressionSyntaxError("Declarations do not return values", currentNode);
77
+ }
78
+ for (const decl of currentNode.values.declarations) {
79
+ decl.execute.compileTimeTraversal(scope, decl, null);
80
+ }
81
+ return null;
82
+ }
83
+ });
84
+ //# sourceMappingURL=Declarations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Declarations.js","sourceRoot":"","sources":["Declarations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAI1D,IAAO,qBAAqB,GAAG,eAAe,CAAC,qBAAqB,CAAC;AAcrE,MAAM,UAAU,sBAAsB,CAAC,IAAU;IAChD,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,iBAAiB,CAAC;AACjD,CAAC;AAED,eAAe,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,iBAAiB,EAAE,CAAC;QACrE,EAAE,IAAI,EAAE,SAAS,CAAC,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE;QAC5C,EAAE,IAAI,EAAE,SAAS,CAAC,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE;QACxC,EAAE,IAAI,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,eAAe,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,2EAA2E;QACpJ,EAAE,IAAI,EAAE,SAAS,CAAC,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE;QACxD,EAAE,IAAI,EAAE,QAAQ,CAAC,UAAU,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,UAAU,EAAE;KACxE,CAAC,EAAE;IACH,cAAc,CAAC,KAAK,EAAE,WAAiC,EAAE,UAAU;QAClE,IAAI,UAAU,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AC,OAAO,CAAC,cAAc,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QAChD,CAAC;QAED,OAAO;YACN,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,IAAI;SACX,CAAC;IACH,CAAC;IACD,oBAAoB,CAAC,KAAK,EAAE,WAA4B,EAAE,UAAU;QACnE,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;YACzB,MAAM,IAAI,qBAAqB,CAAC,mCAAmC,EAAE,WAAW,CAAC,CAAC;QACnF,CAAC;QAED,KAAK,MAAM,IAAI,IAAI,WAAW,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;YACpD,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QACtD,CAAC;QAED,OAAO,IAAI,CAAC;IACb,CAAC;CACD,CAAC,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { GrammarInterfaces } from "../Parser/Interfaces.js";
2
+ import { NodeType } from "../Parser/Enums.js";
3
+ import EAST_Token = GrammarInterfaces.EAST_Token;
4
+ import Node = GrammarInterfaces.Node;
5
+ import { BlockNode, ExpressionNode, ParenthetisedExpressionNode } from "./General.js";
6
+ import { DeclarationEntryNode } from "./Declarations.js";
7
+ import { TypeDefinitionNode } from "./Types.js";
8
+ export interface FunctionDeclarationNode extends GrammarInterfaces.EAST_Complex_Node {
9
+ type: NodeType.FUNCTION_DECLARATION;
10
+ values: {
11
+ name: EAST_Token;
12
+ parameters: DeclarationEntryNode[];
13
+ returnType?: TypeDefinitionNode;
14
+ body: BlockNode<ReturnNode>;
15
+ };
16
+ }
17
+ export declare function IsFunctionDeclarationNode(node: Node): node is FunctionDeclarationNode;
18
+ export interface FunctionCallNode extends GrammarInterfaces.EAST_Complex_Node {
19
+ type: NodeType.FUNCTION_CALL;
20
+ values: {
21
+ name: EAST_Token | ParenthetisedExpressionNode;
22
+ arguments: ExpressionNode[];
23
+ };
24
+ }
25
+ export declare function IsFunctionCallNode(node: Node): node is FunctionCallNode;
26
+ export interface ReturnNode extends GrammarInterfaces.EAST_Complex_Node {
27
+ type: NodeType.RETURN;
28
+ values: ExpressionNode["values"];
29
+ }
30
+ export declare function IsReturnNode(node: Node): node is ReturnNode;
@@ -0,0 +1,292 @@
1
+ import { GrammarInterfaces } from "../Parser/Interfaces.js";
2
+ import { CollectionType, NodeType, TokenType } from "../Parser/Enums.js";
3
+ import { GrammarRegistry } from "../GrammarRegistry.js";
4
+ import { Versions } from "../../../Constants/Versions.js";
5
+ import { CreateChildScope } from "../../TypeRegistry/Types.js";
6
+ var ExpressionSyntaxError = GrammarRegistry.ExpressionSyntaxError;
7
+ import { describeObject } from "../../../Constants/SerialisationTypes.js";
8
+ var isAssignableCompile = GrammarInterfaces.isAssignableCompile;
9
+ import { ErrorStack } from "../../../Constants/Errors.js";
10
+ import { isToken } from "./Tokens.js";
11
+ export function IsFunctionDeclarationNode(node) {
12
+ return node.type === NodeType.FUNCTION_DECLARATION;
13
+ }
14
+ GrammarRegistry.AddRule(Versions.v1_0_0, NodeType.FUNCTION_DECLARATION, [[
15
+ { type: TokenType.IDENTIFIER, value: "function" },
16
+ { type: TokenType.IDENTIFIER, name: "name" },
17
+ { type: TokenType.OPERATOR, value: "(" },
18
+ {
19
+ type: NodeType.DECLARATION_ENTRY,
20
+ name: "parameters",
21
+ repeat: [0, Number.POSITIVE_INFINITY],
22
+ repeatSeparator: { type: TokenType.OPERATOR, value: "," }
23
+ },
24
+ { type: TokenType.OPERATOR, value: ")" },
25
+ { type: [NodeType.TYPE_UNION, NodeType.TYPE_DEFINITION], name: "returnType", optional: true },
26
+ { type: NodeType.BLOCK, input: [NodeType.RETURN], name: "body" }
27
+ ]], {
28
+ runtimeExecute(scope, node, outputType) {
29
+ if (Array.isArray(outputType)) {
30
+ throw new ExpressionSyntaxError(`A function cannot be assigned this variable`, node);
31
+ }
32
+ let type = (node.execute.compileTimeTraversal(scope, node, outputType)?.type)[0];
33
+ let foo = (callingNode, ...args) => {
34
+ let contentScope = CreateChildScope(scope);
35
+ for (let i = 0; i < node.values.parameters.length; i++) {
36
+ let param = node.values.parameters[i];
37
+ let paramValue = args[i].value ?? param.execute.runtimeExecute(contentScope, param, type.parameters[i].type).value;
38
+ let paramType = type.parameters[i].type.find((e) => e.kind == "value" && e.isAssignableLive(scope.version, paramValue));
39
+ if (!paramType) {
40
+ throw new ExpressionSyntaxError(`Invalid parameter type for function.`
41
+ + ` ${describeObject(param)} is not assignable to `
42
+ + `${type.parameters[i].type.map((e) => describeObject(e)).join(" | ")}`, callingNode);
43
+ }
44
+ contentScope.local[type.parameters[i].assignmentName] = {
45
+ value: paramValue,
46
+ type: [paramType]
47
+ };
48
+ }
49
+ let returnType = node.values.body.execute.runtimeExecute(contentScope, node.values.body, outputType);
50
+ if (!Array.isArray(returnType.type) && returnType.type) {
51
+ throw new ExpressionSyntaxError(`Cannot yet return functions from functions`, node);
52
+ }
53
+ let result = node.values.body.execute.runtimeExecute(contentScope, node.values.body, returnType.type);
54
+ return {
55
+ type: returnType.type,
56
+ value: result.value
57
+ };
58
+ };
59
+ foo.type = type;
60
+ scope.local[node.values.name.data] = {
61
+ value: foo,
62
+ type: [type],
63
+ };
64
+ return {
65
+ value: foo,
66
+ type: null
67
+ };
68
+ },
69
+ compileTimeTraversal(scope, node, expectedTypes) {
70
+ let contentScope = CreateChildScope(scope);
71
+ // Validate parameters
72
+ let finalParamTypes = [];
73
+ for (let i = 0; i < node.values.parameters.length; i++) {
74
+ let param = node.values.parameters[i];
75
+ let paramType = param.execute.compileTimeTraversal(contentScope, param, null);
76
+ if (!paramType || !paramType.type) {
77
+ throw new ExpressionSyntaxError(`Function parameters failed to resolve.`, node);
78
+ }
79
+ if (!paramType.assignmentName) {
80
+ throw new ExpressionSyntaxError(`Function parameter's name must be defined.`, node);
81
+ }
82
+ finalParamTypes.push({
83
+ outputType: paramType.type,
84
+ assignmentName: paramType.assignmentName,
85
+ });
86
+ }
87
+ // Validate return type
88
+ let returnTypes = node.values.returnType?.execute?.compileTimeTraversal(scope, node.values.returnType, null);
89
+ // Add the function to the scope
90
+ let functionType = {
91
+ kind: "function",
92
+ parameters: finalParamTypes.map((param) => ({
93
+ type: param.outputType,
94
+ assignmentName: param.assignmentName,
95
+ })),
96
+ returnType: returnTypes?.type ?? null,
97
+ };
98
+ if (expectedTypes) {
99
+ let stack = new ErrorStack({ Version: scope.version, SourceFile: node.file.sourceLocation });
100
+ if (!isAssignableCompile(scope.version, expectedTypes, [functionType], node, stack)) {
101
+ throw new ExpressionSyntaxError(`Function return type does not match the expected type.` + stack.toString(`EXP_GF_FOO_01`), node);
102
+ }
103
+ }
104
+ scope.local[node.values.name.data] = {
105
+ type: [functionType],
106
+ };
107
+ // Traverse the function body
108
+ node.values.body.execute.compileTimeTraversal(contentScope, node.values.body, returnTypes?.type ?? null);
109
+ return {
110
+ type: [functionType],
111
+ assignmentName: node.values.name.data
112
+ };
113
+ }
114
+ });
115
+ export function IsFunctionCallNode(node) {
116
+ return node.type === NodeType.FUNCTION_CALL;
117
+ }
118
+ GrammarRegistry.AddRule(Versions.v1_0_0, NodeType.FUNCTION_CALL, [[
119
+ {
120
+ // Function name - Builtin, identifier
121
+ // or a parenthetised expression that returns a function as a value.
122
+ type: [TokenType.BUILTIN, NodeType.PARENTHETISED_EXPRESSION, TokenType.IDENTIFIER],
123
+ name: "name"
124
+ },
125
+ { type: TokenType.OPERATOR, value: "(" },
126
+ {
127
+ type: NodeType.EXPRESSION,
128
+ name: "arguments",
129
+ repeat: [0, Number.POSITIVE_INFINITY],
130
+ repeatSeparator: { type: TokenType.OPERATOR, value: "," }
131
+ },
132
+ { type: TokenType.OPERATOR, value: ")" }
133
+ ]], {
134
+ runtimeExecute(scope, node, outputType) {
135
+ const funcName = isToken(node.values.name) ? node.values.name.data
136
+ : node.values.name.execute.runtimeExecute(scope, node.values.name, null).value;
137
+ const funcValue = scope.local[funcName] ?? scope.global[funcName];
138
+ if (!funcValue.type) {
139
+ throw new Error(`Function does not have typing information set`);
140
+ }
141
+ //Use first matching type.
142
+ let funcType = undefined;
143
+ for (let type of funcValue.type) {
144
+ if (type.kind === "function" && funcValue.value.type == type) {
145
+ funcType = type;
146
+ break;
147
+ }
148
+ }
149
+ if (!funcType) {
150
+ throw new ExpressionSyntaxError(`Function's value does not match expected function's type.`, node);
151
+ }
152
+ const inputArgNodes = node.values.arguments;
153
+ // Check parameter count
154
+ if (funcType.parameters.length !== inputArgNodes.length) {
155
+ throw new ExpressionSyntaxError(`Function expected ${funcType.parameters.length} argument(s), but got ${inputArgNodes.length}`, node);
156
+ }
157
+ let inputArgValues = [];
158
+ for (let i = 0; i < inputArgNodes.length; i++) {
159
+ const arg = inputArgNodes[i];
160
+ let argResult = arg.execute.runtimeExecute(scope, arg, null);
161
+ let argResultType = argResult.castType ?? (argResult.type ? [argResult.type] : null);
162
+ let stack = new ErrorStack({ Version: scope.version, SourceFile: node.file.sourceLocation });
163
+ if (!isAssignableCompile(scope.version, funcType.parameters[i].type, argResultType, arg, stack)) {
164
+ throw new ExpressionSyntaxError(`Argument ${i + 1} type mismatch: ${describeObject(argResult.value)} is not assignable to any of [${funcType.parameters[i].type.map(e => e.kind == "function" ? "function" : e.debugName).join(", ")}]` + stack.toString(`EXP_GF_FC_02`), node);
165
+ }
166
+ inputArgValues.push(argResult.value);
167
+ }
168
+ // Call the function
169
+ const result = funcValue.value(node, ...inputArgValues);
170
+ let stack = new ErrorStack({ Version: scope.version, SourceFile: node.file.sourceLocation });
171
+ if (!isAssignableCompile(scope.version, outputType, result, node, stack)) {
172
+ throw new ExpressionSyntaxError(`Function return type mismatch: ${describeObject(result.value)} is not assignable to any of [${outputType?.map(e => e.kind == "function" ? "function" : e.debugName).join(", ")}]` + stack.toString(`EXP_GF_FC_03`), node);
173
+ }
174
+ return {
175
+ value: result.value,
176
+ type: result.type
177
+ };
178
+ },
179
+ compileTimeTraversal(scope, node, expectedType) {
180
+ const nameVal = node.values.name;
181
+ const argNodes = node.values.arguments;
182
+ let possibleFuncTypes = [];
183
+ if (isToken(nameVal)) {
184
+ // (1) It's a function name token
185
+ const funcName = nameVal.data;
186
+ const funcEntry = scope.local[funcName] ?? scope.global[funcName];
187
+ if (!funcEntry) {
188
+ throw new ExpressionSyntaxError(`Function '${funcName}' not found in scope`, node);
189
+ }
190
+ if (!funcEntry.type) {
191
+ throw new ExpressionSyntaxError(`Function '${funcName}' has no type info`, node);
192
+ }
193
+ // We gather only the function types; if we find a non-function, we throw an error
194
+ funcEntry.type.forEach(t => {
195
+ if (t.kind === "function") {
196
+ possibleFuncTypes.push(t);
197
+ }
198
+ else {
199
+ throw new ExpressionSyntaxError(`Type mismatch: '${funcName}' is not a function type`, node);
200
+ }
201
+ });
202
+ if (possibleFuncTypes.length === 0) {
203
+ throw new ExpressionSyntaxError(`'${funcName}' is not a valid function`, node);
204
+ }
205
+ }
206
+ else {
207
+ // (2) It's an expression => interpret as an inline function declaration
208
+ const funcTypeInfo = nameVal.execute.compileTimeTraversal(scope, nameVal, null);
209
+ const inlineTypes = funcTypeInfo?.type ?? [];
210
+ if (inlineTypes.length === 0) {
211
+ throw new ExpressionSyntaxError(`Inline function expression has no type`, node);
212
+ }
213
+ // If we find any type that is not a function, we throw
214
+ inlineTypes.forEach(t => {
215
+ if (t.kind !== "function") {
216
+ throw new ExpressionSyntaxError(`Inline expression is not a function`, node);
217
+ }
218
+ else {
219
+ possibleFuncTypes.push(t);
220
+ }
221
+ });
222
+ if (possibleFuncTypes.length === 0) {
223
+ throw new ExpressionSyntaxError(`Inline function expression is invalid`, node);
224
+ }
225
+ }
226
+ // Next, we match arguments to a candidate function signature
227
+ const argCount = argNodes.length;
228
+ let matchedType = null;
229
+ let errorStack = new ErrorStack({ Version: scope.version, SourceFile: node.file.sourceLocation });
230
+ //Candidate loop
231
+ for (const candidate of possibleFuncTypes) {
232
+ // Check param count
233
+ if (candidate.parameters.length !== argCount) {
234
+ continue; // not a match
235
+ }
236
+ // Verify each argument
237
+ let success = true;
238
+ for (let i = 0; i < argCount; i++) {
239
+ const argOutput = argNodes[i].execute.compileTimeTraversal(scope, argNodes[i], null);
240
+ // This function checks if any of argOutput.type is assignable to candidate.parameters[i].type
241
+ const argAssignable = isAssignableCompile(scope.version, candidate.parameters[i].type, argOutput?.type ?? null, node, errorStack);
242
+ if (!argAssignable) {
243
+ success = false;
244
+ break; // argument mismatch => candidate fails
245
+ }
246
+ }
247
+ if (!success) {
248
+ continue;
249
+ }
250
+ // If arguments matched, check return type vs expected
251
+ if (expectedType && !isAssignableCompile(scope.version, expectedType, candidate.returnType, node, errorStack)) {
252
+ continue; // This candidate doesn't match the expected return type
253
+ }
254
+ // We have a match
255
+ matchedType = candidate;
256
+ break;
257
+ }
258
+ if (!matchedType) {
259
+ throw new ExpressionSyntaxError(`No matching function signature found for call (${argCount} args)\n` + errorStack.toString("EXP_GF_FC_05"), node);
260
+ }
261
+ // Return the matched function's return type
262
+ return {
263
+ type: matchedType.returnType,
264
+ style: CollectionType.Single
265
+ };
266
+ }
267
+ });
268
+ export function IsReturnNode(node) {
269
+ return node.type === NodeType.RETURN;
270
+ }
271
+ GrammarRegistry.AddRule(Versions.v1_0_0, NodeType.RETURN, [[
272
+ { type: TokenType.KEYWORD, value: "return" },
273
+ { type: NodeType.EXPRESSION, unroll: true },
274
+ { type: TokenType.OPERATOR, value: ";" }
275
+ ]], {
276
+ runtimeExecute(scope, node, outputType) {
277
+ let result = node.values.expression.execute.runtimeExecute(scope, node.values.expression, null);
278
+ return {
279
+ type: result.type,
280
+ value: result.value,
281
+ interrupt: "return"
282
+ };
283
+ },
284
+ compileTimeTraversal(scope, node, expectedTypes) {
285
+ let result = node.values.expression.execute.compileTimeTraversal(scope, node.values.expression, expectedTypes);
286
+ return {
287
+ interrupt: "return",
288
+ type: result?.type ?? null,
289
+ };
290
+ }
291
+ });
292
+ //# sourceMappingURL=Function.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Function.js","sourceRoot":"","sources":["Function.ts"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E,aAAa;QAChF,IAAI,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,oBAAoB,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;QAC/G,OAAO;YACN,SAAS,EAAE,QAAQ;YACnB,IAAI,EAAE,MAAM,EAAE,IAAI,IAAI,IAAI;SAC1B,CAAC;IACH,CAAC;CACD,CAAC,CAAC"}
@@ -0,0 +1,55 @@
1
+ import { GrammarInterfaces } from "../Parser/Interfaces.js";
2
+ import { NodeType } from "../Parser/Enums.js";
3
+ import { ArrayAccessSequenceNode, MemberAccessNode } from "./Accessors.js";
4
+ import EAST_Token = GrammarInterfaces.EAST_Token;
5
+ import Node = GrammarInterfaces.Node;
6
+ import EAST_Complex_Node = GrammarInterfaces.EAST_Complex_Node;
7
+ import { CommentNode, PreprocessorCommandNode } from "./Preprocessors.js";
8
+ import { FunctionCallNode, FunctionDeclarationNode } from "./Function.js";
9
+ import { AssignmentNode, LiteralNode } from "./Misc.js";
10
+ import { BinaryExpressionNode, UnaryExpressionNode } from "./Maths.js";
11
+ import { DeclarationNode } from "./Declarations.js";
12
+ import { CastNode } from "./Types.js";
13
+ export interface FileNode extends EAST_Complex_Node {
14
+ type: NodeType.FILE;
15
+ text: string;
16
+ sourceLocation: string;
17
+ version: string;
18
+ values: {
19
+ lines: (CommentNode | PreprocessorCommandNode | FunctionDeclarationNode | DeclarationNode | ExpressionNode)[];
20
+ };
21
+ }
22
+ export declare function IsFileNode(node: Node): node is FileNode;
23
+ export interface BlockNode<Extensions extends EAST_Complex_Node | never> extends GrammarInterfaces.EAST_Complex_Node {
24
+ type: NodeType.BLOCK;
25
+ values: {
26
+ lines: (Extensions | CommentNode | DeclarationNode | StatementNode)[];
27
+ };
28
+ }
29
+ export declare function IsBlockNode(node: Node): node is BlockNode<GrammarInterfaces.EAST_Complex_Node>;
30
+ export interface StatementNode extends EAST_Complex_Node {
31
+ type: NodeType.STATEMENT;
32
+ values: {
33
+ expression: ExpressionNode["values"]["expression"];
34
+ };
35
+ }
36
+ export declare function IsStatementNode(node: Node): node is StatementNode;
37
+ export interface ExpressionNode extends EAST_Complex_Node {
38
+ type: NodeType.EXPRESSION;
39
+ values: {
40
+ expression: ArrayAccessSequenceNode | FunctionCallNode | MemberAccessNode | BinaryExpressionNode | ParenthetisedExpressionNode | UnaryExpressionNode | CastNode | AssignmentNode | EAST_Token | LiteralNode;
41
+ };
42
+ }
43
+ export declare function IsExpressionNode(node: Node): node is ExpressionNode;
44
+ export interface ParenthetisedExpressionNode extends EAST_Complex_Node {
45
+ type: NodeType.PARENTHETISED_EXPRESSION;
46
+ values: ExpressionNode["values"];
47
+ }
48
+ export declare function IsParenthetisedExpressionNode(node: Node): node is ParenthetisedExpressionNode;
49
+ export interface IdentifierNode extends EAST_Complex_Node {
50
+ type: NodeType.IDENTIFIER;
51
+ values: {
52
+ name: EAST_Token;
53
+ };
54
+ }
55
+ export declare function IdentifierNode(node: Node): node is ParenthetisedExpressionNode;