Evaluate if and return, error validation.
Signed-off-by: jmug <u.g.a.mariano@gmail.com>
This commit is contained in:
parent
cf8b0033c9
commit
8514ead895
3 changed files with 244 additions and 9 deletions
|
|
@ -5,9 +5,11 @@ import "fmt"
|
|||
type ObjectType string
|
||||
|
||||
const (
|
||||
INTEGER_OBJ = "INTEGER"
|
||||
BOOLEAN_OBJ = "BOOLEAN"
|
||||
NULL_OBJ = "NULL"
|
||||
INTEGER_OBJ = "INTEGER"
|
||||
BOOLEAN_OBJ = "BOOLEAN"
|
||||
NULL_OBJ = "NULL"
|
||||
RETURN_VALUE_OBJ = "RETURN"
|
||||
ERROR_OBJ = "ERROR"
|
||||
)
|
||||
|
||||
type Object interface {
|
||||
|
|
@ -45,3 +47,25 @@ func (n *Null) Type() ObjectType {
|
|||
func (n *Null) Inspect() string {
|
||||
return "null"
|
||||
}
|
||||
|
||||
type ReturnValue struct {
|
||||
Value Object
|
||||
}
|
||||
|
||||
func (rv *ReturnValue) Type() ObjectType {
|
||||
return RETURN_VALUE_OBJ
|
||||
}
|
||||
func (rv *ReturnValue) Inspect() string {
|
||||
return rv.Value.Inspect()
|
||||
}
|
||||
|
||||
type Error struct {
|
||||
Message string
|
||||
}
|
||||
|
||||
func (e *Error) Type() ObjectType {
|
||||
return ERROR_OBJ
|
||||
}
|
||||
func (e *Error) Inspect() string {
|
||||
return "ERROR: " + e.Message
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue