Skip to content

Commit

Permalink
Small refactorings
Browse files Browse the repository at this point in the history
  • Loading branch information
vknabel committed Sep 16, 2021
1 parent 9d1e8e6 commit 053dcab
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 350 deletions.
4 changes: 2 additions & 2 deletions interpreter/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type SyntaxError struct {
ModuleFile ModuleFile
}

func (ex *ExecutionContext) SyntaxErrorf(format string, args ...interface{}) SyntaxError {
func (ex *EvaluationContext) SyntaxErrorf(format string, args ...interface{}) SyntaxError {
return SyntaxError{
Message: fmt.Sprintf(format, args...),
Node: ex.node,
Expand All @@ -33,7 +33,7 @@ type RuntimeError struct {
ModuleFile ModuleFile
}

func (ex *ExecutionContext) RuntimeErrorf(format string, args ...interface{}) RuntimeError {
func (ex *EvaluationContext) RuntimeErrorf(format string, args ...interface{}) RuntimeError {
return RuntimeError{
Message: fmt.Sprintf(format, args...),
Node: ex.node,
Expand Down
10 changes: 5 additions & 5 deletions interpreter/func-binary-operators.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package interpreter

import "reflect"

func (ex *ExecutionContext) BinaryOperatorFunction(operator string) (func(*LazyRuntimeValue, *LazyRuntimeValue) (RuntimeValue, error), error) {
func (ex *EvaluationContext) BinaryOperatorFunction(operator string) (func(*LazyRuntimeValue, *LazyRuntimeValue) (RuntimeValue, error), error) {
switch operator {
case "==":
return func(lazyLeft, lazyRight *LazyRuntimeValue) (RuntimeValue, error) {
Expand Down Expand Up @@ -105,7 +105,7 @@ func (ex *ExecutionContext) BinaryOperatorFunction(operator string) (func(*LazyR
}
}

func (ex *ExecutionContext) genericGreedyComparision(
func (ex *EvaluationContext) genericGreedyComparision(
lazyLeft, lazyRight *LazyRuntimeValue,
compare func(RuntimeValue, RuntimeValue) bool,
) (RuntimeValue, error) {
Expand All @@ -124,7 +124,7 @@ func (ex *ExecutionContext) genericGreedyComparision(
}
}

func (ex *ExecutionContext) numericGreedyComparision(
func (ex *EvaluationContext) numericGreedyComparision(
lazyLeft, lazyRight *LazyRuntimeValue,
compareInt func(PreludeInt, PreludeInt) bool,
compareFloat func(PreludeFloat, PreludeFloat) bool,
Expand Down Expand Up @@ -165,7 +165,7 @@ func (ex *ExecutionContext) numericGreedyComparision(
}
}

func (ex *ExecutionContext) numericGreedyOperation(
func (ex *EvaluationContext) numericGreedyOperation(
lazyLeft, lazyRight *LazyRuntimeValue,
combineInt func(PreludeInt, PreludeInt) PreludeInt,
combineFloat func(PreludeFloat, PreludeFloat) PreludeFloat,
Expand Down Expand Up @@ -206,7 +206,7 @@ func (ex *ExecutionContext) numericGreedyOperation(
}
}

func (ex *ExecutionContext) lazyLogicComparision(
func (ex *EvaluationContext) lazyLogicComparision(
lazyLeft, lazyRight *LazyRuntimeValue,
compare func(bool, func() (bool, error)) (bool, error),
) (RuntimeValue, error) {
Expand Down
4 changes: 2 additions & 2 deletions interpreter/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ type CurriedCallable struct {
type Function struct {
name string
arguments []string
body func(*ExecutionContext) ([]*LazyRuntimeValue, error)
parent *ExecutionContext
body func(*EvaluationContext) ([]*LazyRuntimeValue, error)
parent *EvaluationContext
}

func (f Function) String() string {
Expand Down
183 changes: 0 additions & 183 deletions interpreter/interpreter-visitor.go

This file was deleted.

Loading

0 comments on commit 053dcab

Please sign in to comment.