Documentation
¶
Index ¶
- Variables
- type Bool
- func (b *Bool) Add(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (b *Bool) And(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (b *Bool) BitAnd(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (b *Bool) BitNot(posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (b *Bool) BitOr(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (b *Bool) Divide(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (b *Bool) Equal(other Object, _, _ *util.Pos, _ *frame.Frame) (Object, error)
- func (b *Bool) GreaterThan(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (b *Bool) GreaterThanOrEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (b *Bool) Index(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (b *Bool) LeftShift(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (b *Bool) LessThan(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (b *Bool) LessThanOrEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (b *Bool) Mod(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (b *Bool) Multiply(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (b *Bool) Negative(posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (b *Bool) Not(*util.Pos, *util.Pos, *frame.Frame) (Object, error)
- func (b *Bool) NotEqual(other Object, _, _ *util.Pos, _ *frame.Frame) (Object, error)
- func (b *Bool) Or(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (b *Bool) RightShift(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (b *Bool) String() string
- func (b *Bool) Subtract(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (b *Bool) Type() string
- func (b *Bool) Xor(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- type BreakValue
- func (bv *BreakValue) Add(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (bv *BreakValue) And(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (bv *BreakValue) BitAnd(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (bv *BreakValue) BitNot(posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (bv *BreakValue) BitOr(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (bv *BreakValue) Divide(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (bv *BreakValue) Equal(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (bv *BreakValue) GreaterThan(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (bv *BreakValue) GreaterThanOrEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (bv *BreakValue) Index(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (bv *BreakValue) LeftShift(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (bv *BreakValue) LessThan(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (bv *BreakValue) LessThanOrEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (bv *BreakValue) Mod(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (bv *BreakValue) Multiply(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (bv *BreakValue) Negative(posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (bv *BreakValue) Not(posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (bv *BreakValue) NotEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (bv *BreakValue) Or(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (bv *BreakValue) RightShift(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (bv *BreakValue) String() string
- func (bv *BreakValue) Subtract(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (bv *BreakValue) Type() string
- func (bv *BreakValue) Xor(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- type BuiltinFunction
- func (bf *BuiltinFunction) Add(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (bf *BuiltinFunction) And(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (bf *BuiltinFunction) BitAnd(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (bf *BuiltinFunction) BitNot(posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (bf *BuiltinFunction) BitOr(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (bf *BuiltinFunction) Divide(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (bf *BuiltinFunction) Equal(other Object, _, _ *util.Pos, _ *frame.Frame) (Object, error)
- func (bf *BuiltinFunction) GreaterThan(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (bf *BuiltinFunction) GreaterThanOrEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (bf *BuiltinFunction) Index(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (bf *BuiltinFunction) LeftShift(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (bf *BuiltinFunction) LessThan(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (bf *BuiltinFunction) LessThanOrEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (bf *BuiltinFunction) Mod(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (bf *BuiltinFunction) Multiply(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (bf *BuiltinFunction) Negative(posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (bf *BuiltinFunction) Not(posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (bf *BuiltinFunction) NotEqual(other Object, _, _ *util.Pos, _ *frame.Frame) (Object, error)
- func (bf *BuiltinFunction) Or(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (bf *BuiltinFunction) RightShift(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (bf *BuiltinFunction) String() string
- func (bf *BuiltinFunction) Subtract(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (bf *BuiltinFunction) Type() string
- func (bf *BuiltinFunction) Xor(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- type ContinueValue
- func (cv *ContinueValue) Add(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (cv *ContinueValue) And(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (cv *ContinueValue) BitAnd(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (cv *ContinueValue) BitNot(posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (cv *ContinueValue) BitOr(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (cv *ContinueValue) Divide(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (cv *ContinueValue) Equal(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (cv *ContinueValue) GreaterThan(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (cv *ContinueValue) GreaterThanOrEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (cv *ContinueValue) Index(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (cv *ContinueValue) LeftShift(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (cv *ContinueValue) LessThan(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (cv *ContinueValue) LessThanOrEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (cv *ContinueValue) Mod(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (cv *ContinueValue) Multiply(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (cv *ContinueValue) Negative(posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (cv *ContinueValue) Not(posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (cv *ContinueValue) NotEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (cv *ContinueValue) Or(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (cv *ContinueValue) RightShift(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (cv *ContinueValue) String() string
- func (cv *ContinueValue) Subtract(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (cv *ContinueValue) Type() string
- func (cv *ContinueValue) Xor(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- type Environment
- type Float
- func (f *Float) Add(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (f *Float) And(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (f *Float) BitAnd(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (f *Float) BitNot(posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (f *Float) BitOr(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (f *Float) Divide(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (f *Float) Equal(other Object, _, _ *util.Pos, _ *frame.Frame) (Object, error)
- func (f *Float) GreaterThan(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (f *Float) GreaterThanOrEqual(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (f *Float) Index(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (f *Float) LeftShift(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (f *Float) LessThan(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (f *Float) LessThanOrEqual(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (f *Float) Mod(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (f *Float) Multiply(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (f *Float) Negative(*util.Pos, *util.Pos, *frame.Frame) (Object, error)
- func (f *Float) Not(posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (f *Float) NotEqual(other Object, _, _ *util.Pos, _ *frame.Frame) (Object, error)
- func (f *Float) Or(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (f *Float) RightShift(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (f *Float) String() string
- func (f *Float) Subtract(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (f *Float) Type() string
- func (f *Float) Xor(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- type Function
- func (f *Function) Add(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (f *Function) And(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (f *Function) BitAnd(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (f *Function) BitNot(posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (f *Function) BitOr(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (f *Function) Divide(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (f *Function) Equal(other Object, _, _ *util.Pos, _ *frame.Frame) (Object, error)
- func (f *Function) GreaterThan(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (f *Function) GreaterThanOrEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (f *Function) Index(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (f *Function) LeftShift(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (f *Function) LessThan(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (f *Function) LessThanOrEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (f *Function) Mod(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (f *Function) Multiply(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (f *Function) Negative(posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (f *Function) Not(posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (f *Function) NotEqual(other Object, _, _ *util.Pos, _ *frame.Frame) (Object, error)
- func (f *Function) Or(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (f *Function) RightShift(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (f *Function) String() string
- func (f *Function) Subtract(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (f *Function) Type() string
- func (f *Function) Xor(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- type IndexError
- type Int
- func (i *Int) Add(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (i *Int) And(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (i *Int) BitAnd(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (i *Int) BitNot(*util.Pos, *util.Pos, *frame.Frame) (Object, error)
- func (i *Int) BitOr(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (i *Int) Divide(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (i *Int) Equal(other Object, _, _ *util.Pos, _ *frame.Frame) (Object, error)
- func (i *Int) GreaterThan(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (i *Int) GreaterThanOrEqual(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (i *Int) Index(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (i *Int) LeftShift(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (i *Int) LessThan(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (i *Int) LessThanOrEqual(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (i *Int) Mod(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (i *Int) Multiply(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (i *Int) Negative(*util.Pos, *util.Pos, *frame.Frame) (Object, error)
- func (i *Int) Not(posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (i *Int) NotEqual(other Object, _, _ *util.Pos, _ *frame.Frame) (Object, error)
- func (i *Int) Or(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (i *Int) RightShift(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (i *Int) String() string
- func (i *Int) Subtract(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (i *Int) Type() string
- func (i *Int) Xor(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- type List
- func (l *List) Add(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (l *List) And(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (l *List) BitAnd(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (l *List) BitNot(posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (l *List) BitOr(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (l *List) Divide(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (l *List) Equal(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (l *List) GreaterThan(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (l *List) GreaterThanOrEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (l *List) Index(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (l *List) LeftShift(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (l *List) Length() int64
- func (l *List) LessThan(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (l *List) LessThanOrEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (l *List) Mod(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (l *List) Multiply(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (l *List) Negative(posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (l *List) Not(posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (l *List) NotEqual(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (l *List) Or(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (l *List) RightShift(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (l *List) Set(index Object, value Object, posStart, posEnd *util.Pos, frame *frame.Frame) error
- func (l *List) String() string
- func (l *List) Subtract(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (l *List) Type() string
- func (l *List) Xor(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- type MathError
- type Namespace
- func (n *Namespace) Add(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (n *Namespace) And(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (n *Namespace) BitAnd(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (n *Namespace) BitNot(posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (n *Namespace) BitOr(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (n *Namespace) Divide(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (n *Namespace) Equal(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (n *Namespace) GreaterThan(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (n *Namespace) GreaterThanOrEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (n *Namespace) Index(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (n *Namespace) LeftShift(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (n *Namespace) LessThan(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (n *Namespace) LessThanOrEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (n *Namespace) Mod(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (n *Namespace) Multiply(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (n *Namespace) Negative(posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (n *Namespace) Not(posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (n *Namespace) NotEqual(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (n *Namespace) Or(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (n *Namespace) RightShift(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (n *Namespace) String() string
- func (n *Namespace) Subtract(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (n *Namespace) Type() string
- func (n *Namespace) Xor(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- type Null
- func (n *Null) Add(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (n *Null) And(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (n *Null) BitAnd(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (n *Null) BitNot(posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (n *Null) BitOr(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (n *Null) Divide(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (n *Null) Equal(other Object, _, _ *util.Pos, _ *frame.Frame) (Object, error)
- func (n *Null) GreaterThan(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (n *Null) GreaterThanOrEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (n *Null) Index(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (n *Null) LeftShift(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (n *Null) LessThan(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (n *Null) LessThanOrEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (n *Null) Mod(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (n *Null) Multiply(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (n *Null) Negative(posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (n *Null) Not(posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (n *Null) NotEqual(other Object, _, _ *util.Pos, _ *frame.Frame) (Object, error)
- func (n *Null) Or(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (n *Null) RightShift(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (n *Null) String() string
- func (n *Null) Subtract(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (n *Null) Type() string
- func (n *Null) Xor(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- type Number
- type Object
- type OperationError
- type ReturnValue
- func (rv *ReturnValue) Add(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (rv *ReturnValue) And(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (rv *ReturnValue) BitAnd(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (rv *ReturnValue) BitNot(posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (rv *ReturnValue) BitOr(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (rv *ReturnValue) Divide(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (rv *ReturnValue) Equal(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (rv *ReturnValue) GreaterThan(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (rv *ReturnValue) GreaterThanOrEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (rv *ReturnValue) Index(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (rv *ReturnValue) LeftShift(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (rv *ReturnValue) LessThan(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (rv *ReturnValue) LessThanOrEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (rv *ReturnValue) Mod(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (rv *ReturnValue) Multiply(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (rv *ReturnValue) Negative(posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (rv *ReturnValue) Not(posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (rv *ReturnValue) NotEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (rv *ReturnValue) Or(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (rv *ReturnValue) RightShift(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (rv *ReturnValue) String() string
- func (rv *ReturnValue) Subtract(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (rv *ReturnValue) Type() string
- func (rv *ReturnValue) Xor(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- type String
- func (s *String) Add(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (s *String) And(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (s *String) BitAnd(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (s *String) BitNot(posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (s *String) BitOr(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (s *String) Divide(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (s *String) Equal(other Object, _, _ *util.Pos, _ *frame.Frame) (Object, error)
- func (s *String) GreaterThan(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (s *String) GreaterThanOrEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (s *String) Index(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (s *String) LeftShift(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (s *String) Length() int64
- func (s *String) LessThan(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (s *String) LessThanOrEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (s *String) Mod(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (s *String) Multiply(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (s *String) Negative(posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (s *String) Not(posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (s *String) NotEqual(other Object, _, _ *util.Pos, _ *frame.Frame) (Object, error)
- func (s *String) Or(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (s *String) RightShift(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (s *String) Set(index Object, value Object, posStart, posEnd *util.Pos, frame *frame.Frame) error
- func (s *String) String() string
- func (s *String) Subtract(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- func (s *String) Type() string
- func (s *String) Xor(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
- type Symbol
- type TypeError
Constants ¶
This section is empty.
Variables ¶
var Builtins = map[string]Object{ "inf": &Float{Value: math.Inf(1)}, "nan": &Float{Value: math.NaN()}, "print": &BuiltinFunction{ Name: "print", Parameter: []string{"a"}, DefaultValue: []Object{ nil, }, HaveVariadic: true, Fn: func(f *frame.Frame, posStart, posEnd *util.Pos, args ...Object) (Object, error) { for i, arg := range args { if i > 0 { fmt.Print(" ") } fmt.Print(arg.String()) } _ = os.Stdout.Sync() return &Null{}, nil }, }, "println": &BuiltinFunction{ Name: "println", Parameter: []string{"a"}, DefaultValue: []Object{ nil, }, HaveVariadic: true, Fn: func(f *frame.Frame, posStart, posEnd *util.Pos, args ...Object) (Object, error) { for i, arg := range args { if i > 0 { fmt.Print(" ") } fmt.Print(arg.String()) } fmt.Println() _ = os.Stdout.Sync() return &Null{}, nil }, }, "len": &BuiltinFunction{ Name: "len", Parameter: []string{"a"}, DefaultValue: []Object{ nil, }, HaveVariadic: false, Fn: func(f *frame.Frame, posStart, posEnd *util.Pos, args ...Object) (Object, error) { a := args[0] switch a := a.(type) { case *String: return &Int{Value: int64(utf8.RuneCountInString(a.Value))}, nil case *List: return &Int{Value: int64(len(a.Elements))}, nil default: return nil, &TypeError{ Frame: f, Message: "len() argument must be a sequence or collection.", PosStart: posStart, PosEnd: posEnd, } } }, }, "power": &BuiltinFunction{ Name: "power", Parameter: []string{"a", "n"}, DefaultValue: []Object{ nil, }, HaveVariadic: false, Fn: func(f *frame.Frame, posStart, posEnd *util.Pos, args ...Object) (Object, error) { a := args[0] n := args[1] var base, exp float64 switch a := a.(type) { case *Int: base = float64(a.Value) case *Float: base = a.Value default: return nil, &TypeError{ Frame: f, Message: "power() arguments must be integers or floats.", PosStart: posStart, PosEnd: posEnd, } } switch n := n.(type) { case *Int: exp = float64(n.Value) case *Float: exp = n.Value default: return nil, &TypeError{ Frame: f, Message: "power() arguments must be integers or floats.", PosStart: posStart, PosEnd: posEnd, } } return &Float{Value: math.Pow(base, exp)}, nil }, }, }
Builtins 是内建函数和常量
Functions ¶
This section is empty.
Types ¶
type Bool ¶
type Bool struct {
Value bool // 布尔值的实际值
}
Bool 表示布尔值类型,实现了Object接口 支持逻辑运算
func (*Bool) Add ¶
Add 对值进行加法运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Bool) And ¶
And 执行逻辑与运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Bool) BitAnd ¶
BitAnd 对值进行按位与运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Bool) BitNot ¶
BitNot 对值进行按位非运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Bool) BitOr ¶
BitOr 对值进行按位或运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Bool) Divide ¶
Divide 对值进行除法运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Bool) Equal ¶
Equal 对值进行等于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*Bool) GreaterThan ¶
func (b *Bool) GreaterThan(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
GreaterThan 对值进行大于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*Bool) GreaterThanOrEqual ¶
func (b *Bool) GreaterThanOrEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
GreaterThanOrEqual 对值进行大于等于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*Bool) Index ¶
Index 执行索引运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Bool) LeftShift ¶
LeftShift 对值进行左移运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Bool) LessThan ¶
LessThan 对值进行小于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*Bool) LessThanOrEqual ¶
func (b *Bool) LessThanOrEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
LessThanOrEqual 对值进行小于等于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*Bool) Mod ¶
Mod 对值进行取模运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Bool) Multiply ¶
Multiply 对值进行乘法运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Bool) Negative ¶
Negative 对值进行负运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Bool) Not ¶
Not 返回当前布尔值的否定
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
包含否定值的新Bool实例;无错误
func (*Bool) NotEqual ¶
NotEqual 对值进行不等于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*Bool) Or ¶
Or 执行逻辑或运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Bool) RightShift ¶
RightShift 对值进行右移运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
type BreakValue ¶ added in v0.2.0
type BreakValue struct{}
BreakValue 表示break语句的返回值
func (*BreakValue) Add ¶ added in v0.2.0
Add 对值进行加法运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*BreakValue) And ¶ added in v0.2.0
And 对值进行逻辑与运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*BreakValue) BitAnd ¶ added in v0.2.0
func (bv *BreakValue) BitAnd(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
BitAnd 对值进行按位与运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*BreakValue) BitNot ¶ added in v0.2.0
BitNot 对值进行按位非运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*BreakValue) BitOr ¶ added in v0.2.0
func (bv *BreakValue) BitOr(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
BitOr 对值进行按位或运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*BreakValue) Divide ¶ added in v0.2.0
func (bv *BreakValue) Divide(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
Divide 对值进行除法运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*BreakValue) Equal ¶ added in v0.2.0
func (bv *BreakValue) Equal(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
Equal 判断当前空值与另一个值是否相等
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*BreakValue) GreaterThan ¶ added in v0.2.0
func (bv *BreakValue) GreaterThan(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
GreaterThan 对值进行大于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*BreakValue) GreaterThanOrEqual ¶ added in v0.2.0
func (bv *BreakValue) GreaterThanOrEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
GreaterThanOrEqual 对值进行大于等于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*BreakValue) Index ¶ added in v0.2.0
func (bv *BreakValue) Index(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
Index 执行索引运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*BreakValue) LeftShift ¶ added in v0.2.0
func (bv *BreakValue) LeftShift(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
LeftShift 对值进行左移运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*BreakValue) LessThan ¶ added in v0.2.0
func (bv *BreakValue) LessThan(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
LessThan 对值进行小于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*BreakValue) LessThanOrEqual ¶ added in v0.2.0
func (bv *BreakValue) LessThanOrEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
LessThanOrEqual 对值进行小于等于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*BreakValue) Mod ¶ added in v0.2.0
Mod 对值进行取模运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*BreakValue) Multiply ¶ added in v0.2.0
func (bv *BreakValue) Multiply(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
Multiply 对值进行乘法运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*BreakValue) Negative ¶ added in v0.2.0
Negative 对值进行负运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*BreakValue) Not ¶ added in v0.2.0
Not 对值进行逻辑非运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*BreakValue) NotEqual ¶ added in v0.2.0
func (bv *BreakValue) NotEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
NotEqual 判断当前空值与另一个值是否不相等
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*BreakValue) Or ¶ added in v0.2.0
Or 对值进行逻辑或运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*BreakValue) RightShift ¶ added in v0.2.0
func (bv *BreakValue) RightShift(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
RightShift 对值进行右移运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*BreakValue) String ¶ added in v0.2.0
func (bv *BreakValue) String() string
String 返回值的字符串表示
返回值:
string - 格式化的字符串表示
func (*BreakValue) Subtract ¶ added in v0.2.0
func (bv *BreakValue) Subtract(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
Subtract 对值进行减法运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*BreakValue) Type ¶ added in v0.2.0
func (bv *BreakValue) Type() string
Type 返回值的类型
返回值:
string - 值的类型
type BuiltinFunction ¶
type BuiltinFunction struct {
Name string // 函数名
Parameter []string // 参数名
DefaultValue []Object // 默认参数值
HaveVariadic bool // 是否为可变参数
Fn func(f *frame.Frame, posStart, posEnd *util.Pos, args ...Object) (Object, error) // 函数体
}
BuiltinFunction 表示内建函数类型,实现了Object接口 支持的操作包括调用函数等
func (*BuiltinFunction) Add ¶
func (bf *BuiltinFunction) Add(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
Add 对值进行加法运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*BuiltinFunction) And ¶
func (bf *BuiltinFunction) And(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
And 对值进行逻辑与运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*BuiltinFunction) BitAnd ¶
func (bf *BuiltinFunction) BitAnd(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
BitAnd 对值进行按位与运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*BuiltinFunction) BitNot ¶
BitNot 对值进行按位非运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*BuiltinFunction) BitOr ¶
func (bf *BuiltinFunction) BitOr(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
BitOr 对值进行按位或运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*BuiltinFunction) Divide ¶
func (bf *BuiltinFunction) Divide(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
Divide 对值进行除法运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*BuiltinFunction) Equal ¶
Equal 判断当前函数与另一个值是否相等
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
布尔值,表示比较结果;无错误
比较规则:
引用性比较
func (*BuiltinFunction) GreaterThan ¶
func (bf *BuiltinFunction) GreaterThan(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
GreaterThan 对值进行大于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*BuiltinFunction) GreaterThanOrEqual ¶
func (bf *BuiltinFunction) GreaterThanOrEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
GreaterThanOrEqual 对值进行大于等于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*BuiltinFunction) Index ¶
func (bf *BuiltinFunction) Index(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
Index 执行索引运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*BuiltinFunction) LeftShift ¶
func (bf *BuiltinFunction) LeftShift(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
LeftShift 对值进行左移运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*BuiltinFunction) LessThan ¶
func (bf *BuiltinFunction) LessThan(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
LessThan 对值进行小于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*BuiltinFunction) LessThanOrEqual ¶
func (bf *BuiltinFunction) LessThanOrEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
LessThanOrEqual 对值进行小于等于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*BuiltinFunction) Mod ¶
func (bf *BuiltinFunction) Mod(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
Mod 对值进行取模运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*BuiltinFunction) Multiply ¶
func (bf *BuiltinFunction) Multiply(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
Multiply 对值进行乘法运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*BuiltinFunction) Negative ¶
Negative 对值进行负运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*BuiltinFunction) Not ¶
Not 对值进行逻辑非运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*BuiltinFunction) NotEqual ¶
NotEqual 判断当前函数与另一个值是否不相等
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
布尔值,表示比较结果;无错误
比较规则:
引用性比较
func (*BuiltinFunction) Or ¶
func (bf *BuiltinFunction) Or(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
Or 对值进行逻辑或运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*BuiltinFunction) RightShift ¶
func (bf *BuiltinFunction) RightShift(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
RightShift 对值进行右移运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*BuiltinFunction) String ¶
func (bf *BuiltinFunction) String() string
String 返回值的字符串表示
返回值:
string - 格式化的字符串表示
func (*BuiltinFunction) Subtract ¶
func (bf *BuiltinFunction) Subtract(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
Subtract 对值进行减法运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*BuiltinFunction) Type ¶
func (bf *BuiltinFunction) Type() string
Type 返回值的类型
返回值:
string - 值的类型
type ContinueValue ¶ added in v0.2.0
type ContinueValue struct{}
ContinueValue 表示continue语句的返回值
func (*ContinueValue) Add ¶ added in v0.2.0
func (cv *ContinueValue) Add(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
Add 对值进行加法运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*ContinueValue) And ¶ added in v0.2.0
func (cv *ContinueValue) And(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
And 对值进行逻辑与运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*ContinueValue) BitAnd ¶ added in v0.2.0
func (cv *ContinueValue) BitAnd(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
BitAnd 对值进行按位与运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*ContinueValue) BitNot ¶ added in v0.2.0
BitNot 对值进行按位非运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*ContinueValue) BitOr ¶ added in v0.2.0
func (cv *ContinueValue) BitOr(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
BitOr 对值进行按位或运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*ContinueValue) Divide ¶ added in v0.2.0
func (cv *ContinueValue) Divide(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
Divide 对值进行除法运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*ContinueValue) Equal ¶ added in v0.2.0
func (cv *ContinueValue) Equal(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
Equal 判断当前空值与另一个值是否相等
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*ContinueValue) GreaterThan ¶ added in v0.2.0
func (cv *ContinueValue) GreaterThan(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
GreaterThan 对值进行大于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*ContinueValue) GreaterThanOrEqual ¶ added in v0.2.0
func (cv *ContinueValue) GreaterThanOrEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
GreaterThanOrEqual 对值进行大于等于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*ContinueValue) Index ¶ added in v0.2.0
func (cv *ContinueValue) Index(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
Index 执行索引运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*ContinueValue) LeftShift ¶ added in v0.2.0
func (cv *ContinueValue) LeftShift(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
LeftShift 对值进行左移运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*ContinueValue) LessThan ¶ added in v0.2.0
func (cv *ContinueValue) LessThan(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
LessThan 对值进行小于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*ContinueValue) LessThanOrEqual ¶ added in v0.2.0
func (cv *ContinueValue) LessThanOrEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
LessThanOrEqual 对值进行小于等于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*ContinueValue) Mod ¶ added in v0.2.0
func (cv *ContinueValue) Mod(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
Mod 对值进行取模运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*ContinueValue) Multiply ¶ added in v0.2.0
func (cv *ContinueValue) Multiply(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
Multiply 对值进行乘法运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*ContinueValue) Negative ¶ added in v0.2.0
Negative 对值进行负运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*ContinueValue) Not ¶ added in v0.2.0
Not 对值进行逻辑非运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*ContinueValue) NotEqual ¶ added in v0.2.0
func (cv *ContinueValue) NotEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
NotEqual 判断当前空值与另一个值是否不相等
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*ContinueValue) Or ¶ added in v0.2.0
func (cv *ContinueValue) Or(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
Or 对值进行逻辑或运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*ContinueValue) RightShift ¶ added in v0.2.0
func (cv *ContinueValue) RightShift(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
RightShift 对值进行右移运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*ContinueValue) String ¶ added in v0.2.0
func (cv *ContinueValue) String() string
String 返回值的字符串表示
返回值:
string - 格式化的字符串表示
func (*ContinueValue) Subtract ¶ added in v0.2.0
func (cv *ContinueValue) Subtract(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
Subtract 对值进行减法运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*ContinueValue) Type ¶ added in v0.2.0
func (cv *ContinueValue) Type() string
Type 返回值的类型
返回值:
string - 值的类型
type Environment ¶
type Environment struct {
Name string // 环境名称
Store map[string]*Symbol // 变量名到值的映射
Outer *Environment // 外部环境
}
Environment 表示程序运行时的上下文环境,用于管理符号表和上下文嵌套关系 在函数调用、作用域切换等场景中使用,实现变量的作用域隔离和查找
func (*Environment) Assign ¶
func (e *Environment) Assign(name string, sym *Symbol)
Assign 设置符号的值到当前环境 沿作用域链查找并设置符号的值 若当前作用域未定义该符号,则递归查找父作用域,直到找到或到达全局作用域
参数:
name - 要设置的符号名称 sym - 符号
func (*Environment) Exists ¶
func (e *Environment) Exists(name string) bool
Exists 检查符号是否存在于当前环境(不包含父环境) 仅判断当前作用域中是否已定义该符号,不进行作用域链查找
参数:
name - 要检查的符号名称
返回值:
bool - 存在性结果,true表示存在,false表示不存在
func (*Environment) Get ¶
func (e *Environment) Get(name string) (*Symbol, bool)
Get 查找符号的值,支持作用域链向上查找 先在当前环境中查找,若不存在且存在父环境,则递归查找父环境
参数:
name - 要查找的符号名称
返回值:
Symbol - 符号,若未找到则为nil bool - 查找结果,true表示找到,false表示未找到
func (*Environment) Set ¶
func (e *Environment) Set(name string, sym *Symbol)
Set 设置符号的值到当前环境 仅在当前作用域中添加或修改变量,不影响父环境
参数:
name - 要设置的符号名称 sym - 符号
type Float ¶
type Float struct {
Value float64
}
Float 表示浮点数值类型,实现了Number和Object接口 支持的操作包括算术运算、比较运算等
func (*Float) Add ¶
Add 对值进行加法运算
参数:
other - 右操作数,可以是Int或Float类型 posStart - 节点起始位置 posEnd - 节点结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Float) And ¶
And 对值进行逻辑与运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Float) BitAnd ¶
BitAnd 对值进行按位与运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Float) BitNot ¶
BitNot 对值进行按位非运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Float) BitOr ¶
BitOr 对值进行按位或运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Float) Divide ¶
func (f *Float) Divide(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
Divide 对值进行除法运算
参数:
other - 右操作数,可以是Int或Float类型 posStart - 节点起始位置 posEnd - 节点结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Float) Equal ¶
Equal 判断当前值与另一个值是否相等
参数:
other - 右操作数,可以是Int或Float类型 posStart - 节点起始位置 posEnd - 节点结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Float) GreaterThan ¶
func (f *Float) GreaterThan(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
GreaterThan 对值进行大于比较
参数:
other - 右操作数,可以是Int或Float类型 posStart - 节点起始位置 posEnd - 节点结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Float) GreaterThanOrEqual ¶
func (f *Float) GreaterThanOrEqual(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
GreaterThanOrEqual 对值进行大于等于比较
参数:
other - 右操作数,可以是Int或Float类型 posStart - 节点起始位置 posEnd - 节点结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Float) Index ¶
Index 执行索引运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Float) LeftShift ¶
LeftShift 对值进行左移运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Float) LessThan ¶
func (f *Float) LessThan(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
LessThan 对值进行小于比较
参数:
other - 右操作数,可以是Int或Float类型 posStart - 节点起始位置 posEnd - 节点结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Float) LessThanOrEqual ¶
func (f *Float) LessThanOrEqual(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
LessThanOrEqual 对值进行小于等于比较
参数:
other - 右操作数,可以是Int或Float类型 posStart - 节点起始位置 posEnd - 节点结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Float) Mod ¶
Mod 对值进行取模运算
参数:
other - 右操作数,可以是Int或Float类型 posStart - 节点起始位置 posEnd - 节点结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Float) Multiply ¶
func (f *Float) Multiply(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
Multiply 对值进行乘法运算
参数:
other - 右操作数,可以是Int或Float类型 posStart - 节点起始位置 posEnd - 节点结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Float) Negative ¶
Negative 对值进行负运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Float) Not ¶
Not 对值进行逻辑非运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Float) NotEqual ¶
NotEqual 判断当前值与另一个值是否不相等
参数:
other - 右操作数,可以是Int或Float类型 posStart - 节点起始位置 posEnd - 节点结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Float) Or ¶
Or 对值进行逻辑或运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Float) RightShift ¶
func (f *Float) RightShift(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
RightShift 对值进行右移运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
type Function ¶
type Function struct {
Name string // 函数名
Parameter []*ast.Parameter // 参数
Body ast.Statement // 函数体
Env *Environment // 环境
}
Function 表示函数类型,实现了Object接口 支持的操作包括调用函数等
func (*Function) Add ¶
Add 对值进行加法运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Function) And ¶
And 对值进行逻辑与运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Function) BitAnd ¶
BitAnd 对值进行按位与运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Function) BitNot ¶
BitNot 对值进行按位非运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Function) BitOr ¶
BitOr 对值进行按位或运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Function) Divide ¶
Divide 对值进行除法运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Function) Equal ¶
Equal 判断当前函数与另一个值是否相等
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
布尔值,表示比较结果;无错误
比较规则:
引用性比较
func (*Function) GreaterThan ¶
func (f *Function) GreaterThan(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
GreaterThan 对值进行大于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*Function) GreaterThanOrEqual ¶
func (f *Function) GreaterThanOrEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
GreaterThanOrEqual 对值进行大于等于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*Function) Index ¶
func (f *Function) Index(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
Index 执行索引运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Function) LeftShift ¶
func (f *Function) LeftShift(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
LeftShift 对值进行左移运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Function) LessThan ¶
func (f *Function) LessThan(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
LessThan 对值进行小于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*Function) LessThanOrEqual ¶
func (f *Function) LessThanOrEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
LessThanOrEqual 对值进行小于等于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*Function) Mod ¶
Mod 对值进行取模运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Function) Multiply ¶
func (f *Function) Multiply(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
Multiply 对值进行乘法运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Function) Negative ¶
Negative 对值进行负运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Function) Not ¶
Not 对值进行逻辑非运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Function) NotEqual ¶
NotEqual 判断当前函数与另一个值是否不相等
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
布尔值,表示比较结果;无错误
比较规则:
引用性比较
func (*Function) Or ¶
Or 对值进行逻辑或运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Function) RightShift ¶
func (f *Function) RightShift(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
RightShift 对值进行右移运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
type IndexError ¶
type IndexError struct {
Frame *frame.Frame // 错误发生时的调用栈
Message string // 错误描述文本
PosStart *util.Pos // 错误起始位置
PosEnd *util.Pos // 错误结束位置
}
IndexError 索引错误类型,表示索引越界等相关的运行时错误 拥有完整的错误跟踪和格式化能力
func (*IndexError) Error ¶
func (e *IndexError) Error() string
Error 生成格式化的索引错误信息字符串 前缀为"Index Error"
type Int ¶
type Int struct {
Value int64 // 整数实际值
}
Int 整数类型结构体,表示运行时的整数数值 实现Number接口和Object接口,支持各种整数运算
func (*Int) Add ¶
Add 对值进行加法运算
参数:
other - 右操作数,可以是Int或Float类型 posStart - 节点起始位置 posEnd - 节点结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Int) And ¶
And 对值进行逻辑与运算
参数:
other - 右侧表达式 posStart - 节点起始位置 posEnd - 节点结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Int) BitAnd ¶
BitAnd 对值进行按位与运算
参数:
other - 右侧整数值 posStart - 节点起始位置 posEnd - 节点结束位置 frame - 当前调用栈
返回值:
新的整数值,表示按位与的结果;若操作失败则返回运行时错误 error - 可能出现的错误
注意事项:
仅支持与*Int类型进行按位与操作,其他类型将返回错误
func (*Int) BitNot ¶
BitNot 对值进行按位非运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Int) BitOr ¶
BitOr 对值进行按位或运算
参数:
other - 右侧整数值 posStart - 节点起始位置 posEnd - 节点结束位置 frame - 当前调用栈
返回值:
新的整数值,表示按位或的结果;若操作失败则返回运行时错误 error - 可能出现的错误
注意事项:
仅支持与*Int类型进行按位或操作,其他类型将返回错误
func (*Int) Divide ¶
Divide 对值进行除法运算
参数:
other - 右操作数,可以是Int或Float类型 posStart - 节点起始位置 posEnd - 节点结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Int) Equal ¶
Equal 判断当前值与另一个值是否相等
参数:
other - 要比较的右侧值 posStart - 节点起始位置 posEnd - 节点结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Int) GreaterThan ¶
func (i *Int) GreaterThan(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
GreaterThan 对值进行大于比较
参数:
other - 要比较的右侧值 posStart - 节点起始位置 posEnd - 节点结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Int) GreaterThanOrEqual ¶
func (i *Int) GreaterThanOrEqual(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
GreaterThanOrEqual 对值进行大于等于比较
参数:
other - 要比较的右侧值 posStart - 节点起始位置 posEnd - 节点结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Int) Index ¶
Index 执行索引运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Int) LeftShift ¶
func (i *Int) LeftShift(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
LeftShift 对值进行异或运算
参数:
other - 左移的位数 posStart - 节点起始位置 posEnd - 节点结束位置 frame - 当前调用栈
返回值:
新的整数值,表示左移后的结果;若操作失败则返回运行时错误 error - 可能出现的错误
注意事项:
- 仅支持与*Int类型进行左移操作,其他类型将返回错误
- 右操作数不能为负数,否则返回错误
error - 可能出现的错误
func (*Int) LessThan ¶
func (i *Int) LessThan(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
LessThan 对值进行小于比较
参数:
other - 要比较的右侧值 posStart - 节点起始位置 posEnd - 节点结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Int) LessThanOrEqual ¶
func (i *Int) LessThanOrEqual(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
LessThanOrEqual 对值进行小于等于比较
参数:
other - 要比较的右侧值 posStart - 节点起始位置 posEnd - 节点结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Int) Mod ¶
Mod 对值进行取模运算
参数:
other - 要取模的右侧值 posStart - 节点起始位置 posEnd - 节点结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Int) Multiply ¶
func (i *Int) Multiply(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
Multiply 对值进行乘法运算
参数:
other - 右操作数,可以是Int、Float或String类型 posStart - 节点起始位置 posEnd - 节点结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Int) Negative ¶
Negative 对值进行负运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Int) Not ¶
Not 对值进行逻辑非运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Int) NotEqual ¶
NotEqual 判断当前值与另一个值是否不相等
参数:
other - 要比较的右侧值 posStart - 节点起始位置 posEnd - 节点结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Int) Or ¶
Or 对值进行逻辑或运算
参数:
other - 右侧表达式 posStart - 节点起始位置 posEnd - 节点结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Int) RightShift ¶
func (i *Int) RightShift(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
RightShift 对值进行右移运算
参数:
other - 右移的位数 posStart - 节点起始位置 posEnd - 节点结束位置 frame - 当前调用栈
返回值:
新的整数值,表示右移后的结果;若操作失败则返回运行时错误 error - 可能出现的错误
注意事项:
- 仅支持与*Int类型进行右移操作,其他类型将返回错误
- 右操作数不能为负数,否则返回错误
type List ¶
type List struct {
Elements []Object // 列表元素
}
List 列表类型结构体,表示运行时的列表 实现Object接口
func (*List) Add ¶
Add 对值进行加法运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*List) And ¶
And 对值进行逻辑与运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*List) BitAnd ¶
BitAnd 对值进行按位与运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*List) BitNot ¶
BitNot 对值进行按位非运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*List) BitOr ¶
BitOr 对值进行按位或运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*List) Divide ¶
Divide 对值进行除法运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*List) Equal ¶
Equal 判断当前值与另一个值是否相等
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
布尔值,表示比较结果;无错误
比较规则:
- 与*Null类型比较:返回true
- 与其他类型比较:返回false
func (*List) GreaterThan ¶
func (l *List) GreaterThan(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
GreaterThan 对值进行大于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*List) GreaterThanOrEqual ¶
func (l *List) GreaterThanOrEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
GreaterThanOrEqual 对值进行大于等于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*List) Index ¶
Index 执行索引运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*List) LeftShift ¶
LeftShift 对值进行左移运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*List) LessThan ¶
LessThan 对值进行小于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*List) LessThanOrEqual ¶
func (l *List) LessThanOrEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
LessThanOrEqual 对值进行小于等于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*List) Mod ¶
Mod 对值进行取模运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*List) Multiply ¶
func (l *List) Multiply(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
Multiply 对值进行乘法运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果(重复后的新列表) error - 可能出现的错误
func (*List) Negative ¶
Negative 对值进行负运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*List) Not ¶
Not 对值进行逻辑非运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*List) NotEqual ¶
func (l *List) NotEqual(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
NotEqual 判断当前值与另一个值是否不相等
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
布尔值,表示比较结果;无错误
比较规则:
- 与*Null类型比较:返回false
- 与其他类型比较:返回true
func (*List) Or ¶
Or 对值进行逻辑或运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*List) RightShift ¶
RightShift 对值进行右移运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*List) Set ¶
func (l *List) Set(index Object, value Object, posStart, posEnd *util.Pos, frame *frame.Frame) error
Set 设置索引位置的值
参数:
index - 索引值 value - 要设置的值 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
error - 可能出现的错误
type MathError ¶
type MathError struct {
Frame *frame.Frame // 错误发生时的调用栈
Message string // 错误描述文本
PosStart *util.Pos // 错误起始位置
PosEnd *util.Pos // 错误结束位置
}
MathError 数学错误类型,表示数学运算相关的错误 例如除以零、数值溢出、无效的数学函数参数等 拥有完整的错误跟踪和格式化能力
type Namespace ¶ added in v0.3.0
type Namespace struct {
Name string
Member *Environment
}
Namespace 表示命名空间类型,实现了Object接口 用于表示命名空间
func (*Namespace) Add ¶ added in v0.3.0
Add 对值进行加法运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Namespace) And ¶ added in v0.3.0
And 对值进行逻辑与运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Namespace) BitAnd ¶ added in v0.3.0
func (n *Namespace) BitAnd(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
BitAnd 对值进行按位与运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Namespace) BitNot ¶ added in v0.3.0
BitNot 对值进行按位非运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Namespace) BitOr ¶ added in v0.3.0
BitOr 对值进行按位或运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Namespace) Divide ¶ added in v0.3.0
func (n *Namespace) Divide(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
Divide 对值进行除法运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Namespace) Equal ¶ added in v0.3.0
func (n *Namespace) Equal(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
Equal 判断当前值与另一个值是否相等
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Namespace) GreaterThan ¶ added in v0.3.0
func (n *Namespace) GreaterThan(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
GreaterThan 对值进行大于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*Namespace) GreaterThanOrEqual ¶ added in v0.3.0
func (n *Namespace) GreaterThanOrEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
GreaterThanOrEqual 对值进行大于等于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*Namespace) Index ¶ added in v0.3.0
func (n *Namespace) Index(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
Index 执行索引运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Namespace) LeftShift ¶ added in v0.3.0
func (n *Namespace) LeftShift(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
LeftShift 对值进行左移运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Namespace) LessThan ¶ added in v0.3.0
func (n *Namespace) LessThan(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
LessThan 对值进行小于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*Namespace) LessThanOrEqual ¶ added in v0.3.0
func (n *Namespace) LessThanOrEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
LessThanOrEqual 对值进行小于等于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*Namespace) Mod ¶ added in v0.3.0
Mod 对值进行取模运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Namespace) Multiply ¶ added in v0.3.0
func (n *Namespace) Multiply(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
Multiply 对值进行乘法运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Namespace) Negative ¶ added in v0.3.0
Negative 对值进行负运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Namespace) Not ¶ added in v0.3.0
Not 对值进行逻辑非运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Namespace) NotEqual ¶ added in v0.3.0
func (n *Namespace) NotEqual(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
NotEqual 判断当前值与另一个值是否不相等
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Namespace) Or ¶ added in v0.3.0
Or 对值进行逻辑或运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Namespace) RightShift ¶ added in v0.3.0
func (n *Namespace) RightShift(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
RightShift 对值进行右移运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Namespace) Subtract ¶ added in v0.3.0
func (n *Namespace) Subtract(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
Subtract 对值进行减法运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
type Null ¶
type Null struct{}
Null 表示空值类型,实现了Object接口 用于表示不存在的值或空值
func (*Null) Add ¶
Add 对值进行加法运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Null) And ¶
And 对值进行逻辑与运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Null) BitAnd ¶
BitAnd 对值进行按位与运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Null) BitNot ¶
BitNot 对值进行按位非运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Null) BitOr ¶
BitOr 对值进行按位或运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Null) Divide ¶
Divide 对值进行除法运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Null) Equal ¶
Equal 判断当前值与另一个值是否相等
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
布尔值,表示比较结果;无错误
比较规则:
- 与*Null类型比较:返回true
- 与其他类型比较:返回false
func (*Null) GreaterThan ¶
func (n *Null) GreaterThan(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
GreaterThan 对值进行大于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*Null) GreaterThanOrEqual ¶
func (n *Null) GreaterThanOrEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
GreaterThanOrEqual 对值进行大于等于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*Null) Index ¶
Index 执行索引运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Null) LeftShift ¶
LeftShift 对值进行左移运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Null) LessThan ¶
LessThan 对值进行小于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*Null) LessThanOrEqual ¶
func (n *Null) LessThanOrEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
LessThanOrEqual 对值进行小于等于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*Null) Mod ¶
Mod 对值进行取模运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Null) Multiply ¶
Multiply 对值进行乘法运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Null) Negative ¶
Negative 对值进行负运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Null) Not ¶
Not 对值进行逻辑非运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Null) NotEqual ¶
NotEqual 判断当前值与另一个值是否不相等
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
布尔值,表示比较结果;无错误
比较规则:
- 与*Null类型比较:返回false
- 与其他类型比较:返回true
func (*Null) Or ¶
Or 对值进行逻辑或运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*Null) RightShift ¶
RightShift 对值进行右移运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
type Number ¶
type Number interface {
Object
}
Number 数值类型接口,定义所有数值类型共有的操作 实现此接口的类型包括Int和Float 接口方法包括算术运算、位运算等数值操作
type Object ¶
type Object interface {
// Type 返回值的类型
//
// 返回值:
//
// string - 值的类型
Type() string
// String 返回值的字符串表示
//
// 返回值:
//
// string - 格式化的字符串表示
String() string
// Negative 对值进行负运算
//
// 参数:
//
// posStart - 表达式起始位置
// posEnd - 表达式结束位置
// frame - 当前调用栈
//
// 返回值:
//
// Object - 运算结果
// error - 可能出现的错误
Negative(posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
// BitNot 对值进行按位非运算
//
// 参数:
//
// posStart - 表达式起始位置
// posEnd - 表达式结束位置
// frame - 当前调用栈
//
// 返回值:
//
// Object - 运算结果
// error - 可能出现的错误
BitNot(posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
// Not 对值进行逻辑非运算
//
// 参数:
//
// posStart - 表达式起始位置
// posEnd - 表达式结束位置
// frame - 当前调用栈
//
// 返回值:
//
// Object - 运算结果
// error - 可能出现的错误
Not(posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
// Add 对值进行加法运算
//
// 参数:
//
// other - 另一个操作数
// posStart - 表达式起始位置
// posEnd - 表达式结束位置
// frame - 当前调用栈
//
// 返回值:
//
// Object - 运算结果
// error - 可能出现的错误
Add(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
// Subtract 对值进行减法运算
//
// 参数:
//
// other - 另一个操作数
// posStart - 表达式起始位置
// posEnd - 表达式结束位置
// frame - 当前调用栈
//
// 返回值:
//
// Object - 运算结果
// error - 可能出现的错误
Subtract(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
// Multiply 对值进行乘法运算
//
// 参数:
//
// other - 另一个操作数
// posStart - 表达式起始位置
// posEnd - 表达式结束位置
// frame - 当前调用栈
//
// 返回值:
//
// Object - 运算结果
// error - 可能出现的错误
Multiply(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
// Divide 对值进行除法运算
//
// 参数:
//
// other - 另一个操作数
// posStart - 表达式起始位置
// posEnd - 表达式结束位置
// frame - 当前调用栈
//
// 返回值:
//
// Object - 运算结果
// error - 可能出现的错误
Divide(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
// Mod 对值进行取模运算
//
// 参数:
//
// other - 另一个操作数
// posStart - 表达式起始位置
// posEnd - 表达式结束位置
// frame - 当前调用栈
//
// 返回值:
//
// Object - 运算结果
// error - 可能出现的错误
Mod(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
// Equal 对值进行等于比较
//
// 参数:
//
// other - 另一个操作数
// posStart - 表达式起始位置
// posEnd - 表达式结束位置
// frame - 当前调用栈
//
// 返回值:
//
// Object - 比较结果
Equal(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
// NotEqual 对值进行不等于比较
//
// 参数:
//
// other - 另一个操作数
// posStart - 表达式起始位置
// posEnd - 表达式结束位置
// frame - 当前调用栈
//
// 返回值:
//
// Object - 比较结果
NotEqual(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
// LessThan 对值进行小于比较
//
// 参数:
//
// other - 另一个操作数
// posStart - 表达式起始位置
// posEnd - 表达式结束位置
// frame - 当前调用栈
//
// 返回值:
//
// Object - 比较结果
LessThan(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
// GreaterThan 对值进行大于比较
//
// 参数:
//
// other - 另一个操作数
// posStart - 表达式起始位置
// posEnd - 表达式结束位置
// frame - 当前调用栈
//
// 返回值:
//
// Object - 比较结果
GreaterThan(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
// LessThanOrEqual 对值进行小于等于比较
//
// 参数:
//
// other - 另一个操作数
// posStart - 表达式起始位置
// posEnd - 表达式结束位置
// frame - 当前调用栈
//
// 返回值:
//
// Object - 比较结果
LessThanOrEqual(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
// GreaterThanOrEqual 对值进行大于等于比较
//
// 参数:
//
// other - 另一个操作数
// posStart - 表达式起始位置
// posEnd - 表达式结束位置
// frame - 当前调用栈
//
// 返回值:
//
// Object - 比较结果
GreaterThanOrEqual(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
// BitAnd 对值进行按位与运算
//
// 参数:
//
// other - 另一个操作数
// posStart - 表达式起始位置
// posEnd - 表达式结束位置
// frame - 当前调用栈
//
// 返回值:
//
// Object - 运算结果
// error - 可能出现的错误
BitAnd(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
// BitOr 对值进行按位或运算
//
// 参数:
//
// other - 另一个操作数
// posStart - 表达式起始位置
// posEnd - 表达式结束位置
// frame - 当前调用栈
//
// 返回值:
//
// Object - 运算结果
// error - 可能出现的错误
BitOr(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
// Xor 对值进行异或运算
//
// 参数:
//
// other - 另一个操作数
// posStart - 表达式起始位置
// posEnd - 表达式结束位置
// frame - 当前调用栈
//
// 返回值:
//
// Object - 运算结果
// error - 可能出现的错误
Xor(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
// LeftShift 对值进行左移运算
//
// 参数:
//
// other - 另一个操作数
// posStart - 表达式起始位置
// posEnd - 表达式结束位置
// frame - 当前调用栈
//
// 返回值:
//
// Object - 运算结果
// error - 可能出现的错误
LeftShift(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
// RightShift 对值进行右移运算
//
// 参数:
//
// other - 另一个操作数
// posStart - 表达式起始位置
// posEnd - 表达式结束位置
// frame - 当前调用栈
//
// 返回值:
//
// Object - 运算结果
// error - 可能出现的错误
RightShift(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
// And 对值进行逻辑与运算
//
// 参数:
//
// other - 另一个操作数
// posStart - 表达式起始位置
// posEnd - 表达式结束位置
// frame - 当前调用栈
//
// 返回值:
//
// Object - 运算结果
// error - 可能出现的错误
And(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
// Or 对值进行逻辑或运算
//
// 参数:
//
// other - 另一个操作数
// posStart - 表达式起始位置
// posEnd - 表达式结束位置
// frame - 当前调用栈
//
// 返回值:
//
// Object - 运算结果
// error - 可能出现的错误
Or(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
// Index 对值进行索引运算
//
// 参数:
//
// other - 另一个操作数
// posStart - 表达式起始位置
// posEnd - 表达式结束位置
// frame - 当前调用栈
//
// 返回值:
//
// Object - 运算结果
// error - 可能出现的错误
Index(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
}
Value 运行时值接口,定义所有可计算值的通用操作 实现此接口的类型包括整数、浮点数、字符串、函数等
type OperationError ¶
type OperationError struct {
Frame *frame.Frame // 错误发生时的调用栈
Message string // 错误描述文本
PosStart *util.Pos // 错误起始位置
PosEnd *util.Pos // 错误结束位置
}
OperationError 操作错误类型,表示执行不支持的操作时发生的错误 例如对不兼容类型执行运算、调用未定义的方法等 拥有完整的错误跟踪和格式化能力
func (*OperationError) Error ¶
func (e *OperationError) Error() string
Error 生成格式化的操作错误信息字符串 前缀为"Operation Error"
返回值:
string - 格式化的操作错误信息,格式同基础Error但错误类型为"Operation Error"
type ReturnValue ¶
type ReturnValue struct {
Value Object // 返回的值
}
ReturnValue 返回值
func (*ReturnValue) Add ¶
func (rv *ReturnValue) Add(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
Add 对值进行加法运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*ReturnValue) And ¶
func (rv *ReturnValue) And(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
And 对值进行逻辑与运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*ReturnValue) BitAnd ¶
func (rv *ReturnValue) BitAnd(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
BitAnd 对值进行按位与运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*ReturnValue) BitNot ¶
BitNot 对值进行按位非运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*ReturnValue) BitOr ¶
func (rv *ReturnValue) BitOr(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
BitOr 对值进行按位或运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*ReturnValue) Divide ¶
func (rv *ReturnValue) Divide(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
Divide 对值进行除法运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*ReturnValue) Equal ¶
func (rv *ReturnValue) Equal(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
Equal 判断当前空值与另一个值是否相等
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*ReturnValue) GreaterThan ¶
func (rv *ReturnValue) GreaterThan(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
GreaterThan 对值进行大于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*ReturnValue) GreaterThanOrEqual ¶
func (rv *ReturnValue) GreaterThanOrEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
GreaterThanOrEqual 对值进行大于等于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*ReturnValue) Index ¶
func (rv *ReturnValue) Index(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
Index 执行索引运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*ReturnValue) LeftShift ¶
func (rv *ReturnValue) LeftShift(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
LeftShift 对值进行左移运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*ReturnValue) LessThan ¶
func (rv *ReturnValue) LessThan(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
LessThan 对值进行小于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*ReturnValue) LessThanOrEqual ¶
func (rv *ReturnValue) LessThanOrEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
LessThanOrEqual 对值进行小于等于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*ReturnValue) Mod ¶
func (rv *ReturnValue) Mod(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
Mod 对值进行取模运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*ReturnValue) Multiply ¶
func (rv *ReturnValue) Multiply(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
Multiply 对值进行乘法运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*ReturnValue) Negative ¶
Negative 对值进行负运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*ReturnValue) Not ¶
Not 对值进行逻辑非运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*ReturnValue) NotEqual ¶
func (rv *ReturnValue) NotEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
NotEqual 判断当前空值与另一个值是否不相等
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*ReturnValue) Or ¶
Or 对值进行逻辑或运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*ReturnValue) RightShift ¶
func (rv *ReturnValue) RightShift(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
RightShift 对值进行右移运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*ReturnValue) String ¶
func (rv *ReturnValue) String() string
String 返回值的字符串表示
返回值:
string - 格式化的字符串表示
type String ¶
type String struct {
Value string // 字符串的实际值
}
String 表示字符串值类型,实现了Object接口 用于存储和操作文本数据
func (*String) Add ¶
Add 实现字符串的加法运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
运算结果;若操作失败则返回运行时错误
支持的操作:
- 与*String类型相加:返回连接后的新字符串
- 与其他类型相加:返回操作错误
func (*String) And ¶
And 对值进行逻辑与运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*String) BitAnd ¶
BitAnd 对值进行按位与运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*String) BitNot ¶
BitNot 对值进行按位非运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*String) BitOr ¶
BitOr 对值进行按位或运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*String) Divide ¶
Divide 对值进行除法运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*String) Equal ¶
Equal 判断当前字符串与另一个值是否相等
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
布尔值,表示比较结果;若操作失败则返回运行时错误
支持的比较:
- 与*String类型比较:比较字符串内容是否相同
- 与*Null类型比较:始终返回false
- 与其他类型比较:返回操作错误
func (*String) GreaterThan ¶
func (s *String) GreaterThan(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
GreaterThan 对值进行大于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*String) GreaterThanOrEqual ¶
func (s *String) GreaterThanOrEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
GreaterThanOrEqual 对值进行大于等于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*String) Index ¶
func (s *String) Index(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
Index 执行索引运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*String) LeftShift ¶
func (s *String) LeftShift(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
LeftShift 对值进行左移运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*String) LessThan ¶
LessThan 对值进行小于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*String) LessThanOrEqual ¶
func (s *String) LessThanOrEqual(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
LessThanOrEqual 对值进行小于等于比较
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 比较结果
func (*String) Mod ¶
Mod 对值进行取模运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*String) Multiply ¶
func (s *String) Multiply(other Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
Multiply 实现字符串的乘法运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
运算结果;若操作失败则返回运行时错误
支持的操作:
- 与*Int类型相乘:返回重复指定次数的新字符串
- 若整数为负数或超过math.MaxInt:返回操作错误
- 与其他类型相乘:返回操作错误
func (*String) Negative ¶
Negative 对值进行负运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*String) Not ¶
Not 对值进行逻辑非运算
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*String) NotEqual ¶
NotEqual 判断当前字符串与另一个值是否不相等
参数:
posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
布尔值,表示比较结果;若操作失败则返回运行时错误
支持的比较:
- 与*String类型比较:比较字符串内容是否不同
- 与*Null类型比较:始终返回true
- 与其他类型比较:返回操作错误
func (*String) Or ¶
Or 对值进行逻辑或运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*String) RightShift ¶
func (s *String) RightShift(_ Object, posStart, posEnd *util.Pos, frame *frame.Frame) (Object, error)
RightShift 对值进行右移运算
参数:
other - 另一个操作数 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
Object - 运算结果 error - 可能出现的错误
func (*String) Set ¶
func (s *String) Set(index Object, value Object, posStart, posEnd *util.Pos, frame *frame.Frame) error
Set 设置索引位置的值
参数:
index - 索引值 value - 要设置的值 posStart - 表达式起始位置 posEnd - 表达式结束位置 frame - 当前调用栈
返回值:
error - 可能出现的错误