8 static_assert(
sizeof(
void*) == 8,
9 "MysoreScript only supports 64-bit platforms currently");
20 size_t size =
sizeof(T) + extraBytes;
21 return reinterpret_cast<T*
>(GC_MALLOC(size));
45 return (reinterpret_cast<intptr_t>(o) & 7) == 1;
54 return reinterpret_cast<intptr_t
>(o) >> 3;
62 assert((i<<3)>>3 == i);
63 return reinterpret_cast<Obj
>(((i << 3) | 1));
struct Class * isa
The pointer to the class of this object.
Object *(* CompiledMethod)(Object *, Selector,...)
A compiled method is a function that takes an object (the receiver) and the selector as implicit argu...
Object * Obj
Object pointer.
Obj mysoreScriptAdd(Obj lhs, Obj rhs)
Helper function called by compiled code for the + operator on objects that are not small (embedded in...
Obj callCompiledClosure(ClosureInvoke m, Closure *receiver, Obj *args, int argCount)
Calls a compiled closure from the specified argument list.
Obj mysoreScriptDiv(Obj lhs, Obj rhs)
Helper function called by compiled code for the / operator on objects that are not small (embedded in...
uint32_t Selector
Selectors are unique identifiers for methods.
AST::ClosureDecl * AST
The AST for this closure.
Obj bufferSize
The size of the buffer.
const char ** indexedIVarNames
The names of the instance variables.
ClosureInvoke invoke
The function that is used to invoke this closure.
Class * isa
Class pointer.
struct Class SmallIntClass
The SmallInt (Number) class structure.
Class * isa
Class pointer.
struct Method * methodList
An array of methodCount elements describing the methods that this class implements.
Selector lookupSelector(const std::string &str)
Looks up the selector for a specified string value, registering a new value if this is the first time...
Obj newObject(struct Class *cls)
Instantiate an object.
Object *(* ClosureInvoke)(Closure *,...)
A compiled closure invoke function.
Obj mysoreScriptMul(Obj lhs, Obj rhs)
Helper function called by compiled code for the * operator on objects that are not small (embedded in...
void registerClass(const std::string &name, struct Class *cls)
Register a newly constructed class.
struct Class * lookupClass(const std::string &name)
Look up an existing class.
A generic MysoreScript object.
AST::ClosureDecl * AST
The AST for this method.
int32_t args
The number of arguments that this method takes.
struct Class StringClass
The String class structure.
struct Class ClosureClass
The Closure class structure.
Method * methodForSelector(Class *cls, Selector sel)
Looks up the Method that should be invoked for the specified selector on this class.
T * gcAlloc(size_t extraBytes=0)
Typesafe helper function for allocating garbage-collected memory.
CompiledMethod compiledMethodForSelector(Obj obj, Selector sel)
Look up the compiled method to call for a specific selector.
Class * isa
Class pointer.
Obj callCompiledMethod(CompiledMethod m, Obj receiver, Selector sel, Obj *args, int argCount)
Calls a compiled method, constructing the correct argument frame based on the arguments.
The layout of the primitive Array class in MysoreScript.
struct Class * superclass
The superclass of this class, if it has one, or a null pointer if it is a root class.
intptr_t getInteger(Obj o)
Assuming that o is a small integer (an integer embedded in a pointer), return it as a C integer...
int32_t methodCount
The number of methods that this class implements.
The primitive String class in MysoreScript.
int32_t indexedIVarCount
The number of indexed instance variables that this class has.
const char * className
The name of this class.
Obj createSmallInteger(intptr_t i)
Construct a small integer object from the given integer.
Obj * buffer
The buffer storing the values in this array.
Obj mysoreScriptSub(Obj lhs, Obj rhs)
Helper function called by compiled code for the - operator on objects that are not small (embedded in...
Obj length
Length of the array (number of elements in it).
Obj length
The number of characters in the string.
Struct holding metadata about a class.
Methods in a class's method list.
bool isInteger(Obj o)
Is this object a small integer (lowest bit is 1, next two bits are 0).
Obj parameters
The number of parameters that this object has.
The layout of all closures in MysoreScript.
Selector selector
The selector that this method applies to.