cashc 0.7.2 → 0.7.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.
- package/dist/main/ast/AST.d.ts +2 -2
- package/dist/main/ast/AstBuilder.js +2 -3
- package/dist/main/grammar/CashScriptParser.d.ts +2 -1
- package/dist/main/grammar/CashScriptParser.js +296 -284
- package/dist/main/index.d.ts +1 -1
- package/dist/main/index.js +1 -1
- package/dist/main/semantic/SymbolTableTraversal.js +9 -6
- package/dist/main/semantic/TypeCheckTraversal.js +1 -1
- package/dist/module/ast/AST.d.ts +2 -2
- package/dist/module/ast/AstBuilder.js +2 -3
- package/dist/module/grammar/CashScriptParser.d.ts +2 -1
- package/dist/module/grammar/CashScriptParser.js +296 -284
- package/dist/module/index.d.ts +1 -1
- package/dist/module/index.js +1 -1
- package/dist/module/semantic/SymbolTableTraversal.js +9 -6
- package/dist/module/semantic/TypeCheckTraversal.js +1 -1
- package/package.json +3 -3
package/dist/main/index.d.ts
CHANGED
package/dist/main/index.js
CHANGED
|
@@ -32,5 +32,5 @@ exports.utils = __importStar(require("@cashscript/utils"));
|
|
|
32
32
|
var compiler_js_1 = require("./compiler.js");
|
|
33
33
|
Object.defineProperty(exports, "compileFile", { enumerable: true, get: function () { return compiler_js_1.compileFile; } });
|
|
34
34
|
Object.defineProperty(exports, "compileString", { enumerable: true, get: function () { return compiler_js_1.compileString; } });
|
|
35
|
-
exports.version = '0.7.
|
|
35
|
+
exports.version = '0.7.4';
|
|
36
36
|
//# sourceMappingURL=index.js.map
|
|
@@ -73,20 +73,23 @@ class SymbolTableTraversal extends AstTraversal_js_1.default {
|
|
|
73
73
|
return node;
|
|
74
74
|
}
|
|
75
75
|
visitAssign(node) {
|
|
76
|
-
var _a;
|
|
76
|
+
var _a, _b;
|
|
77
77
|
const v = (_a = this.symbolTables[0].get(node.identifier.name)) === null || _a === void 0 ? void 0 : _a.definition;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
// const used_modifiers = [] # PREVENT USER FROM USING SAME MODIFIER AGAIN
|
|
79
|
+
(_b = v === null || v === void 0 ? void 0 : v.modifier) === null || _b === void 0 ? void 0 : _b.forEach((modifier) => {
|
|
80
|
+
if (modifier === Globals_js_1.Modifier.CONSTANT) {
|
|
81
|
+
throw new Errors_js_1.ConstantModificationError(v);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
81
84
|
super.visitAssign(node);
|
|
82
85
|
return node;
|
|
83
86
|
}
|
|
84
87
|
visitTupleAssignment(node) {
|
|
85
88
|
[node.var1, node.var2].forEach(({ name, type }) => {
|
|
86
89
|
if (this.symbolTables[0].get(name)) {
|
|
87
|
-
throw new Errors_js_1.VariableRedefinitionError(new AST_js_1.VariableDefinitionNode(type,
|
|
90
|
+
throw new Errors_js_1.VariableRedefinitionError(new AST_js_1.VariableDefinitionNode(type, [], name, node.tuple));
|
|
88
91
|
}
|
|
89
|
-
this.symbolTables[0].set(SymbolTable_js_1.Symbol.variable(new AST_js_1.VariableDefinitionNode(type,
|
|
92
|
+
this.symbolTables[0].set(SymbolTable_js_1.Symbol.variable(new AST_js_1.VariableDefinitionNode(type, [], name, node.tuple)));
|
|
90
93
|
});
|
|
91
94
|
node.tuple = this.visit(node.tuple);
|
|
92
95
|
return node;
|
|
@@ -27,7 +27,7 @@ class TypeCheckTraversal extends AstTraversal_js_1.default {
|
|
|
27
27
|
if (tupleType instanceof utils_1.BytesType && variable.type instanceof utils_1.BytesType) {
|
|
28
28
|
return node;
|
|
29
29
|
}
|
|
30
|
-
throw new Errors_js_1.AssignTypeError(new AST_js_1.VariableDefinitionNode(variable.type,
|
|
30
|
+
throw new Errors_js_1.AssignTypeError(new AST_js_1.VariableDefinitionNode(variable.type, [], variable.name, node.tuple));
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
return node;
|
package/dist/module/ast/AST.d.ts
CHANGED
|
@@ -47,10 +47,10 @@ export declare abstract class StatementNode extends Node {
|
|
|
47
47
|
}
|
|
48
48
|
export declare class VariableDefinitionNode extends StatementNode implements Named, Typed {
|
|
49
49
|
type: Type;
|
|
50
|
-
modifier: string;
|
|
50
|
+
modifier: string[];
|
|
51
51
|
name: string;
|
|
52
52
|
expression: ExpressionNode;
|
|
53
|
-
constructor(type: Type, modifier: string, name: string, expression: ExpressionNode);
|
|
53
|
+
constructor(type: Type, modifier: string[], name: string, expression: ExpressionNode);
|
|
54
54
|
accept<T>(visitor: AstVisitor<T>): T;
|
|
55
55
|
}
|
|
56
56
|
export declare class TupleAssignmentNode extends StatementNode {
|
|
@@ -68,12 +68,11 @@ export default class AstBuilder extends AbstractParseTreeVisitor {
|
|
|
68
68
|
return parameter;
|
|
69
69
|
}
|
|
70
70
|
visitVariableDefinition(ctx) {
|
|
71
|
-
var _a, _b;
|
|
72
71
|
const type = parseType(ctx.typeName().text);
|
|
73
|
-
const
|
|
72
|
+
const modifiers = ctx.modifier().map((modifier) => modifier.text);
|
|
74
73
|
const name = ctx.Identifier().text;
|
|
75
74
|
const expression = this.visit(ctx.expression());
|
|
76
|
-
const variableDefinition = new VariableDefinitionNode(type,
|
|
75
|
+
const variableDefinition = new VariableDefinitionNode(type, modifiers, name, expression);
|
|
77
76
|
variableDefinition.location = Location.fromCtx(ctx);
|
|
78
77
|
return variableDefinition;
|
|
79
78
|
}
|
|
@@ -263,7 +263,8 @@ export declare class VariableDefinitionContext extends ParserRuleContext {
|
|
|
263
263
|
typeName(): TypeNameContext;
|
|
264
264
|
Identifier(): TerminalNode;
|
|
265
265
|
expression(): ExpressionContext;
|
|
266
|
-
modifier(): ModifierContext
|
|
266
|
+
modifier(): ModifierContext[];
|
|
267
|
+
modifier(i: number): ModifierContext;
|
|
267
268
|
constructor(parent: ParserRuleContext | undefined, invokingState: number);
|
|
268
269
|
get ruleIndex(): number;
|
|
269
270
|
enterRule(listener: CashScriptListener): void;
|