Skip to content

Commit

Permalink
Group Fixes No.2 (#132)
Browse files Browse the repository at this point in the history
* foobar

* Finally works
  • Loading branch information
0x19 authored Oct 23, 2023
1 parent 14fded3 commit a909104
Show file tree
Hide file tree
Showing 422 changed files with 589,300 additions and 633,064 deletions.
5 changes: 5 additions & 0 deletions abi/state_variable.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package abi

import (
"github.com/unpackdev/solgo/ir"
"github.com/unpackdev/solgo/utils"
)

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

if stateVar.GetTypeDescription() == nil {
utils.DumpNodeWithExit(stateVar)
}

typeName := b.resolver.ResolveType(stateVar.GetTypeDescription())

switch typeName {
Expand Down
34 changes: 8 additions & 26 deletions ast/and_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,41 +154,23 @@ func (f *AndOperation) Parse(
bodyNode *BodyNode,
vDeclar *VariableDeclaration,
expNode Node[NodeType],
parentNodeId int64,
ctx *parser.AndOperationContext,
) Node[NodeType] {
f.Id = f.GetNextID()
f.Src = SrcNode{
Id: f.GetNextID(),
Line: int64(ctx.GetStart().GetLine()),
Column: int64(ctx.GetStart().GetColumn()),
Start: int64(ctx.GetStart().GetStart()),
End: int64(ctx.GetStop().GetStop()),
Length: int64(ctx.GetStop().GetStop() - ctx.GetStart().GetStart() + 1),
ParentIndex: func() int64 {
if vDeclar != nil {
return vDeclar.GetId()
}

if expNode != nil {
return expNode.GetId()
}

if bodyNode != nil {
return bodyNode.GetId()
}

if fnNode != nil {
return fnNode.GetId()
}

return contractNode.GetId()
}(),
Line: int64(ctx.GetStart().GetLine()),
Column: int64(ctx.GetStart().GetColumn()),
Start: int64(ctx.GetStart().GetStart()),
End: int64(ctx.GetStop().GetStop()),
Length: int64(ctx.GetStop().GetStop() - ctx.GetStart().GetStart() + 1),
ParentIndex: parentNodeId,
}

expression := NewExpression(f.ASTBuilder)

for _, expr := range ctx.AllExpression() {
parsedExp := expression.Parse(unit, contractNode, fnNode, bodyNode, vDeclar, f, expr)
parsedExp := expression.Parse(unit, contractNode, fnNode, bodyNode, vDeclar, f, f.GetId(), expr)
f.Expressions = append(
f.Expressions,
parsedExp,
Expand Down
58 changes: 17 additions & 41 deletions ast/assignment.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,36 +283,22 @@ func (a *Assignment) ParseStatement(
bodyNode *BodyNode,
parentNode Node[NodeType],
eCtx *parser.ExpressionStatementContext,
parentNodeId int64,
ctx *parser.AssignmentContext,
) {
// Setting the source location information.
a.Src = SrcNode{
Id: a.GetNextID(),
Line: int64(eCtx.GetStart().GetLine()),
Column: int64(eCtx.GetStart().GetColumn()),
Start: int64(eCtx.GetStart().GetStart()),
End: int64(eCtx.GetStop().GetStop()),
Length: int64(eCtx.GetStop().GetStop() - eCtx.GetStart().GetStart() + 1),
ParentIndex: func() int64 {
if parentNode != nil {
return parentNode.GetId()
}

if bodyNode != nil {
return bodyNode.GetId()
}

if fnNode != nil {
return fnNode.GetId()
}

return contractNode.GetId()
}(),
Line: int64(eCtx.GetStart().GetLine()),
Column: int64(eCtx.GetStart().GetColumn()),
Start: int64(eCtx.GetStart().GetStart()),
End: int64(eCtx.GetStop().GetStop()),
Length: int64(eCtx.GetStop().GetStop() - eCtx.GetStart().GetStart() + 1),
ParentIndex: parentNodeId,
}

// Parsing the expression and setting the type description.
expression := NewExpression(a.ASTBuilder)
a.Expression = expression.Parse(unit, contractNode, fnNode, bodyNode, nil, nil, ctx)
a.Expression = expression.Parse(unit, contractNode, fnNode, bodyNode, nil, a, a.GetId(), ctx)
a.TypeDescription = a.Expression.GetTypeDescription()
}

Expand All @@ -324,37 +310,27 @@ func (a *Assignment) Parse(
bodyNode *BodyNode,
vDeclar *VariableDeclaration,
expNode Node[NodeType],
parentNodeId int64,
ctx *parser.AssignmentContext,
) Node[NodeType] {
// Setting the type and source location information.
a.NodeType = ast_pb.NodeType_ASSIGNMENT
a.Src = SrcNode{
Id: a.GetNextID(),
Line: int64(ctx.GetStart().GetLine()),
Column: int64(ctx.GetStart().GetColumn()),
Start: int64(ctx.GetStart().GetStart()),
End: int64(ctx.GetStop().GetStop()),
Length: int64(ctx.GetStop().GetStop() - ctx.GetStart().GetStart() + 1),
ParentIndex: func() int64 {
if expNode != nil {
return expNode.GetId()
}

if vDeclar != nil {
return vDeclar.GetId()
}

return bodyNode.GetId()
}(),
Line: int64(ctx.GetStart().GetLine()),
Column: int64(ctx.GetStart().GetColumn()),
Start: int64(ctx.GetStart().GetStart()),
End: int64(ctx.GetStop().GetStop()),
Length: int64(ctx.GetStop().GetStop() - ctx.GetStart().GetStart() + 1),
ParentIndex: parentNodeId,
}

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

// Parsing left and right expressions.
expression := NewExpression(a.ASTBuilder)
a.LeftExpression = expression.Parse(unit, contractNode, fnNode, bodyNode, vDeclar, a, ctx.Expression(0))
a.RightExpression = expression.Parse(unit, contractNode, fnNode, bodyNode, vDeclar, a, ctx.Expression(1))
a.LeftExpression = expression.Parse(unit, contractNode, fnNode, bodyNode, vDeclar, a, a.GetId(), ctx.Expression(0))
a.RightExpression = expression.Parse(unit, contractNode, fnNode, bodyNode, vDeclar, a, a.GetId(), ctx.Expression(1))

// Setting the type description based on the left expression.
a.TypeDescription = a.LeftExpression.GetTypeDescription()
Expand Down
Loading

0 comments on commit a909104

Please sign in to comment.