cashc 0.13.2 → 0.14.0-next.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.
- package/dist/Errors.d.ts +26 -1
- package/dist/Errors.js +42 -1
- package/dist/artifact/Artifact.js +2 -0
- package/dist/ast/AST.d.ts +28 -4
- package/dist/ast/AST.js +38 -2
- package/dist/ast/AstBuilder.d.ts +8 -3
- package/dist/ast/AstBuilder.js +45 -6
- package/dist/ast/AstTraversal.d.ts +4 -1
- package/dist/ast/AstTraversal.js +13 -1
- package/dist/ast/AstVisitor.d.ts +4 -1
- package/dist/ast/Globals.js +27 -14
- package/dist/ast/SymbolTable.d.ts +7 -3
- package/dist/ast/SymbolTable.js +17 -3
- package/dist/compiler.d.ts +1 -2
- package/dist/compiler.js +19 -27
- package/dist/dependency-resolution.d.ts +3 -0
- package/dist/dependency-resolution.js +40 -0
- package/dist/generation/GenerateTargetTraversal.d.ts +4 -1
- package/dist/generation/GenerateTargetTraversal.js +47 -8
- package/dist/generation/utils.d.ts +1 -2
- package/dist/generation/utils.js +1 -19
- package/dist/grammar/CashScriptLexer.d.ts +23 -20
- package/dist/grammar/CashScriptLexer.js +347 -331
- package/dist/grammar/CashScriptParser.d.ts +109 -57
- package/dist/grammar/CashScriptParser.js +1056 -680
- package/dist/grammar/CashScriptVisitor.d.ts +38 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/parser.d.ts +3 -0
- package/dist/parser.js +23 -0
- package/dist/print/OutputSourceCodeTraversal.d.ts +5 -1
- package/dist/print/OutputSourceCodeTraversal.js +23 -0
- package/dist/semantic/DeadCodeEliminationTraversal.d.ts +7 -0
- package/dist/semantic/DeadCodeEliminationTraversal.js +32 -0
- package/dist/semantic/EnsureFinalRequireTraversal.js +48 -3
- package/dist/semantic/EnsureFunctionsSafeTraversal.d.ts +8 -0
- package/dist/semantic/EnsureFunctionsSafeTraversal.js +35 -0
- package/dist/semantic/InjectLocktimeGuardTraversal.d.ts +5 -5
- package/dist/semantic/InjectLocktimeGuardTraversal.js +55 -18
- package/dist/semantic/SymbolTableTraversal.d.ts +3 -2
- package/dist/semantic/SymbolTableTraversal.js +28 -12
- package/dist/semantic/TypeCheckTraversal.d.ts +5 -1
- package/dist/semantic/TypeCheckTraversal.js +36 -12
- package/package.json +3 -3
package/dist/Errors.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Type } from '@cashscript/utils';
|
|
2
|
-
import { IdentifierNode, FunctionDefinitionNode, VariableDefinitionNode, ParameterNode, Node, FunctionCallNode, BinaryOpNode, UnaryOpNode, TimeOpNode, CastNode, AssignNode, BranchNode, ArrayNode, TupleIndexOpNode, RequireNode, InstantiationNode, StatementNode, ContractNode, ExpressionNode, SliceNode } from './ast/AST.js';
|
|
2
|
+
import { IdentifierNode, ImportNode, FunctionDefinitionNode, VariableDefinitionNode, ParameterNode, Node, FunctionCallNode, BinaryOpNode, UnaryOpNode, TimeOpNode, CastNode, AssignNode, BranchNode, ArrayNode, TupleIndexOpNode, RequireNode, InstantiationNode, StatementNode, ContractNode, ExpressionNode, SliceNode } from './ast/AST.js';
|
|
3
3
|
import { Symbol, SymbolType } from './ast/SymbolTable.js';
|
|
4
4
|
import { Location } from './ast/Location.js';
|
|
5
5
|
export declare class CashScriptError extends Error {
|
|
@@ -25,6 +25,13 @@ export declare class FunctionRedefinitionError extends RedefinitionError {
|
|
|
25
25
|
node: FunctionDefinitionNode;
|
|
26
26
|
constructor(node: FunctionDefinitionNode);
|
|
27
27
|
}
|
|
28
|
+
export declare class MissingContractError extends Error {
|
|
29
|
+
constructor();
|
|
30
|
+
}
|
|
31
|
+
export declare class ImportResolutionError extends CashScriptError {
|
|
32
|
+
node: ImportNode;
|
|
33
|
+
constructor(node: ImportNode, message: string);
|
|
34
|
+
}
|
|
28
35
|
export declare class VariableRedefinitionError extends RedefinitionError {
|
|
29
36
|
node: VariableDefinitionNode | ParameterNode;
|
|
30
37
|
constructor(node: VariableDefinitionNode | ParameterNode);
|
|
@@ -45,11 +52,29 @@ export declare class FinalRequireStatementError extends CashScriptError {
|
|
|
45
52
|
node: StatementNode;
|
|
46
53
|
constructor(node: StatementNode);
|
|
47
54
|
}
|
|
55
|
+
export declare class UnusedFunctionReturnError extends CashScriptError {
|
|
56
|
+
node: FunctionCallNode;
|
|
57
|
+
constructor(node: FunctionCallNode);
|
|
58
|
+
}
|
|
59
|
+
export declare class MissingReturnError extends CashScriptError {
|
|
60
|
+
node: Node;
|
|
61
|
+
constructor(node: Node);
|
|
62
|
+
}
|
|
63
|
+
export declare class MisplacedReturnError extends CashScriptError {
|
|
64
|
+
node: StatementNode;
|
|
65
|
+
constructor(node: StatementNode);
|
|
66
|
+
}
|
|
67
|
+
export declare class UnsafeFunctionOperationError extends CashScriptError {
|
|
68
|
+
constructor(node: Node, operation: string);
|
|
69
|
+
}
|
|
48
70
|
export declare class TypeError extends CashScriptError {
|
|
49
71
|
actual?: (Type | Type[]) | undefined;
|
|
50
72
|
expected?: (Type | Type[]) | undefined;
|
|
51
73
|
constructor(node: Node, actual?: (Type | Type[]) | undefined, expected?: (Type | Type[]) | undefined, message?: string);
|
|
52
74
|
}
|
|
75
|
+
export declare class ReturnTypeError extends TypeError {
|
|
76
|
+
constructor(node: Node, actual?: Type, expected?: Type);
|
|
77
|
+
}
|
|
53
78
|
export declare class InvalidParameterTypeError extends TypeError {
|
|
54
79
|
constructor(node: FunctionCallNode | RequireNode | InstantiationNode, actual: Type[], expected: Type[]);
|
|
55
80
|
}
|
package/dist/Errors.js
CHANGED
|
@@ -28,7 +28,7 @@ export class UndefinedReferenceError extends CashScriptError {
|
|
|
28
28
|
}
|
|
29
29
|
export class InvalidSymbolTypeError extends CashScriptError {
|
|
30
30
|
constructor(node, expected) {
|
|
31
|
-
super(node, `Found symbol ${node.name} with type ${node.
|
|
31
|
+
super(node, `Found symbol ${node.name} with type ${node.symbol?.symbolType} where type ${expected} was expected`);
|
|
32
32
|
this.node = node;
|
|
33
33
|
this.expected = expected;
|
|
34
34
|
}
|
|
@@ -41,6 +41,18 @@ export class FunctionRedefinitionError extends RedefinitionError {
|
|
|
41
41
|
this.node = node;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
+
export class MissingContractError extends Error {
|
|
45
|
+
constructor() {
|
|
46
|
+
super('Source file does not contain a contract definition');
|
|
47
|
+
this.name = this.constructor.name;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export class ImportResolutionError extends CashScriptError {
|
|
51
|
+
constructor(node, message) {
|
|
52
|
+
super(node, message);
|
|
53
|
+
this.node = node;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
44
56
|
export class VariableRedefinitionError extends RedefinitionError {
|
|
45
57
|
constructor(node) {
|
|
46
58
|
super(node, `Redefinition of variable ${node.name}`);
|
|
@@ -71,6 +83,30 @@ export class FinalRequireStatementError extends CashScriptError {
|
|
|
71
83
|
this.node = node;
|
|
72
84
|
}
|
|
73
85
|
}
|
|
86
|
+
export class UnusedFunctionReturnError extends CashScriptError {
|
|
87
|
+
constructor(node) {
|
|
88
|
+
super(node, `Return value of ${node.identifier.name} must be used; only void functions may be called as a statement`);
|
|
89
|
+
this.node = node;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
export class MissingReturnError extends CashScriptError {
|
|
93
|
+
constructor(node) {
|
|
94
|
+
super(node, 'A value-returning function must end with a return statement');
|
|
95
|
+
this.node = node;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
export class MisplacedReturnError extends CashScriptError {
|
|
99
|
+
constructor(node) {
|
|
100
|
+
super(node, 'A return statement is only allowed as the final statement of a function body');
|
|
101
|
+
this.node = node;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
export class UnsafeFunctionOperationError extends CashScriptError {
|
|
105
|
+
constructor(node, operation) {
|
|
106
|
+
super(node, `'${operation}' cannot be used inside a user-defined function. Use it directly in a `
|
|
107
|
+
+ 'contract function instead, or pass the resulting value into the function as a parameter');
|
|
108
|
+
}
|
|
109
|
+
}
|
|
74
110
|
export class TypeError extends CashScriptError {
|
|
75
111
|
constructor(node, actual, expected, message) {
|
|
76
112
|
super(node, message ?? `Found type '${actual}' where type '${expected}' was expected`);
|
|
@@ -78,6 +114,11 @@ export class TypeError extends CashScriptError {
|
|
|
78
114
|
this.expected = expected;
|
|
79
115
|
}
|
|
80
116
|
}
|
|
117
|
+
export class ReturnTypeError extends TypeError {
|
|
118
|
+
constructor(node, actual, expected) {
|
|
119
|
+
super(node, actual, expected, `Cannot return type '${actual}' from a function with return type '${expected}'`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
81
122
|
export class InvalidParameterTypeError extends TypeError {
|
|
82
123
|
constructor(node, actual, expected) {
|
|
83
124
|
const name = node instanceof RequireNode ? 'require' : node.identifier.name;
|
|
@@ -2,6 +2,8 @@ import { scriptToAsm, } from '@cashscript/utils';
|
|
|
2
2
|
import { version } from '../index.js';
|
|
3
3
|
export function generateArtifact(ast, script, source, debug, compilerOptions, fingerprint) {
|
|
4
4
|
const { contract } = ast;
|
|
5
|
+
if (!contract)
|
|
6
|
+
throw new Error('Internal error: cannot generate an artifact for a source file with no contract');
|
|
5
7
|
const constructorInputs = contract.parameters
|
|
6
8
|
.map((parameter) => ({ name: parameter.name, type: parameter.type.toString() }));
|
|
7
9
|
const abi = contract.functions.map((func) => ({
|
package/dist/ast/AST.d.ts
CHANGED
|
@@ -15,9 +15,21 @@ export interface Named {
|
|
|
15
15
|
export interface Typed {
|
|
16
16
|
type: Type;
|
|
17
17
|
}
|
|
18
|
+
export declare enum FunctionKind {
|
|
19
|
+
CONTRACT = "contract",
|
|
20
|
+
GLOBAL = "global"
|
|
21
|
+
}
|
|
18
22
|
export declare class SourceFileNode extends Node {
|
|
19
|
-
contract
|
|
20
|
-
|
|
23
|
+
contract?: ContractNode | undefined;
|
|
24
|
+
functions: FunctionDefinitionNode[];
|
|
25
|
+
imports: ImportNode[];
|
|
26
|
+
symbolTable?: SymbolTable;
|
|
27
|
+
constructor(contract?: ContractNode | undefined, functions?: FunctionDefinitionNode[], imports?: ImportNode[]);
|
|
28
|
+
accept<T>(visitor: AstVisitor<T>): T;
|
|
29
|
+
}
|
|
30
|
+
export declare class ImportNode extends Node {
|
|
31
|
+
path: string;
|
|
32
|
+
constructor(path: string);
|
|
21
33
|
accept<T>(visitor: AstVisitor<T>): T;
|
|
22
34
|
}
|
|
23
35
|
export declare class ContractNode extends Node implements Named {
|
|
@@ -29,12 +41,14 @@ export declare class ContractNode extends Node implements Named {
|
|
|
29
41
|
accept<T>(visitor: AstVisitor<T>): T;
|
|
30
42
|
}
|
|
31
43
|
export declare class FunctionDefinitionNode extends Node implements Named {
|
|
44
|
+
kind: FunctionKind;
|
|
32
45
|
name: string;
|
|
33
46
|
parameters: ParameterNode[];
|
|
34
47
|
body: BlockNode;
|
|
48
|
+
returnType?: Type | undefined;
|
|
35
49
|
symbolTable?: SymbolTable;
|
|
36
50
|
opRolls: Map<string, IdentifierNode>;
|
|
37
|
-
constructor(name: string, parameters: ParameterNode[], body: BlockNode);
|
|
51
|
+
constructor(kind: FunctionKind, name: string, parameters: ParameterNode[], body: BlockNode, returnType?: Type | undefined);
|
|
38
52
|
accept<T>(visitor: AstVisitor<T>): T;
|
|
39
53
|
}
|
|
40
54
|
export declare class ParameterNode extends Node implements Named, Typed {
|
|
@@ -101,6 +115,16 @@ export declare class ConsoleStatementNode extends NonControlStatementNode {
|
|
|
101
115
|
constructor(parameters: ConsoleParameterNode[]);
|
|
102
116
|
accept<T>(visitor: AstVisitor<T>): T;
|
|
103
117
|
}
|
|
118
|
+
export declare class FunctionCallStatementNode extends NonControlStatementNode {
|
|
119
|
+
functionCall: FunctionCallNode;
|
|
120
|
+
constructor(functionCall: FunctionCallNode);
|
|
121
|
+
accept<T>(visitor: AstVisitor<T>): T;
|
|
122
|
+
}
|
|
123
|
+
export declare class ReturnNode extends NonControlStatementNode {
|
|
124
|
+
expression: ExpressionNode;
|
|
125
|
+
constructor(expression: ExpressionNode);
|
|
126
|
+
accept<T>(visitor: AstVisitor<T>): T;
|
|
127
|
+
}
|
|
104
128
|
export declare class BranchNode extends ControlStatementNode {
|
|
105
129
|
condition: ExpressionNode;
|
|
106
130
|
ifBlock: BlockNode;
|
|
@@ -195,7 +219,7 @@ export declare class ArrayNode extends ExpressionNode {
|
|
|
195
219
|
}
|
|
196
220
|
export declare class IdentifierNode extends ExpressionNode implements Named {
|
|
197
221
|
name: string;
|
|
198
|
-
|
|
222
|
+
symbol?: Symbol;
|
|
199
223
|
constructor(name: string);
|
|
200
224
|
accept<T>(visitor: AstVisitor<T>): T;
|
|
201
225
|
}
|
package/dist/ast/AST.js
CHANGED
|
@@ -2,15 +2,31 @@ import { PrimitiveType, BytesType } from '@cashscript/utils';
|
|
|
2
2
|
import { binToHex } from '@bitauth/libauth';
|
|
3
3
|
export class Node {
|
|
4
4
|
}
|
|
5
|
+
export var FunctionKind;
|
|
6
|
+
(function (FunctionKind) {
|
|
7
|
+
FunctionKind["CONTRACT"] = "contract";
|
|
8
|
+
FunctionKind["GLOBAL"] = "global";
|
|
9
|
+
})(FunctionKind || (FunctionKind = {}));
|
|
5
10
|
export class SourceFileNode extends Node {
|
|
6
|
-
constructor(contract) {
|
|
11
|
+
constructor(contract, functions = [], imports = []) {
|
|
7
12
|
super();
|
|
8
13
|
this.contract = contract;
|
|
14
|
+
this.functions = functions;
|
|
15
|
+
this.imports = imports;
|
|
9
16
|
}
|
|
10
17
|
accept(visitor) {
|
|
11
18
|
return visitor.visitSourceFile(this);
|
|
12
19
|
}
|
|
13
20
|
}
|
|
21
|
+
export class ImportNode extends Node {
|
|
22
|
+
constructor(path) {
|
|
23
|
+
super();
|
|
24
|
+
this.path = path;
|
|
25
|
+
}
|
|
26
|
+
accept(visitor) {
|
|
27
|
+
return visitor.visitImport(this);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
14
30
|
export class ContractNode extends Node {
|
|
15
31
|
constructor(name, parameters, functions) {
|
|
16
32
|
super();
|
|
@@ -23,11 +39,13 @@ export class ContractNode extends Node {
|
|
|
23
39
|
}
|
|
24
40
|
}
|
|
25
41
|
export class FunctionDefinitionNode extends Node {
|
|
26
|
-
constructor(name, parameters, body) {
|
|
42
|
+
constructor(kind, name, parameters, body, returnType) {
|
|
27
43
|
super();
|
|
44
|
+
this.kind = kind;
|
|
28
45
|
this.name = name;
|
|
29
46
|
this.parameters = parameters;
|
|
30
47
|
this.body = body;
|
|
48
|
+
this.returnType = returnType;
|
|
31
49
|
this.opRolls = new Map();
|
|
32
50
|
}
|
|
33
51
|
accept(visitor) {
|
|
@@ -117,6 +135,24 @@ export class ConsoleStatementNode extends NonControlStatementNode {
|
|
|
117
135
|
return visitor.visitConsoleStatement(this);
|
|
118
136
|
}
|
|
119
137
|
}
|
|
138
|
+
export class FunctionCallStatementNode extends NonControlStatementNode {
|
|
139
|
+
constructor(functionCall) {
|
|
140
|
+
super();
|
|
141
|
+
this.functionCall = functionCall;
|
|
142
|
+
}
|
|
143
|
+
accept(visitor) {
|
|
144
|
+
return visitor.visitFunctionCallStatement(this);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
export class ReturnNode extends NonControlStatementNode {
|
|
148
|
+
constructor(expression) {
|
|
149
|
+
super();
|
|
150
|
+
this.expression = expression;
|
|
151
|
+
}
|
|
152
|
+
accept(visitor) {
|
|
153
|
+
return visitor.visitReturn(this);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
120
156
|
export class BranchNode extends ControlStatementNode {
|
|
121
157
|
constructor(condition, ifBlock, elseBlock) {
|
|
122
158
|
super();
|
package/dist/ast/AstBuilder.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ParseTree, ParseTreeVisitor } from 'antlr4';
|
|
2
|
-
import { Node, SourceFileNode, ContractNode, ParameterNode, VariableDefinitionNode, FunctionDefinitionNode, AssignNode, IdentifierNode, BranchNode, CastNode, FunctionCallNode, UnaryOpNode, BinaryOpNode, BoolLiteralNode, IntLiteralNode, HexLiteralNode, StringLiteralNode, ExpressionNode, StatementNode, LiteralNode, BlockNode, TimeOpNode, ArrayNode, TupleIndexOpNode, RequireNode, InstantiationNode, TupleAssignmentNode, NullaryOpNode, ConsoleStatementNode, ConsoleParameterNode, SliceNode, DoWhileNode, WhileNode, ForNode } from './AST.js';
|
|
3
|
-
import type { ContractDefinitionContext,
|
|
2
|
+
import { Node, SourceFileNode, ImportNode, ContractNode, ParameterNode, VariableDefinitionNode, FunctionDefinitionNode, AssignNode, IdentifierNode, BranchNode, CastNode, FunctionCallNode, UnaryOpNode, BinaryOpNode, BoolLiteralNode, IntLiteralNode, HexLiteralNode, StringLiteralNode, ExpressionNode, StatementNode, LiteralNode, BlockNode, TimeOpNode, ArrayNode, TupleIndexOpNode, RequireNode, ReturnNode, InstantiationNode, TupleAssignmentNode, NullaryOpNode, ConsoleStatementNode, ConsoleParameterNode, FunctionCallStatementNode, SliceNode, DoWhileNode, WhileNode, ForNode } from './AST.js';
|
|
3
|
+
import type { ImportDirectiveContext, ContractDefinitionContext, ContractFunctionDefinitionContext, GlobalFunctionDefinitionContext, ReturnStatementContext, FunctionCallStatementContext, VariableDefinitionContext, TupleAssignmentContext, ParameterContext, AssignStatementContext, IfStatementContext, FunctionCallContext, CastContext, LiteralContext, SourceFileContext, BlockContext, TimeOpStatementContext, ArrayContext, ParenthesisedContext, FunctionCallExpressionContext, UnaryOpContext, BinaryOpContext, IdentifierContext, LiteralExpressionContext, TupleIndexOpContext, RequireStatementContext, PragmaDirectiveContext, InstantiationContext, NullaryOpContext, UnaryIntrospectionOpContext, ConsoleStatementContext, ConsoleParameterContext, StatementContext, NonControlStatementContext, ControlStatementContext, RequireMessageContext, SliceContext, DoWhileStatementContext, LoopStatementContext, WhileStatementContext, ForStatementContext, ForInitContext, FunctionBodyContext } from '../grammar/CashScriptParser.js';
|
|
4
4
|
import CashScriptVisitor from '../grammar/CashScriptVisitor.js';
|
|
5
5
|
export default class AstBuilder extends ParseTreeVisitor<Node> implements CashScriptVisitor<Node> {
|
|
6
6
|
private tree;
|
|
@@ -8,9 +8,12 @@ export default class AstBuilder extends ParseTreeVisitor<Node> implements CashSc
|
|
|
8
8
|
defaultResult(): Node;
|
|
9
9
|
build(): Node;
|
|
10
10
|
visitSourceFile(ctx: SourceFileContext): SourceFileNode;
|
|
11
|
+
visitImportDirective(ctx: ImportDirectiveContext): ImportNode;
|
|
11
12
|
processPragma(ctx: PragmaDirectiveContext): void;
|
|
12
13
|
visitContractDefinition(ctx: ContractDefinitionContext): ContractNode;
|
|
13
|
-
|
|
14
|
+
visitContractFunctionDefinition(ctx: ContractFunctionDefinitionContext): FunctionDefinitionNode;
|
|
15
|
+
visitGlobalFunctionDefinition(ctx: GlobalFunctionDefinitionContext): FunctionDefinitionNode;
|
|
16
|
+
private buildFunctionDefinition;
|
|
14
17
|
visitFunctionBody(ctx: FunctionBodyContext): BlockNode;
|
|
15
18
|
visitParameter(ctx: ParameterContext): ParameterNode;
|
|
16
19
|
visitStatement(ctx: StatementContext): StatementNode;
|
|
@@ -22,6 +25,8 @@ export default class AstBuilder extends ParseTreeVisitor<Node> implements CashSc
|
|
|
22
25
|
private createAssignExpression;
|
|
23
26
|
visitTimeOpStatement(ctx: TimeOpStatementContext): TimeOpNode;
|
|
24
27
|
visitRequireStatement(ctx: RequireStatementContext): RequireNode;
|
|
28
|
+
visitReturnStatement(ctx: ReturnStatementContext): ReturnNode;
|
|
29
|
+
visitFunctionCallStatement(ctx: FunctionCallStatementContext): FunctionCallStatementNode;
|
|
25
30
|
visitIfStatement(ctx: IfStatementContext): BranchNode;
|
|
26
31
|
visitLoopStatement(ctx: LoopStatementContext): StatementNode;
|
|
27
32
|
visitDoWhileStatement(ctx: DoWhileStatementContext): DoWhileNode;
|
package/dist/ast/AstBuilder.js
CHANGED
|
@@ -2,7 +2,7 @@ import { ParseTreeVisitor } from 'antlr4';
|
|
|
2
2
|
import { hexToBin } from '@bitauth/libauth';
|
|
3
3
|
import { parseType } from '@cashscript/utils';
|
|
4
4
|
import semver from 'semver';
|
|
5
|
-
import { SourceFileNode, ContractNode, ParameterNode, VariableDefinitionNode, FunctionDefinitionNode, AssignNode, IdentifierNode, BranchNode, CastNode, FunctionCallNode, UnaryOpNode, BinaryOpNode, BoolLiteralNode, IntLiteralNode, HexLiteralNode, StringLiteralNode, BlockNode, TimeOpNode, ArrayNode, TupleIndexOpNode, RequireNode, InstantiationNode, TupleAssignmentNode, NullaryOpNode, ConsoleStatementNode, SliceNode, DoWhileNode, WhileNode, ForNode, } from './AST.js';
|
|
5
|
+
import { SourceFileNode, ImportNode, ContractNode, ParameterNode, VariableDefinitionNode, FunctionDefinitionNode, FunctionKind, AssignNode, IdentifierNode, BranchNode, CastNode, FunctionCallNode, UnaryOpNode, BinaryOpNode, BoolLiteralNode, IntLiteralNode, HexLiteralNode, StringLiteralNode, BlockNode, TimeOpNode, ArrayNode, TupleIndexOpNode, RequireNode, ReturnNode, InstantiationNode, TupleAssignmentNode, NullaryOpNode, ConsoleStatementNode, FunctionCallStatementNode, SliceNode, DoWhileNode, WhileNode, ForNode, } from './AST.js';
|
|
6
6
|
import { BinaryOperator } from './Operator.js';
|
|
7
7
|
import { Location } from './Location.js';
|
|
8
8
|
import { NumberUnit, } from './Globals.js';
|
|
@@ -24,11 +24,30 @@ export default class AstBuilder extends ParseTreeVisitor {
|
|
|
24
24
|
ctx.pragmaDirective_list().forEach((pragma) => {
|
|
25
25
|
this.processPragma(pragma);
|
|
26
26
|
});
|
|
27
|
-
const
|
|
28
|
-
const
|
|
27
|
+
const imports = ctx.importDirective_list().map((directive) => this.visit(directive));
|
|
28
|
+
const functions = [];
|
|
29
|
+
let contract;
|
|
30
|
+
ctx.topLevelDefinition_list().forEach((def) => {
|
|
31
|
+
if (def.globalFunctionDefinition()) {
|
|
32
|
+
functions.push(this.visit(def.globalFunctionDefinition()));
|
|
33
|
+
}
|
|
34
|
+
else if (def.contractDefinition()) {
|
|
35
|
+
if (contract) {
|
|
36
|
+
throw new ParseError('A source file may define at most one contract', Location.fromCtx(def.contractDefinition()));
|
|
37
|
+
}
|
|
38
|
+
contract = this.visit(def.contractDefinition());
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
const sourceFileNode = new SourceFileNode(contract, functions, imports);
|
|
29
42
|
sourceFileNode.location = Location.fromCtx(ctx);
|
|
30
43
|
return sourceFileNode;
|
|
31
44
|
}
|
|
45
|
+
visitImportDirective(ctx) {
|
|
46
|
+
const raw = ctx.StringLiteral().getText();
|
|
47
|
+
const importNode = new ImportNode(raw.substring(1, raw.length - 1));
|
|
48
|
+
importNode.location = Location.fromCtx(ctx);
|
|
49
|
+
return importNode;
|
|
50
|
+
}
|
|
32
51
|
processPragma(ctx) {
|
|
33
52
|
const pragmaName = getPragmaName(ctx.pragmaName().getText());
|
|
34
53
|
if (pragmaName !== PragmaName.CASHSCRIPT)
|
|
@@ -46,16 +65,24 @@ export default class AstBuilder extends ParseTreeVisitor {
|
|
|
46
65
|
visitContractDefinition(ctx) {
|
|
47
66
|
const name = ctx.Identifier().getText();
|
|
48
67
|
const parameters = ctx.parameterList().parameter_list().map((p) => this.visit(p));
|
|
49
|
-
const functions = ctx.
|
|
68
|
+
const functions = ctx.contractFunctionDefinition_list()
|
|
69
|
+
.map((f) => this.visit(f));
|
|
50
70
|
const contract = new ContractNode(name, parameters, functions);
|
|
51
71
|
contract.location = Location.fromCtx(ctx);
|
|
52
72
|
return contract;
|
|
53
73
|
}
|
|
54
|
-
|
|
74
|
+
visitContractFunctionDefinition(ctx) {
|
|
75
|
+
return this.buildFunctionDefinition(ctx, FunctionKind.CONTRACT);
|
|
76
|
+
}
|
|
77
|
+
visitGlobalFunctionDefinition(ctx) {
|
|
78
|
+
const returnType = ctx.typeName() ? parseType(ctx.typeName().getText()) : undefined;
|
|
79
|
+
return this.buildFunctionDefinition(ctx, FunctionKind.GLOBAL, returnType);
|
|
80
|
+
}
|
|
81
|
+
buildFunctionDefinition(ctx, kind, returnType) {
|
|
55
82
|
const name = ctx.Identifier().getText();
|
|
56
83
|
const parameters = ctx.parameterList().parameter_list().map((p) => this.visit(p));
|
|
57
84
|
const body = this.visit(ctx.functionBody());
|
|
58
|
-
const functionDefinition = new FunctionDefinitionNode(name, parameters, body);
|
|
85
|
+
const functionDefinition = new FunctionDefinitionNode(kind, name, parameters, body, returnType);
|
|
59
86
|
functionDefinition.location = Location.fromCtx(ctx);
|
|
60
87
|
return functionDefinition;
|
|
61
88
|
}
|
|
@@ -151,6 +178,18 @@ export default class AstBuilder extends ParseTreeVisitor {
|
|
|
151
178
|
require.location = Location.fromCtx(ctx);
|
|
152
179
|
return require;
|
|
153
180
|
}
|
|
181
|
+
visitReturnStatement(ctx) {
|
|
182
|
+
const expression = this.visit(ctx.expression());
|
|
183
|
+
const returnNode = new ReturnNode(expression);
|
|
184
|
+
returnNode.location = Location.fromCtx(ctx);
|
|
185
|
+
return returnNode;
|
|
186
|
+
}
|
|
187
|
+
visitFunctionCallStatement(ctx) {
|
|
188
|
+
const functionCall = this.visit(ctx.functionCall());
|
|
189
|
+
const node = new FunctionCallStatementNode(functionCall);
|
|
190
|
+
node.location = Location.fromCtx(ctx);
|
|
191
|
+
return node;
|
|
192
|
+
}
|
|
154
193
|
visitIfStatement(ctx) {
|
|
155
194
|
const condition = this.visit(ctx.expression());
|
|
156
195
|
const ifBlock = this.visit(ctx._ifBlock);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Node, SourceFileNode, ContractNode, ParameterNode, VariableDefinitionNode, FunctionDefinitionNode, AssignNode, IdentifierNode, BranchNode, CastNode, FunctionCallNode, UnaryOpNode, BinaryOpNode, BoolLiteralNode, IntLiteralNode, HexLiteralNode, StringLiteralNode, BlockNode, TimeOpNode, ArrayNode, TupleIndexOpNode, RequireNode, InstantiationNode, TupleAssignmentNode, NullaryOpNode, ConsoleStatementNode, SliceNode, DoWhileNode, WhileNode, ForNode } from './AST.js';
|
|
1
|
+
import { Node, SourceFileNode, ImportNode, ContractNode, ParameterNode, VariableDefinitionNode, FunctionDefinitionNode, AssignNode, IdentifierNode, BranchNode, CastNode, FunctionCallNode, UnaryOpNode, BinaryOpNode, BoolLiteralNode, IntLiteralNode, HexLiteralNode, StringLiteralNode, BlockNode, TimeOpNode, ArrayNode, TupleIndexOpNode, RequireNode, ReturnNode, InstantiationNode, TupleAssignmentNode, NullaryOpNode, ConsoleStatementNode, FunctionCallStatementNode, SliceNode, DoWhileNode, WhileNode, ForNode } from './AST.js';
|
|
2
2
|
import AstVisitor from './AstVisitor.js';
|
|
3
3
|
export default class AstTraversal extends AstVisitor<Node> {
|
|
4
4
|
visitSourceFile(node: SourceFileNode): Node;
|
|
5
|
+
visitImport(node: ImportNode): Node;
|
|
5
6
|
visitContract(node: ContractNode): Node;
|
|
6
7
|
visitFunctionDefinition(node: FunctionDefinitionNode): Node;
|
|
7
8
|
visitParameter(node: ParameterNode): Node;
|
|
@@ -10,7 +11,9 @@ export default class AstTraversal extends AstVisitor<Node> {
|
|
|
10
11
|
visitAssign(node: AssignNode): Node;
|
|
11
12
|
visitTimeOp(node: TimeOpNode): Node;
|
|
12
13
|
visitRequire(node: RequireNode): Node;
|
|
14
|
+
visitReturn(node: ReturnNode): Node;
|
|
13
15
|
visitConsoleStatement(node: ConsoleStatementNode): Node;
|
|
16
|
+
visitFunctionCallStatement(node: FunctionCallStatementNode): Node;
|
|
14
17
|
visitBranch(node: BranchNode): Node;
|
|
15
18
|
visitDoWhile(node: DoWhileNode): Node;
|
|
16
19
|
visitWhile(node: WhileNode): Node;
|
package/dist/ast/AstTraversal.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import AstVisitor from './AstVisitor.js';
|
|
2
2
|
export default class AstTraversal extends AstVisitor {
|
|
3
3
|
visitSourceFile(node) {
|
|
4
|
-
node.
|
|
4
|
+
node.functions = this.visitList(node.functions);
|
|
5
|
+
node.contract = this.visitOptional(node.contract);
|
|
6
|
+
return node;
|
|
7
|
+
}
|
|
8
|
+
visitImport(node) {
|
|
5
9
|
return node;
|
|
6
10
|
}
|
|
7
11
|
visitContract(node) {
|
|
@@ -38,10 +42,18 @@ export default class AstTraversal extends AstVisitor {
|
|
|
38
42
|
node.expression = this.visit(node.expression);
|
|
39
43
|
return node;
|
|
40
44
|
}
|
|
45
|
+
visitReturn(node) {
|
|
46
|
+
node.expression = this.visit(node.expression);
|
|
47
|
+
return node;
|
|
48
|
+
}
|
|
41
49
|
visitConsoleStatement(node) {
|
|
42
50
|
node.parameters = this.visitList(node.parameters);
|
|
43
51
|
return node;
|
|
44
52
|
}
|
|
53
|
+
visitFunctionCallStatement(node) {
|
|
54
|
+
node.functionCall = this.visit(node.functionCall);
|
|
55
|
+
return node;
|
|
56
|
+
}
|
|
45
57
|
visitBranch(node) {
|
|
46
58
|
node.condition = this.visit(node.condition);
|
|
47
59
|
node.ifBlock = this.visit(node.ifBlock);
|
package/dist/ast/AstVisitor.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Node, SourceFileNode, ContractNode, ParameterNode, VariableDefinitionNode, FunctionDefinitionNode, AssignNode, IdentifierNode, BranchNode, CastNode, FunctionCallNode, UnaryOpNode, BinaryOpNode, BoolLiteralNode, IntLiteralNode, HexLiteralNode, StringLiteralNode, BlockNode, TimeOpNode, ArrayNode, TupleIndexOpNode, RequireNode, InstantiationNode, TupleAssignmentNode, NullaryOpNode, ConsoleStatementNode, SliceNode, DoWhileNode, WhileNode, ForNode } from './AST.js';
|
|
1
|
+
import { Node, SourceFileNode, ImportNode, ContractNode, ParameterNode, VariableDefinitionNode, FunctionDefinitionNode, AssignNode, IdentifierNode, BranchNode, CastNode, FunctionCallNode, UnaryOpNode, BinaryOpNode, BoolLiteralNode, IntLiteralNode, HexLiteralNode, StringLiteralNode, BlockNode, TimeOpNode, ArrayNode, TupleIndexOpNode, RequireNode, ReturnNode, InstantiationNode, TupleAssignmentNode, NullaryOpNode, ConsoleStatementNode, FunctionCallStatementNode, SliceNode, DoWhileNode, WhileNode, ForNode } from './AST.js';
|
|
2
2
|
export default abstract class AstVisitor<T> {
|
|
3
3
|
abstract visitSourceFile(node: SourceFileNode): T;
|
|
4
|
+
abstract visitImport(node: ImportNode): T;
|
|
4
5
|
abstract visitContract(node: ContractNode): T;
|
|
5
6
|
abstract visitFunctionDefinition(node: FunctionDefinitionNode): T;
|
|
6
7
|
abstract visitParameter(node: ParameterNode): T;
|
|
@@ -9,7 +10,9 @@ export default abstract class AstVisitor<T> {
|
|
|
9
10
|
abstract visitAssign(node: AssignNode): T;
|
|
10
11
|
abstract visitTimeOp(node: TimeOpNode): T;
|
|
11
12
|
abstract visitRequire(node: RequireNode): T;
|
|
13
|
+
abstract visitReturn(node: ReturnNode): T;
|
|
12
14
|
abstract visitConsoleStatement(node: ConsoleStatementNode): T;
|
|
15
|
+
abstract visitFunctionCallStatement(node: FunctionCallStatementNode): T;
|
|
13
16
|
abstract visitBranch(node: BranchNode): T;
|
|
14
17
|
abstract visitDoWhile(node: DoWhileNode): T;
|
|
15
18
|
abstract visitWhile(node: WhileNode): T;
|
package/dist/ast/Globals.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PrimitiveType, ArrayType, BytesType } from '@cashscript/utils';
|
|
1
|
+
import { PrimitiveType, ArrayType, BytesType, Op } from '@cashscript/utils';
|
|
2
2
|
import { SymbolTable, Symbol } from './SymbolTable.js';
|
|
3
3
|
export const NumberUnit = {
|
|
4
4
|
SATOSHIS: 1,
|
|
@@ -51,17 +51,30 @@ GLOBAL_SYMBOL_TABLE.set(Symbol.class(Class.LOCKING_BYTECODE_P2SH32, new BytesTyp
|
|
|
51
51
|
GLOBAL_SYMBOL_TABLE.set(Symbol.class(Class.LOCKING_BYTECODE_P2PKH, new BytesType(25), [new BytesType(20)]));
|
|
52
52
|
GLOBAL_SYMBOL_TABLE.set(Symbol.class(Class.LOCKING_BYTECODE_NULLDATA, new BytesType(), [new ArrayType(new BytesType())]));
|
|
53
53
|
// Global functions
|
|
54
|
-
|
|
55
|
-
GLOBAL_SYMBOL_TABLE.set(Symbol.
|
|
56
|
-
|
|
57
|
-
GLOBAL_SYMBOL_TABLE.set(Symbol.
|
|
58
|
-
|
|
59
|
-
GLOBAL_SYMBOL_TABLE.set(Symbol.
|
|
60
|
-
|
|
61
|
-
GLOBAL_SYMBOL_TABLE.set(Symbol.
|
|
62
|
-
|
|
63
|
-
GLOBAL_SYMBOL_TABLE.set(Symbol.
|
|
64
|
-
|
|
65
|
-
GLOBAL_SYMBOL_TABLE.set(Symbol.
|
|
66
|
-
|
|
54
|
+
// abs(int) -> int
|
|
55
|
+
GLOBAL_SYMBOL_TABLE.set(Symbol.builtinFunction(GlobalFunction.ABS, PrimitiveType.INT, [PrimitiveType.INT], [Op.OP_ABS]));
|
|
56
|
+
// min(int, int) -> int
|
|
57
|
+
GLOBAL_SYMBOL_TABLE.set(Symbol.builtinFunction(GlobalFunction.MIN, PrimitiveType.INT, [PrimitiveType.INT, PrimitiveType.INT], [Op.OP_MIN]));
|
|
58
|
+
// max(int, int) -> int
|
|
59
|
+
GLOBAL_SYMBOL_TABLE.set(Symbol.builtinFunction(GlobalFunction.MAX, PrimitiveType.INT, [PrimitiveType.INT, PrimitiveType.INT], [Op.OP_MAX]));
|
|
60
|
+
// within(int, int, int) -> bool
|
|
61
|
+
GLOBAL_SYMBOL_TABLE.set(Symbol.builtinFunction(GlobalFunction.WITHIN, PrimitiveType.BOOL, [PrimitiveType.INT, PrimitiveType.INT, PrimitiveType.INT], [Op.OP_WITHIN]));
|
|
62
|
+
// ripemd160(any) -> bytes20
|
|
63
|
+
GLOBAL_SYMBOL_TABLE.set(Symbol.builtinFunction(GlobalFunction.RIPEMD160, new BytesType(20), [PrimitiveType.ANY], [Op.OP_RIPEMD160]));
|
|
64
|
+
// sha1(any) -> bytes20
|
|
65
|
+
GLOBAL_SYMBOL_TABLE.set(Symbol.builtinFunction(GlobalFunction.SHA1, new BytesType(20), [PrimitiveType.ANY], [Op.OP_SHA1]));
|
|
66
|
+
// sha256(any) -> bytes32
|
|
67
|
+
GLOBAL_SYMBOL_TABLE.set(Symbol.builtinFunction(GlobalFunction.SHA256, new BytesType(32), [PrimitiveType.ANY], [Op.OP_SHA256]));
|
|
68
|
+
// hash160(any) -> bytes20
|
|
69
|
+
GLOBAL_SYMBOL_TABLE.set(Symbol.builtinFunction(GlobalFunction.HASH160, new BytesType(20), [PrimitiveType.ANY], [Op.OP_HASH160]));
|
|
70
|
+
// hash256(any) -> bytes32
|
|
71
|
+
GLOBAL_SYMBOL_TABLE.set(Symbol.builtinFunction(GlobalFunction.HASH256, new BytesType(32), [PrimitiveType.ANY], [Op.OP_HASH256]));
|
|
72
|
+
// checkSig(sig, pubkey) -> bool
|
|
73
|
+
GLOBAL_SYMBOL_TABLE.set(Symbol.builtinFunction(GlobalFunction.CHECKSIG, PrimitiveType.BOOL, [PrimitiveType.SIG, PrimitiveType.PUBKEY], [Op.OP_CHECKSIG]));
|
|
74
|
+
// checkMultiSig(sig[], pubkey[]) -> bool
|
|
75
|
+
GLOBAL_SYMBOL_TABLE.set(Symbol.builtinFunction(GlobalFunction.CHECKMULTISIG, PrimitiveType.BOOL, [new ArrayType(PrimitiveType.SIG), new ArrayType(PrimitiveType.PUBKEY)], [Op.OP_CHECKMULTISIG]));
|
|
76
|
+
// checkDataSig(datasig, bytes, pubkey) -> bool
|
|
77
|
+
GLOBAL_SYMBOL_TABLE.set(Symbol.builtinFunction(GlobalFunction.CHECKDATASIG, PrimitiveType.BOOL, [PrimitiveType.DATASIG, new BytesType(), PrimitiveType.PUBKEY], [Op.OP_CHECKDATASIG]));
|
|
78
|
+
// toPaddedBytes(int, int) -> bytes
|
|
79
|
+
GLOBAL_SYMBOL_TABLE.set(Symbol.builtinFunction(GlobalFunction.TO_PADDED_BYTES, new BytesType(), [PrimitiveType.INT, PrimitiveType.INT], [Op.OP_NUM2BIN]));
|
|
67
80
|
//# sourceMappingURL=Globals.js.map
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import { Type } from '@cashscript/utils';
|
|
2
|
-
import { VariableDefinitionNode, ParameterNode, IdentifierNode, Node } from './AST.js';
|
|
1
|
+
import { Type, Script } from '@cashscript/utils';
|
|
2
|
+
import { VariableDefinitionNode, ParameterNode, FunctionDefinitionNode, IdentifierNode, Node } from './AST.js';
|
|
3
3
|
export declare class Symbol {
|
|
4
4
|
name: string;
|
|
5
5
|
type: Type;
|
|
6
6
|
symbolType: SymbolType;
|
|
7
7
|
definition?: Node | undefined;
|
|
8
8
|
parameters?: Type[] | undefined;
|
|
9
|
+
bytecode?: Script | undefined;
|
|
10
|
+
functionId?: number | undefined;
|
|
9
11
|
references: IdentifierNode[];
|
|
10
12
|
private constructor();
|
|
11
13
|
static variable(node: VariableDefinitionNode | ParameterNode): Symbol;
|
|
12
14
|
static global(name: string, type: Type): Symbol;
|
|
13
|
-
static
|
|
15
|
+
static builtinFunction(name: string, returnType: Type, parameters: Type[], bytecode: Script): Symbol;
|
|
16
|
+
static userFunction(node: FunctionDefinitionNode, functionId: number): Symbol;
|
|
17
|
+
setFunctionId(functionId: number): void;
|
|
14
18
|
static class(name: string, type: Type, parameters: Type[]): Symbol;
|
|
15
19
|
toString(): string;
|
|
16
20
|
}
|
package/dist/ast/SymbolTable.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import { PrimitiveType, Op, encodeInt } from '@cashscript/utils';
|
|
1
2
|
export class Symbol {
|
|
2
|
-
constructor(name, type, symbolType, definition, parameters) {
|
|
3
|
+
constructor(name, type, symbolType, definition, parameters, bytecode, functionId) {
|
|
3
4
|
this.name = name;
|
|
4
5
|
this.type = type;
|
|
5
6
|
this.symbolType = symbolType;
|
|
6
7
|
this.definition = definition;
|
|
7
8
|
this.parameters = parameters;
|
|
9
|
+
this.bytecode = bytecode;
|
|
10
|
+
this.functionId = functionId;
|
|
8
11
|
this.references = [];
|
|
9
12
|
}
|
|
10
13
|
static variable(node) {
|
|
@@ -13,8 +16,19 @@ export class Symbol {
|
|
|
13
16
|
static global(name, type) {
|
|
14
17
|
return new Symbol(name, type, SymbolType.VARIABLE);
|
|
15
18
|
}
|
|
16
|
-
static
|
|
17
|
-
return new Symbol(name,
|
|
19
|
+
static builtinFunction(name, returnType, parameters, bytecode) {
|
|
20
|
+
return new Symbol(name, returnType, SymbolType.FUNCTION, undefined, parameters, bytecode);
|
|
21
|
+
}
|
|
22
|
+
static userFunction(node, functionId) {
|
|
23
|
+
const parameterTypes = node.parameters.map((parameter) => parameter.type);
|
|
24
|
+
const returnType = node.returnType ?? PrimitiveType.VOID;
|
|
25
|
+
const symbol = new Symbol(node.name, returnType, SymbolType.FUNCTION, node, parameterTypes);
|
|
26
|
+
symbol.setFunctionId(functionId);
|
|
27
|
+
return symbol;
|
|
28
|
+
}
|
|
29
|
+
setFunctionId(functionId) {
|
|
30
|
+
this.functionId = functionId;
|
|
31
|
+
this.bytecode = [encodeInt(BigInt(functionId)), Op.OP_INVOKE];
|
|
18
32
|
}
|
|
19
33
|
static class(name, type, parameters) {
|
|
20
34
|
return new Symbol(name, type, SymbolType.CLASS, undefined, parameters);
|
package/dist/compiler.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Artifact, CompilerOptions } from '@cashscript/utils';
|
|
2
2
|
import { PathLike } from 'fs';
|
|
3
|
-
import { Ast } from './ast/AST.js';
|
|
4
3
|
import { CashScriptErrorListener } from './ast/error-listeners.js';
|
|
5
4
|
export declare const DEFAULT_COMPILER_OPTIONS: CompilerOptions;
|
|
6
5
|
export interface CompileOptions extends CompilerOptions {
|
|
7
6
|
errorListener?: CashScriptErrorListener;
|
|
7
|
+
basePath?: string;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* Compile a CashScript source string to an {@link Artifact}.
|
|
@@ -24,4 +24,3 @@ export declare function compileString(code: string, compilerOptions?: CompileOpt
|
|
|
24
24
|
* @throws If the file cannot be read, or if the source contains a compilation error.
|
|
25
25
|
*/
|
|
26
26
|
export declare function compileFile(codeFile: PathLike, compilerOptions?: CompileOptions): Artifact;
|
|
27
|
-
export declare function parseCode(code: string, errorListener?: CashScriptErrorListener): Ast;
|