Documentation
¶
Index ¶
Constants ¶
View Source
const (
VoidType = iota
)
Variables ¶
View Source
var AccountType = &ClassType{ Name: "Account", InstanceFields: &FieldMap{ Data: map[string]*Field{ "name": { Type: &ast.TypeRef{Name: []string{"String"}}, Name: "name", Modifiers: []ast.Node{ &ast.Modifier{ Name: "public", }, }, }, "website": { Type: &ast.TypeRef{Name: []string{"String"}}, Name: "website", Modifiers: []ast.Node{ &ast.Modifier{ Name: "public", }, }, }, "field1__c": { Type: &ast.TypeRef{Name: []string{"String"}}, Name: "field1__c", Modifiers: []ast.Node{ &ast.Modifier{ Name: "public", }, }, }, }, }, }
View Source
var BooleanType = &ClassType{
Name: "Boolean",
}
View Source
var DoubleType = &ClassType{
Name: "Double",
}
View Source
var IntegerType = &ClassType{
Name: "Integer",
}
View Source
var ListType = &ClassType{ Name: "List", Modifiers: []ast.Node{ &ast.Modifier{ Name: "public", }, }, Constructors: []*ast.ConstructorDeclaration{ { Modifiers: []ast.Node{ &ast.Modifier{ Name: "public", }, }, Parameters: []ast.Node{}, NativeFunction: func(params []interface{}) {}, }, { Modifiers: []ast.Node{ &ast.Modifier{ Name: "public", }, }, Parameters: []ast.Node{ &ast.Parameter{ Type: &ast.TypeRef{ Name: []string{"List"}, Parameters: []ast.Node{ &ast.TypeRef{ Name: []string{"T:1"}, }, }, }, Name: "list", }, }, NativeFunction: func(params []interface{}) { listObj := params[1].(*Object) listParams := listObj.Extra["records"].([]*Object) newListParams := make([]*Object, len(listParams)) for i, listParam := range listParams { newListParams[i] = &Object{ ClassType: listParam.ClassType, } } this := params[0].(*Object) this.Extra = map[string]interface{}{ "records": newListParams, } }, }, }, InstanceFields: NewFieldMap(), InstanceMethods: &MethodMap{ Data: map[string][]ast.Node{ "size": { &ast.MethodDeclaration{ Name: "size", Modifiers: []ast.Node{ &ast.Modifier{Name: "public"}, }, NativeFunction: func(this interface{}, params []interface{}, options ...interface{}) interface{} { thisObj := this.(*Object) return len(thisObj.Extra["records"].([]*Object)) }, }, }, "isNext": { &ast.MethodDeclaration{ Name: "next", NativeFunction: func(this interface{}, params []interface{}, options ...interface{}) interface{} { thisObj := this.(*Object) counter := thisObj.Extra["counter"].(int) return thisObj.Extra["records"].([]*Object)[counter] }, }, }, "next": { &ast.MethodDeclaration{ Name: "next", NativeFunction: func(this interface{}, params []interface{}, options ...interface{}) interface{} { thisObj := this.(*Object) counter := thisObj.Extra["counter"].(int) return thisObj.Extra["records"].([]*Object)[counter] }, }, }, }, }, }
View Source
var MapType = &ClassType{
Name: "Map",
}
View Source
var PrimitiveClasses []*ClassType
View Source
var SetType = &ClassType{
Name: "Set",
}
View Source
var StringType = &ClassType{
Name: "String",
}
View Source
var System = &ClassType{ Name: "System", StaticMethods: &MethodMap{ Data: map[string][]ast.Node{ "debug": { &ast.MethodDeclaration{ Name: "debug", Modifiers: []ast.Node{ &ast.Modifier{Name: "public"}, }, NativeFunction: func(this interface{}, parameter []interface{}, options ...interface{}) interface{} { o := parameter[0].(*Object) stdout := options[0].(io.Writer) fmt.Fprintln(stdout, String(o)) return nil }, }, }, "assertequals": { &ast.MethodDeclaration{ Name: "assertequals", Modifiers: []ast.Node{ &ast.Modifier{Name: "public"}, }, NativeFunction: func(this interface{}, parameter []interface{}, options ...interface{}) interface{} { expected := parameter[0].(*Object) actual := parameter[1].(*Object) if expected.Value() != actual.Value() { fmt.Printf("expected: %s, actual: %s\n", String(expected), String(actual)) } return nil }, }, }, }, }, }
Functions ¶
Types ¶
type ClassMap ¶
*
- ClassMap
func NewClassMap ¶
func NewClassMap() *ClassMap
func NewClassMapWithPrimivie ¶
func PrimitiveClassMap ¶
func PrimitiveClassMap() *ClassMap
type ClassType ¶
type ClassType struct { Annotations []ast.Node Modifiers []ast.Node Name string SuperClass ast.Node ImplementClasses []ast.Node Constructors []*ast.ConstructorDeclaration InstanceFields *FieldMap StaticFields *FieldMap InstanceMethods *MethodMap StaticMethods *MethodMap InnerClasses *ClassMap Extra map[string]interface{} Location *ast.Location Parent ast.Node }
func (*ClassType) IsPrimitive ¶
type Field ¶
type Field struct { Type ast.Node Modifiers []ast.Node Name string Expression ast.Node Location *ast.Location Parent ast.Node }
func (*Field) AccessModifier ¶
func (*Field) IsAbstract ¶
func (*Field) IsOverride ¶
func (*Field) IsProtected ¶
type FieldMap ¶
func NewFieldMap ¶
func NewFieldMap() *FieldMap
type MethodMap ¶
func NewMethodMap ¶
func NewMethodMap() *MethodMap
type NameSpaceStore ¶
*
- NameSpaces
func NewNameSpaceStore ¶
func NewNameSpaceStore() *NameSpaceStore
func (*NameSpaceStore) Add ¶
func (m *NameSpaceStore) Add(k string, n *ClassType)
func (*NameSpaceStore) Set ¶
func (m *NameSpaceStore) Set(k string, n *ClassMap)
type Object ¶
type Object struct { ClassType *ClassType InstanceFields *ObjectMap GenericType []*ClassType Extra map[string]interface{} ToString func(*Object) string }
func CreateObject ¶
func (*Object) DoubleValue ¶
func (*Object) IntegerValue ¶
func (*Object) StringValue ¶
type ToStringer ¶
type ToStringer struct {
Indent int
}
func (*ToStringer) AddIndent ¶
func (v *ToStringer) AddIndent(f func())
func (*ToStringer) String ¶
func (v *ToStringer) String(o *Object) string
Click to show internal directories.
Click to hide internal directories.