Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Sh0g0-1758 committed Aug 23, 2024
1 parent c618583 commit 123ab09
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
8 changes: 4 additions & 4 deletions pkg/hintrunner/zero/hint_reference_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ func (m *hintReferenceResolver) GetResOperander(name string) (hinter.Reference,
if err != nil {
return nil, err
}
switch op := ref.(type) {
switch ref.(type) {
case hinter.ApCellRef, hinter.FpCellRef:
return nil, fmt.Errorf("expected %s to be ResOperander (got %T)", name, ref)
default:
return op, nil
return ref, nil
}
}

Expand All @@ -53,11 +53,11 @@ func (m *hintReferenceResolver) GetCellRefer(name string) (hinter.Reference, err
if err != nil {
return nil, err
}
switch op := ref.(type) {
switch ref.(type) {
case hinter.Deref, hinter.DoubleDeref, hinter.BinaryOp, hinter.Immediate:
return nil, fmt.Errorf("expected %s to be CellRefer (got %T)", name, ref)
default:
return op, nil
return ref, nil
}
}

Expand Down
20 changes: 5 additions & 15 deletions pkg/hintrunner/zero/hintparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,21 +273,11 @@ func (expression ProdExp) Evaluate() (hinter.Reference, error) {
return nil, err
}

switch left := leftExp.(type) {
case hinter.ApCellRef, hinter.FpCellRef:
return nil, fmt.Errorf("unexpected product expression")
default:
switch right := rightExp.(type) {
case hinter.ApCellRef, hinter.FpCellRef:
return nil, fmt.Errorf("unexpected product expression")
default:
return hinter.BinaryOp{
Operator: hinter.Mul,
Lhs: left,
Rhs: right,
}, nil
}
}
return hinter.BinaryOp{
Operator: hinter.Mul,
Lhs: leftExp,
Rhs: rightExp,
}, nil
}

func (expression Expression) Evaluate() (hinter.Reference, error) {
Expand Down

0 comments on commit 123ab09

Please sign in to comment.