Skip to content

Commit 69dd6e3

Browse files
committed
Assembly AST statements
1 parent 20e591f commit 69dd6e3

14 files changed

+9246
-592
lines changed

ast/assembly.proto

-12
This file was deleted.

ast/types.proto

+2
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ enum NodeType {
126126
YUL_IF = 120;
127127
YUL_FUNCTION_DEFINITION = 121;
128128
YUL_VARIABLE_DECLARATION = 122;
129+
YUL_EXPRESSION = 123;
130+
HEX_NUMBER = 124;
129131
}
130132

131133
enum Mutability {

ast/yul.proto

+154
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
syntax = "proto3";
2+
option go_package = "github.com/unpackdev/protos/dist/go/ast;ast_pb";
3+
package unpack.v1.ast;
4+
5+
import "ast/types.proto";
6+
import "ast/src.proto";
7+
import "ast/body.proto";
8+
import "xds/type/v3/typed_struct.proto";
9+
10+
// AssemblyStatement represents a higher-level assembly statement.
11+
message AssemblyStatement {
12+
int64 id = 1; // Unique identifier for the assembly statement.
13+
unpack.v1.ast.NodeType node_type = 2; // The type of the node.
14+
unpack.v1.ast.Src src = 3; // Source information for the assembly statement.
15+
unpack.v1.ast.Body body = 4; // The body of the assembly statement.
16+
}
17+
18+
// YulBlockStatement represents a Yul block of statements.
19+
message YulBlockStatement {
20+
int64 id = 1; // Unique identifier for the Yul block statement.
21+
unpack.v1.ast.NodeType node_type = 2; // The type of the node.
22+
unpack.v1.ast.Src src = 3; // Source information for the Yul block statement.
23+
repeated xds.type.v3.TypedStruct statements = 4; // The statements within the block.
24+
}
25+
26+
// YulStatement represents an individual Yul statement.
27+
message YulStatement {
28+
int64 id = 1; // Unique identifier for the Yul statement.
29+
unpack.v1.ast.NodeType node_type = 2; // The type of the node.
30+
unpack.v1.ast.Src src = 3; // Source information for the Yul statement.
31+
repeated xds.type.v3.TypedStruct statements = 4; // Any sub-statements or expressions associated with this statement.
32+
}
33+
34+
// YulIdentifier represents an identifier in the Yul language.
35+
message YulIdentifier {
36+
int64 id = 1; // Unique identifier for the identifier.
37+
unpack.v1.ast.NodeType node_type = 2; // The type of the node.
38+
unpack.v1.ast.Src src = 3; // Source information for the identifier.
39+
string name = 4; // The name of the identifier.
40+
}
41+
42+
// YulVariableStatement represents a variable declaration in Yul.
43+
message YulVariableStatement {
44+
int64 id = 1; // Unique identifier for the variable statement.
45+
unpack.v1.ast.NodeType node_type = 2; // The type of the node.
46+
unpack.v1.ast.Src src = 3; // Source information for the variable statement.
47+
bool let = 4; // Specifies if it's a "let" declaration.
48+
xds.type.v3.TypedStruct value = 5; // The value assigned to the variable.
49+
repeated xds.type.v3.TypedStruct variables = 6; // List of variables declared.
50+
}
51+
52+
// YulSwitchCaseStatement represents a case within a Yul switch statement.
53+
message YulSwitchCaseStatement {
54+
int64 id = 1; // Unique identifier for the case statement.
55+
unpack.v1.ast.NodeType node_type = 2; // The type of the node.
56+
unpack.v1.ast.Src src = 3; // Source information for the case statement.
57+
xds.type.v3.TypedStruct case = 4; // The case value.
58+
xds.type.v3.TypedStruct body = 5; // The body of the case.
59+
}
60+
61+
// YulSwitchStatement represents a switch statement in Yul.
62+
message YulSwitchStatement {
63+
int64 id = 1; // Unique identifier for the switch statement.
64+
unpack.v1.ast.NodeType node_type = 2; // The type of the node.
65+
unpack.v1.ast.Src src = 3; // Source information for the switch statement.
66+
repeated unpack.v1.ast.YulSwitchCaseStatement cases = 4; // The list of cases for the switch statement.
67+
}
68+
69+
// YulLiteralStatement represents a literal value in Yul.
70+
message YulLiteralStatement {
71+
int64 id = 1; // Unique identifier for the literal.
72+
unpack.v1.ast.NodeType node_type = 2; // The type of the node.
73+
unpack.v1.ast.NodeType kind = 3; // The kind of the literal (e.g., string, number).
74+
unpack.v1.ast.Src src = 4; // Source information for the literal.
75+
string value = 5; // The literal value as a string.
76+
string hex_value = 6; // The literal value as a hexadecimal string.
77+
}
78+
79+
// YulLeaveStatement represents a "leave" statement in Yul.
80+
message YulLeaveStatement {
81+
int64 id = 1; // Unique identifier for the leave statement.
82+
unpack.v1.ast.NodeType node_type = 2; // The type of the node.
83+
unpack.v1.ast.Src src = 3; // Source information for the leave statement.
84+
}
85+
86+
// YulBreakStatement represents a "break" statement in Yul.
87+
message YulBreakStatement {
88+
int64 id = 1; // Unique identifier for the break statement.
89+
unpack.v1.ast.NodeType node_type = 2; // The type of the node.
90+
unpack.v1.ast.Src src = 3; // Source information for the break statement.
91+
}
92+
93+
// YulContinueStatement represents a "continue" statement in Yul.
94+
message YulContinueStatement {
95+
int64 id = 1; // Unique identifier for the continue statement.
96+
unpack.v1.ast.NodeType node_type = 2; // The type of the node.
97+
unpack.v1.ast.Src src = 3; // Source information for the continue statement.
98+
}
99+
100+
// YulIfStatement represents an "if" statement in Yul.
101+
message YulIfStatement {
102+
int64 id = 1; // Unique identifier for the if statement.
103+
unpack.v1.ast.NodeType node_type = 2; // The type of the node.
104+
unpack.v1.ast.Src src = 3; // Source information for the if statement.
105+
xds.type.v3.TypedStruct condition = 4; // The condition of the if statement.
106+
xds.type.v3.TypedStruct body = 5; // The body of the if statement.
107+
}
108+
109+
// YulFunctionDefinition represents a function definition in Yul.
110+
message YulFunctionDefinition {
111+
int64 id = 1; // Unique identifier for the function definition.
112+
unpack.v1.ast.NodeType node_type = 2; // The type of the node.
113+
unpack.v1.ast.Src src = 3; // Source information for the function definition.
114+
repeated xds.type.v3.TypedStruct arguments = 4; // The arguments of the function.
115+
xds.type.v3.TypedStruct body = 5; // The body of the function.
116+
repeated xds.type.v3.TypedStruct return_parameters = 6; // The return parameters of the function.
117+
}
118+
119+
// YulFunctionCallStatement represents a function call in Yul.
120+
message YulFunctionCallStatement {
121+
int64 id = 1; // Unique identifier for the function call statement.
122+
unpack.v1.ast.NodeType node_type = 2; // The type of the node.
123+
unpack.v1.ast.Src src = 3; // Source information for the function call statement.
124+
xds.type.v3.TypedStruct function_name = 4; // The name of the function being called.
125+
repeated xds.type.v3.TypedStruct arguments = 5; // The arguments passed to the function.
126+
}
127+
128+
// YulAssignmentStatement represents an assignment operation in Yul.
129+
message YulAssignmentStatement {
130+
int64 id = 1; // Unique identifier for the assignment statement.
131+
unpack.v1.ast.NodeType node_type = 2; // The type of the node.
132+
unpack.v1.ast.Src src = 3; // Source information for the assignment statement.
133+
repeated xds.type.v3.TypedStruct variable_names = 4; // The variables being assigned to.
134+
xds.type.v3.TypedStruct value = 5; // The value being assigned.
135+
}
136+
137+
// YulExpressionStatement represents an expression in Yul.
138+
message YulExpressionStatement {
139+
int64 id = 1; // Unique identifier for the expression statement.
140+
unpack.v1.ast.NodeType node_type = 2; // The type of the node.
141+
unpack.v1.ast.Src src = 3; // Source information for the expression statement.
142+
xds.type.v3.TypedStruct expression = 4; // The expression itself.
143+
}
144+
145+
// YulForStatement represents a "for" loop in Yul.
146+
message YulForStatement {
147+
int64 id = 1; // Unique identifier for the for statement.
148+
unpack.v1.ast.NodeType node_type = 2; // The type of the node.
149+
unpack.v1.ast.Src src = 3; // Source information for the for statement.
150+
xds.type.v3.TypedStruct pre = 4; // Initialization part of the for loop.
151+
xds.type.v3.TypedStruct post = 5; // Increment/decrement part of the for loop.
152+
xds.type.v3.TypedStruct condition = 6; // Condition of the for loop.
153+
xds.type.v3.TypedStruct body = 7; // The body of the for loop.
154+
}

0 commit comments

Comments
 (0)