Documentation
¶
Overview ¶
Package value defines the type that represents the evaluation result.
Index ¶
- Variables
- type FunctionData
- type Type
- func (t Type) Abbrev() string
- func (t Type) Arith(op bytecode.OpCode, b Type) (Type, error)
- func (t Type) Display() string
- func (t Type) Eq(op bytecode.OpCode, b Type) (Type, error)
- func (t Type) Flip() (Type, error)
- func (t Type) Index(b ...Type) (Type, error)
- func (t Type) IsNil() bool
- func (t Type) Len() (Type, error)
- func (t Type) Logic(op bytecode.OpCode, b Type) (Type, error)
- func (t Type) Mod(b Type) (Type, error)
- func (t Type) Not() (Type, error)
- func (t Type) Relational(op bytecode.OpCode, b Type) (Type, error)
- func (t *Type) SetFrame(frame *[]Type)
- func (t Type) Shift(op bytecode.OpCode, b Type) (Type, error)
- func (t *Type) StrictEq(b Type) bool
- func (t Type) String() string
- func (t Type) ToArray() ([]Type, bool)
- func (t Type) ToBool() (bool, bool)
- func (t Type) ToFunction() (FunctionData, bool)
- func (t Type) ToInt() (int, bool)
- func (t Type) ToString() (string, bool)
- func (t *Type) WeakEq(b Type) (bool, error)
Constants ¶
This section is empty.
Variables ¶
var ( ErrNil = errors.New("nil error") ErrType = errors.New("type error") ErrZeroDiv = errors.New("division by zero") ErrIndex = errors.New("index error") )
Predefined errors.
var Nil = Type{/* contains filtered or unexported fields */}
Nil is the nil value.
Functions ¶
This section is empty.
Types ¶
type FunctionData ¶ added in v1.3.0
type FunctionData struct { Node int // Pointer to the code of the function - the AST node that holds the function Frame *[]Type // Pointer to the closure stack frame ParamCnt int // ParamCnt is the number of parameters of the function LocalCnt int // LocalCnt is the number of local variables of the function including ParamCnt }
A structure that represents a function value.
type Type ¶
type Type struct {
// contains filtered or unexported fields
}
Type is evaluation result value.
It is a uniform structure, not an interface, to keep evaluation on the stack as much as possible.
func NewFunction ¶ added in v1.3.0
NewFunction allocates a new function value.
func (Type) Display ¶ added in v1.4.0
Display converts a value to a string for calc result printing.
Adds extra quotes around string type.
func (Type) Relational ¶
Relational is value relational <, >, <= ...
func (*Type) StrictEq ¶ added in v1.3.0
StrictEq decides whether a and b are exactly the same value.
1 == 1.0 -> false
in strict equality all functions are equal, this is counter intuitive, but for testing it makes sense.
func (Type) ToBool ¶ added in v1.3.0
ToBool converts a value to bool.
It returns ok false if not an bool.
func (Type) ToFunction ¶ added in v1.3.0
func (t Type) ToFunction() (FunctionData, bool)
ToFunction converts a value to FunctionData.
It returns ok false if not a function.
func (Type) ToInt ¶ added in v1.3.0
ToInt converts a value to int.
It returns ok false if not an int.