Skip to content

Instantly share code, notes, and snippets.

@swarley
Last active December 12, 2015 08:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swarley/4742592 to your computer and use it in GitHub Desktop.
Save swarley/4742592 to your computer and use it in GitHub Desktop.
package sixModel
type Object struct {
refcount, id, flags int
_type_ byte
methods, attributes *map[string]*Object
data PolymorphicData
}
type PolymorphicData interface{}
type STable struct {
data PolymorphicData
HOW, WHAT, WHO Object
methodCache *map[string]*Object
vtable, typeCheckCache []*Object
flags byte
typeCacheId int
containerSpec ContainerSpec
invocationSpec InvocationSpec
boolificationSpec BoolificationSpec
}
const (
BoolModeCallMethod = iota
BoolModeUnboxInt
BoolModeUnboxNum
BoolModeUnboxStrNotEmpty
BoolModeUnboxStrNotEmptyOrZero
BoolModeNotTypeObject
BoolModeBigInt
BoolModeIter
)
type BoolificationSpec struct {
mode int
method *Object
}
type ContainerSpec struct {
classHandle, fetchMethod *Object
hint int
attributeName string
}
type InvocationSpec struct {
classHandle, InvocationHandler *Object
hint int
attributeName string
}
const (
StorageReferenced = iota
StorageInlined
)
const (
StorageBpNone = iota
StorageBpInt
StorageBpNum
StorageBpStr
)
const (
StorageCanBoxInt = 1
StorageCanBoxNum = 2
StorageCanBoxStr = 4
)
type StorageSpec struct {
inlineable, bits, boxedPrimitive, canBox byte
}
type ReprInterface interface {
Allocate(st STable) Object
Compose(st STable, repr_info *Object)
HintFor(st STable, classHandle *Object, name string)
getStorageSpec(st STable) StorageSpec
getValueStorageSpec(st STable) StorageSpec
changeType(obj, new_type Object)
inlineStorage(st STable, c ClassGen, cp ConstantPoolGen, prefix string)
inlineBind(st STable, c ClassGen, cp ConstantPoolGen, prefix string) []Instruction
inlineGet(st STable, c ClassGen, cp ConstantPoolGen, prefix string) []Instruction
generateBoxingMethods(st STable, c ClassGen, cp ConstantPoolGen, prefix string)
}
type Repr struct { // Implement the ReprInterface
id int
name string
}
/* Implement Repr here as a base REPR class for future use */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment