MysoreScript
Classes | Typedefs | Functions | Variables
MysoreScript Namespace Reference

Classes

struct  Array
 The layout of the primitive Array class in MysoreScript. More...
 
struct  Class
 Struct holding metadata about a class. More...
 
struct  Closure
 The layout of all closures in MysoreScript. More...
 
struct  Method
 Methods in a class's method list. More...
 
struct  Object
 A generic MysoreScript object. More...
 
struct  String
 The primitive String class in MysoreScript. More...
 

Typedefs

typedef ObjectObj
 Object pointer. More...
 
typedef uint32_t Selector
 Selectors are unique identifiers for methods. More...
 
typedef Object *(* CompiledMethod) (Object *, Selector,...)
 A compiled method is a function that takes an object (the receiver) and the selector as implicit arguments and then any other explicit arguments. More...
 
typedef Object *(* ClosureInvoke) (Closure *,...)
 A compiled closure invoke function. More...
 

Functions

Selector lookupSelector (const std::string &)
 Looks up the selector for a specified string value, registering a new value if this is the first time the mapping has been needed. More...
 
void registerClass (const std::string &name, struct Class *cls)
 Register a newly constructed class. More...
 
struct ClasslookupClass (const std::string &name)
 Look up an existing class. More...
 
Obj newObject (struct Class *cls)
 Instantiate an object. More...
 
MethodmethodForSelector (Class *, Selector)
 Looks up the Method that should be invoked for the specified selector on this class. More...
 
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. More...
 
Obj callCompiledClosure (ClosureInvoke m, Closure *receiver, Obj *args, int argCount)
 Calls a compiled closure from the specified argument list. More...
 
Obj mysoreScriptAdd (Obj lhs, Obj rhs)
 Helper function called by compiled code for the + operator on objects that are not small (embedded in a pointer) integers. More...
 
Obj mysoreScriptSub (Obj lhs, Obj rhs)
 Helper function called by compiled code for the - operator on objects that are not small (embedded in a pointer) integers. More...
 
Obj mysoreScriptMul (Obj lhs, Obj rhs)
 Helper function called by compiled code for the * operator on objects that are not small (embedded in a pointer) integers. More...
 
Obj mysoreScriptDiv (Obj lhs, Obj rhs)
 Helper function called by compiled code for the / operator on objects that are not small (embedded in a pointer) integers. More...
 
CompiledMethod compiledMethodForSelector (Obj obj, Selector sel)
 Look up the compiled method to call for a specific selector. More...
 
bool isInteger (Obj o)
 Is this object a small integer (lowest bit is 1, next two bits are 0). More...
 
intptr_t getInteger (Obj o)
 Assuming that o is a small integer (an integer embedded in a pointer), return it as a C integer. More...
 
Obj createSmallInteger (intptr_t i)
 Construct a small integer object from the given integer. More...
 

Variables

struct Class StringClass
 The String class structure. More...
 
struct Class FileClass
 The File class structure. More...
 
struct Class ArrayClass
 The Array class structure. More...
 
struct Class SmallIntClass
 The SmallInt (Number) class structure. More...
 
struct Class ClosureClass
 The Closure class structure. More...
 

Typedef Documentation

§ ClosureInvoke

typedef Object*(* MysoreScript::ClosureInvoke) (Closure *,...)

A compiled closure invoke function.

This takes the closure as an implicit argument and then other explicit arguments.

Definition at line 80 of file runtime.hh.

§ CompiledMethod

typedef Object*(* MysoreScript::CompiledMethod) (Object *, Selector,...)

A compiled method is a function that takes an object (the receiver) and the selector as implicit arguments and then any other explicit arguments.

Definition at line 75 of file runtime.hh.

§ Obj

Object pointer.

Objects are either pointers or small objects hidden inside the pointer.

Definition at line 33 of file runtime.hh.

§ Selector

typedef uint32_t MysoreScript::Selector

Selectors are unique identifiers for methods.

When a method name is registered, it is assigned a unique number.

Definition at line 70 of file runtime.hh.

Function Documentation

§ callCompiledClosure()

Obj MysoreScript::callCompiledClosure ( ClosureInvoke  m,
Closure receiver,
Obj args,
int  argCount 
)

Calls a compiled closure from the specified argument list.

Definition at line 656 of file runtime.cc.

Here is the caller graph for this function:

§ callCompiledMethod()

Obj MysoreScript::callCompiledMethod ( CompiledMethod  m,
Obj  receiver,
Selector  sel,
Obj args,
int  argCount 
)

Calls a compiled method, constructing the correct argument frame based on the arguments.

Definition at line 632 of file runtime.cc.

Here is the caller graph for this function:

§ compiledMethodForSelector()

CompiledMethod MysoreScript::compiledMethodForSelector ( Obj  obj,
Selector  sel 
)

Look up the compiled method to call for a specific selector.

This is called by compiled code to perform method lookups. If a method has not yet been compiled, the Method structure should be initialised with a trampoline function that jumps back into the interpreter.

Definition at line 697 of file runtime.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

§ createSmallInteger()

Obj MysoreScript::createSmallInteger ( intptr_t  i)
inline

Construct a small integer object from the given integer.

Definition at line 59 of file runtime.hh.

Here is the caller graph for this function:

§ getInteger()

