Skip to content

Commit a909104

Browse files
authored
Group Fixes No.2 (#132)
* foobar * Finally works
1 parent 14fded3 commit a909104

File tree

422 files changed

+589300
-633064
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

422 files changed

+589300
-633064
lines changed

abi/state_variable.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package abi
22

33
import (
44
"github.com/unpackdev/solgo/ir"
5+
"github.com/unpackdev/solgo/utils"
56
)
67

78
// processStateVariable processes the provided StateVariable from the IR and constructs a Method representation.
@@ -16,6 +17,10 @@ func (b *Builder) processStateVariable(stateVar *ir.StateVariable) *Method {
1617
StateMutability: b.normalizeStateMutability(stateVar.GetStateMutability()),
1718
}
1819

20+
if stateVar.GetTypeDescription() == nil {
21+
utils.DumpNodeWithExit(stateVar)
22+
}
23+
1924
typeName := b.resolver.ResolveType(stateVar.GetTypeDescription())
2025

2126
switch typeName {

ast/and_operation.go

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -154,41 +154,23 @@ func (f *AndOperation) Parse(
154154
bodyNode *BodyNode,
155155
vDeclar *VariableDeclaration,
156156
expNode Node[NodeType],
157+
parentNodeId int64,
157158
ctx *parser.AndOperationContext,
158159
) Node[NodeType] {
159160
f.Id = f.GetNextID()
160161
f.Src = SrcNode{
161-
Id: f.GetNextID(),
162-
Line: int64(ctx.GetStart().GetLine()),
163-
Column: int64(ctx.GetStart().GetColumn()),
164-
Start: int64(ctx.GetStart().GetStart()),
165-
End: int64(ctx.GetStop().GetStop()),
166-
Length: int64(ctx.GetStop().GetStop() - ctx.GetStart().GetStart() + 1),
167-
ParentIndex: func() int64 {
168-
if vDeclar != nil {
169-
return vDeclar.GetId()
170-
}
171-
172-
if expNode != nil {
173-
return expNode.GetId()
174-
}
175-
176-
if bodyNode != nil {
177-
return bodyNode.GetId()
178-
}
179-
180-
if fnNode != nil {
181-
return fnNode.GetId()
182-
}
183-
184-
return contractNode.GetId()
185-
}(),
162+
Line: int64(ctx.GetStart().GetLine()),
163+
Column: int64(ctx.GetStart().GetColumn()),
164+
Start: int64(ctx.GetStart().GetStart()),
165+
End: int64(ctx.GetStop().GetStop()),
166+
Length: int64(ctx.GetStop().GetStop() - ctx.GetStart().GetStart() + 1),
167+
ParentIndex: parentNodeId,
186168
}
187169

188170
expression := NewExpression(f.ASTBuilder)
189171

190172
for _, expr := range ctx.AllExpression() {
191-
parsedExp := expression.Parse(unit, contractNode, fnNode, bodyNode, vDeclar, f, expr)
173+
parsedExp := expression.Parse(unit, contractNode, fnNode, bodyNode, vDeclar, f, f.GetId(), expr)
192174
f.Expressions = append(
193175
f.Expressions,
194176
parsedExp,

ast/assignment.go

Lines changed: 17 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -283,36 +283,22 @@ func (a *Assignment) ParseStatement(
283283
bodyNode *BodyNode,
284284
parentNode Node[NodeType],
285285
eCtx *parser.ExpressionStatementContext,
286+
parentNodeId int64,
286287
ctx *parser.AssignmentContext,
287288
) {
288289
// Setting the source location information.
289290
a.Src = SrcNode{
290-
Id: a.GetNextID(),
291-
Line: int64(eCtx.GetStart().GetLine()),
292-
Column: int64(eCtx.GetStart().GetColumn()),
293-
Start: int64(eCtx.GetStart().GetStart()),
294-
End: int64(eCtx.GetStop().GetStop()),
295-
Length: int64(eCtx.GetStop().GetStop() - eCtx.GetStart().GetStart() + 1),
296-
ParentIndex: func() int64 {
297-
if parentNode != nil {
298-
return parentNode.GetId()
299-
}
300-
301-
if bodyNode != nil {
302-
return bodyNode.GetId()
303-
}
304-
305-
if fnNode != nil {
306-
return fnNode.GetId()
307-
}
308-
309-
return contractNode.GetId()
310-
}(),
291+
Line: int64(eCtx.GetStart().GetLine()),
292+
Column: int64(eCtx.GetStart().GetColumn()),
293+
Start: int64(eCtx.GetStart().GetStart()),
294+
End: int64(eCtx.GetStop().GetStop()),
295+
Length: int64(eCtx.GetStop().GetStop() - eCtx.GetStart().GetStart() + 1),
296+
ParentIndex: parentNodeId,
311297
}
312298

313299
// Parsing the expression and setting the type description.
314300
expression := NewExpression(a.ASTBuilder)
315-
a.Expression = expression.Parse(unit, contractNode, fnNode, bodyNode, nil, nil, ctx)
301+
a.Expression = expression.Parse(unit, contractNode, fnNode, bodyNode, nil, a, a.GetId(), ctx)
316302
a.TypeDescription = a.Expression.GetTypeDescription()
317303
}
318304

@@ -324,37 +310,27 @@ func (a *Assignment) Parse(
324310
bodyNode *BodyNode,
325311
vDeclar *VariableDeclaration,
326312
expNode Node[NodeType],
313+
parentNodeId int64,
327314
ctx *parser.AssignmentContext,
328315
) Node[NodeType] {
329316
// Setting the type and source location information.
330317
a.NodeType = ast_pb.NodeType_ASSIGNMENT
331318
a.Src = SrcNode{
332-
Id: a.GetNextID(),
333-
Line: int64(ctx.GetStart().GetLine()),
334-
Column: int64(ctx.GetStart().GetColumn()),
335-
Start: int64(ctx.GetStart().GetStart()),
336-
End: int64(ctx.GetStop().GetStop()),
337-
Length: int64(ctx.GetStop().GetStop() - ctx.GetStart().GetStart() + 1),
338-
ParentIndex: func() int64 {
339-
if expNode != nil {
340-
return expNode.GetId()
341-
}
342-
343-
if vDeclar != nil {
344-
return vDeclar.GetId()
345-
}
346-
347-
return bodyNode.GetId()
348-
}(),
319+
Line: int64(ctx.GetStart().GetLine()),
320+
Column: int64(ctx.GetStart().GetColumn()),
321+
Start: int64(ctx.GetStart().GetStart()),
322+
End: int64(ctx.GetStop().GetStop()),
323+
Length: int64(ctx.GetStop().GetStop() - ctx.GetStart().GetStart() + 1),
324+
ParentIndex: parentNodeId,
349325
}
350326

351327
// Parsing the operator.
352328
a.Operator = parseOperator(ctx.AssignOp())
353329

354330
// Parsing left and right expressions.
355331
expression := NewExpression(a.ASTBuilder)
356-
a.LeftExpression = expression.Parse(unit, contractNode, fnNode, bodyNode, vDeclar, a, ctx.Expression(0))
357-
a.RightExpression = expression.Parse(unit, contractNode, fnNode, bodyNode, vDeclar, a, ctx.Expression(1))
332+
a.LeftExpression = expression.Parse(unit, contractNode, fnNode, bodyNode, vDeclar, a, a.GetId(), ctx.Expression(0))
333+
a.RightExpression = expression.Parse(unit, contractNode, fnNode, bodyNode, vDeclar, a, a.GetId(), ctx.Expression(1))
358334

359335
// Setting the type description based on the left expression.
360336
a.TypeDescription = a.LeftExpression.GetTypeDescription()

0 commit comments

Comments
 (0)