Documentation
¶
Index ¶
- Constants
- type ArrayObject
- type BaseClass
- type BooleanObject
- type BuiltInMethodObject
- type Class
- type Error
- type FileObject
- type HashObject
- type IntegerObject
- type MethodObject
- type NullObject
- type Object
- type Pointer
- type RArray
- type RBool
- type RClass
- type RHash
- type RInteger
- type RMethod
- type RNull
- type RObject
- type RString
- type StringObject
- type VM
Constants ¶
const ( // UndefinedMethodError describes the error type in string UndefinedMethodError = "UndefinedMethodError" // ArgumentError describes the error type in string ArgumentError = "ArgumentError" // TypeError describes the error type in string TypeError = "TypeError" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArrayObject ¶
ArrayObject represents instance from Array class. An array is a collection of different objects that are ordered and indexed. Elements in an array can belong to any class.
func (*ArrayObject) Inspect ¶
func (a *ArrayObject) Inspect() string
Inspect returns detailed info of a array include elements it contains
type BaseClass ¶
type BaseClass struct { // Name is the class's name Name string // Methods contains its instances' methods Methods *environment // ClassMethods contains this class's methods ClassMethods *environment // Class points to this class's class, which should be ClassClass Class *RClass // Singleton is a flag marks if this class a singleton class Singleton bool // contains filtered or unexported fields }
BaseClass is a embedded struct that contains all the essential fields for a class
func (*BaseClass) Inspect ¶
Inspect returns the basic inspected result (which is class name) of current class TODO: Singleton class's inspect() should also mark if it's a singleton class explicitly.
func (*BaseClass) ReturnName ¶
ReturnName returns the name of the class
type BooleanObject ¶
BooleanObject represents boolean object in goby. It includes `true` and `FALSE` which represents logically true and false value.
var ( // TRUE is shared boolean object that represents true TRUE *BooleanObject // FALSE is shared boolean object that represents false FALSE *BooleanObject )
func (*BooleanObject) Inspect ¶
func (b *BooleanObject) Inspect() string
Inspect returns boolean object's value, which is either true or false.
type BuiltInMethodObject ¶ added in v0.0.5
type BuiltInMethodObject struct { Name string Fn func(receiver Object) builtinMethodBody // contains filtered or unexported fields }
BuiltInMethodObject represents methods defined in go.
func (*BuiltInMethodObject) Inspect ¶ added in v0.0.5
func (bim *BuiltInMethodObject) Inspect() string
Inspect just returns built in method's name.
type Class ¶
Class is an interface that implements a class's basic functions.
- lookupClassMethod: search for current class's class method with given name. - lookupInstanceMethod: search for current class's instance method with given name. - ReturnName returns class's name
type FileObject ¶ added in v0.0.6
FileObject is a special type that contains file pointer so we can keep track on target file.
func (*FileObject) Inspect ¶ added in v0.0.6
func (f *FileObject) Inspect() string
Inspect returns detailed infoof a array include elements it contains
type HashObject ¶
HashObject represents hash instances
func (*HashObject) Inspect ¶
func (h *HashObject) Inspect() string
func (*HashObject) Length ¶
func (h *HashObject) Length() int
type IntegerObject ¶
IntegerObject represents number objects which can bring into mathematical calculations.
```ruby 1 + 1 # => 2 2 * 2 # => 4 ```
func (*IntegerObject) Inspect ¶
func (i *IntegerObject) Inspect() string
type MethodObject ¶ added in v0.0.5
type MethodObject struct { Name string // contains filtered or unexported fields }
MethodObject represents methods defined using goby.
func (*MethodObject) Inspect ¶ added in v0.0.5
func (m *MethodObject) Inspect() string
Inspect returns method's name, params count and instruction set.
type NullObject ¶ added in v0.0.5
type NullObject struct {
Class *RNull
}
NullObject represnts the null value in Goby.
var ( // NULL represents Goby's null objects. NULL *NullObject )
func (*NullObject) Inspect ¶ added in v0.0.5
func (n *NullObject) Inspect() string
Inspect returns the name of NullObject
type Object ¶
type Object interface { Inspect() string // contains filtered or unexported methods }
Object represents all objects in Goby, including Array, Integer or even Method and Error.
type Pointer ¶
type Pointer struct {
Target Object
}
Pointer is used to point to an object. Variables should hold pointer instead of holding a object directly.
type RBool ¶
type RBool struct {
*BaseClass
}
RBool is the built in class of goby's boolean objects.
type RClass ¶
type RClass struct {
*BaseClass
}
RClass represents normal (not built in) class object
type RMethod ¶ added in v0.0.5
type RMethod struct {
*BaseClass
}
RMethod represents all method's class. Currently has no methods.
type RObject ¶
type RObject struct { Class *RClass InstanceVariables *environment InitializeMethod *MethodObject }
RObject represents any non built-in class's instance.
type StringObject ¶
StringObject represents string instances
func (*StringObject) Inspect ¶
func (s *StringObject) Inspect() string
type VM ¶
type VM struct {
// contains filtered or unexported fields
}
VM represents a stack based virtual machine.
func (*VM) ExecBytecodes ¶
ExecBytecodes accepts a sequence of bytecodes and use vm to evaluate them.
func (*VM) GetExecResult ¶
GetExecResult returns stack's top most value. Normally it's used in tests.