Getting to the Forth Interpreter

Here's a quick tour of how any given JavaScript *.abc file gets to the Forth interpreter. The entry point into the command line version of Tamarin is in avmshell.cpp. Let's see what is in here:

avmshell.cpp
main() {
// other GC stuff
int code = _main(argc, argv);
// post exit code
}

_main() {
// other stuff
avmshell::shell = new avmshell::Shell(&gc);
exitCode = avmshell::shell->main(argc, argv);
}

avmshell::shell::main() {
// Macro Fun
runShell(a_thrower);
}

void Shell::runShell(Thrower& p_thrower) {
// stuff
initBuiltinPool(a_thrower);
initShellPool(a_thrower);

handleActionPool(shellPool, domain, toplevel, codeContext, p_thrower);
}

Since the file includes a few files, handleActionPool is located in avmcore.cpp instead:
AvmCore.cpp
void AvmCore::handleActionPool(PoolObject* pool,
DomainEnv* domainEnv,
Toplevel* toplevel,
CodeContext* codeContext,
Thrower& p_thrower)
{
ScriptObject *global = prepEntryPoint(pool,domainEnv,toplevel,codeContext, p_thrower);
interp.interpScript(global);
}

Finally Interpreter.cpp finally calls the inner() function which was described in a previous post.

Interpreter.cpp
void Interpreter::interpScript(ScriptObject *global)
{
inner(f, CODE_POS(w_interp), sp, rp);
}

However, lets look at the hooks where .ABCs are actually parsed. In initBuiltinPool, all the builtin things are interpreted first, which sets up the JavaScript environment. Then looking at the initShellPool where the actual script of your source .abc is executed:
AvmShell.cpp
void Shell::initShellPool(Thrower& p_thrower)
{
avmplus::ScriptBuffer code = newReadOnlyScriptBuffer(shell_abc_data, sizeof(shell_abc_data));
shellPool = parseActionBlock(code, NULL, shell_natives, shell_offset, p_thrower);
}
AvmCore.cpp
PoolObject* AvmCore::parseActionBlock(const ScriptBuffer& code,
Toplevel* toplevel,
NativeMethodInfop nativeMap,
int nativeOffset,
Thrower& p_thrower) {

// parse the actual binary .abc
PoolObject* pool = AbcParser::decodeAbc(this,
code,
toplevel,
nativeMap,
nativeOffset,
p_thrower);

return pool;
}

In the next Post, I'll explain a little more how the shell works. It's kind of twisted and convoluted, just like everything in Tamarin.