@ball-lang/encoder 0.1.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/encoder.d.ts +42 -0
- package/dist/encoder.d.ts.map +1 -0
- package/dist/encoder.js +895 -0
- package/dist/encoder.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +103 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +57 -0
- package/src/encoder.ts +969 -0
- package/src/index.ts +3 -0
- package/src/types.ts +107 -0
package/src/index.ts
ADDED
package/src/types.ts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
export interface Program {
|
|
2
|
+
name?: string;
|
|
3
|
+
version?: string;
|
|
4
|
+
modules: Module[];
|
|
5
|
+
entryModule: string;
|
|
6
|
+
entryFunction: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface Module {
|
|
10
|
+
name: string;
|
|
11
|
+
functions: FunctionDef[];
|
|
12
|
+
typeDefs?: TypeDefinition[];
|
|
13
|
+
typeAliases?: TypeAlias[];
|
|
14
|
+
enums?: EnumDef[];
|
|
15
|
+
metadata?: Struct;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface FunctionDef {
|
|
19
|
+
name: string;
|
|
20
|
+
isBase?: boolean;
|
|
21
|
+
body?: Expression;
|
|
22
|
+
inputType?: string;
|
|
23
|
+
outputType?: string;
|
|
24
|
+
metadata?: Struct;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface TypeDefinition {
|
|
28
|
+
name: string;
|
|
29
|
+
descriptor?: DescriptorProto;
|
|
30
|
+
description?: string;
|
|
31
|
+
metadata?: Struct;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface TypeAlias {
|
|
35
|
+
name: string;
|
|
36
|
+
targetType: string;
|
|
37
|
+
metadata?: Struct;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface EnumDef {
|
|
41
|
+
name: string;
|
|
42
|
+
values: EnumValue[];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface EnumValue {
|
|
46
|
+
name: string;
|
|
47
|
+
intValue?: string | number;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface DescriptorProto {
|
|
51
|
+
name: string;
|
|
52
|
+
field?: FieldDescriptor[];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface FieldDescriptor {
|
|
56
|
+
name: string;
|
|
57
|
+
number?: number;
|
|
58
|
+
type?: string;
|
|
59
|
+
label?: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface Expression {
|
|
63
|
+
call?: FunctionCall;
|
|
64
|
+
literal?: Literal;
|
|
65
|
+
reference?: { name: string };
|
|
66
|
+
fieldAccess?: { object: Expression; field: string };
|
|
67
|
+
messageCreation?: MessageCreation;
|
|
68
|
+
block?: Block;
|
|
69
|
+
lambda?: FunctionDef;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface FunctionCall {
|
|
73
|
+
module?: string;
|
|
74
|
+
function: string;
|
|
75
|
+
input?: Expression;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface Literal {
|
|
79
|
+
intValue?: string | number;
|
|
80
|
+
doubleValue?: number;
|
|
81
|
+
stringValue?: string;
|
|
82
|
+
boolValue?: boolean;
|
|
83
|
+
listValue?: { elements: Expression[] };
|
|
84
|
+
bytesValue?: string;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface MessageCreation {
|
|
88
|
+
typeName?: string;
|
|
89
|
+
fields: FieldValuePair[];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface FieldValuePair {
|
|
93
|
+
name: string;
|
|
94
|
+
value: Expression;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface Block {
|
|
98
|
+
statements: Statement[];
|
|
99
|
+
result?: Expression;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface Statement {
|
|
103
|
+
let?: { name: string; value?: Expression; metadata?: Struct };
|
|
104
|
+
expression?: Expression;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export type Struct = Record<string, unknown>;
|