intptr_t MysoreScript::getInteger ( Obj  o)
inline

Assuming that o is a small integer (an integer embedded in a pointer), return it as a C integer.

Definition at line 51 of file runtime.hh.

Here is the call graph for this function:
Here is the caller graph for this function:

§ isInteger()

bool MysoreScript::isInteger ( Obj  o)
inline

Is this object a small integer (lowest bit is 1, next two bits are 0).

Definition at line 43 of file runtime.hh.

Here is the caller graph for this function:

§ lookupClass()

struct Class * MysoreScript::lookupClass ( const std::string &  name)

Look up an existing class.

Definition at line 601 of file runtime.cc.

Here is the caller graph for this function:

§ lookupSelector()

Selector MysoreScript::lookupSelector ( const std::string &  )

Looks up the selector for a specified string value, registering a new value if this is the first time the mapping has been needed.

Definition at line 553 of file runtime.cc.

Here is the caller graph for this function:

§ methodForSelector()

Method * MysoreScript::methodForSelector ( Class cls,
Selector  sel 
)

Looks up the Method that should be invoked for the specified selector on this class.

Definition at line 615 of file runtime.cc.

Here is the caller graph for this function:

§ mysoreScriptAdd()

Obj MysoreScript::mysoreScriptAdd ( Obj  lhs,
Obj  rhs 
)

Helper function called by compiled code for the + operator on objects that are not small (embedded in a pointer) integers.

Definition at line 681 of file runtime.cc.

Here is the call graph for this function:

§ mysoreScriptDiv()

Obj MysoreScript::mysoreScriptDiv ( Obj  lhs,
Obj  rhs 
)

Helper function called by compiled code for the / operator on objects that are not small (embedded in a pointer) integers.

Definition at line 693 of file runtime.cc.

Here is the call graph for this function:

§ mysoreScriptMul()

Obj MysoreScript::mysoreScriptMul ( Obj  lhs,
Obj  rhs 
)

Helper function called by compiled code for the * operator on objects that are not small (embedded in a pointer) integers.

Definition at line 689 of file runtime.cc.

Here is the call graph for this function:

§ mysoreScriptSub()

Obj MysoreScript::mysoreScriptSub ( Obj  lhs,
Obj  rhs 
)

Helper function called by compiled code for the - operator on objects that are not small (embedded in a pointer) integers.

Definition at line 685 of file runtime.cc.

Here is the call graph for this function:

§ newObject()

Obj MysoreScript::newObject ( struct Class cls)

Instantiate an object.

This returns a new instance of the class with all of its instance variables set to null.

Definition at line 606 of file runtime.cc.

Here is the caller graph for this function:

§ registerClass()

void MysoreScript::registerClass ( const std::string &  name,
struct Class cls 
)

Register a newly constructed class.

Definition at line 596 of file runtime.cc.

Here is the caller graph for this function:

Variable Documentation

§ ArrayClass

struct Class MysoreScript::ArrayClass
Initial value:
=
{
NULL,
"Array",
sizeof(ArrayMethods) / sizeof(Method),
sizeof(ArrayIvars) / sizeof(char*),
}
const char * ArrayIvars[]
The names of the instance variables in the Array class.
Definition: runtime.cc:479
Methods in a class's method list.
Definition: runtime.hh:85
struct Method ArrayMethods[]
Method table for the Array class.
Definition: runtime.cc:451

The Array class structure.

Definition at line 516 of file runtime.cc.

§ ClosureClass

struct Class MysoreScript::ClosureClass
Initial value:
=
{
NULL,
"Closure",
0,
0,
nullptr,
nullptr
}

The Closure class structure.

The class used for closures.

Definition at line 543 of file runtime.cc.

§ FileClass

struct Class MysoreScript::FileClass
Initial value:
=
{
NULL,
"File",
sizeof(FileMethods) / sizeof(Method),
sizeof(FileIvars) / sizeof(char*),
}
struct Method FileMethods[]
Methods for the file class.
Definition: runtime.cc:361
const char * FileIvars[]
The names of the instance variables in the File class.
Definition: runtime.cc:483
Methods in a class's method list.
Definition: runtime.hh:85

The File class structure.

Definition at line 504 of file runtime.cc.

§ SmallIntClass

struct Class MysoreScript::SmallIntClass
Initial value:
=
{
NULL,
"Number",
sizeof(NumberMethods) / sizeof(Method),
0,
nullptr
}
struct Method NumberMethods[]
Method table for the Number class.
Definition: runtime.cc:433
Methods in a class's method list.
Definition: runtime.hh:85

The SmallInt (Number) class structure.

The class used for small integers.

This is distinct from Number because a future implementation may implement Number as both SmallInt and BigInt classes internally, which both appear as instances of the Number class.

Definition at line 531 of file runtime.cc.

§ StringClass

struct Class MysoreScript::StringClass
Initial value:
=
{
NULL,
"String",
sizeof(StringMethods) / sizeof(Method),
sizeof(StringIvars) / sizeof(char*),
}
struct Method StringMethods[]
Method table for the String class.
Definition: runtime.cc:391
const char * StringIvars[]
The names of the instance variables in the String class.
Definition: runtime.cc:475
Methods in a class's method list.
Definition: runtime.hh:85

The String class structure.

The class used for strings.

Definition at line 492 of file runtime.cc.