NewtVM.c

VM [詳細]

#include <stdlib.h>
#include "NewtErrs.h"
#include "NewtVM.h"
#include "NewtBC.h"
#include "NewtGC.h"
#include "NewtMem.h"
#include "NewtEnv.h"
#include "NewtObj.h"
#include "NewtFns.h"
#include "NewtStr.h"
#include "NewtFile.h"
#include "NewtIO.h"
#include "NewtPrint.h"
#include "NewtNSOF.h"

ソースコードを見る。

マクロ定義

#define START_LOCALARGS   3
 ローカル引数の開始位置
#define BC   (vm_env.bc)
 バイトコード
#define BCLEN   (vm_env.bclen)
  バイトコード長
#define CALLSTACK   ((vm_reg_t *)vm_env.callstack.stackp)
 呼出しスタック
#define CALLSP   (vm_env.callstack.sp)
 呼出しスタックのスタックポインタ
#define EXCPSTACK   ((vm_excp_t *)vm_env.excpstack.stackp)
 例外スタック
#define EXCPSP   (vm_env.excpstack.sp)
 例外スタックのスタックポインタ
#define CURREXCP   (vm_env.currexcp)
 現在の例外
#define REG   (vm_env.reg)
 レジスタ
#define STACK   ((newtRef *)vm_env.stack.stackp)
 スタック
#define FUNC   ((REG).func)
 実行中の関数
#define PC   ((REG).pc)
 プログラムカウンタ
#define SP   ((REG).sp)
 スタックポインタ
#define LOCALS   ((REG).locals)
 ローカルフレーム
#define RCVR   ((REG).rcvr)
 レシーバ
#define IMPL   ((REG).impl)
 インプリメンタ

型定義

typedef void(*) instruction_t (int16_t b)
 命令セット
typedef void(*) simple_instruction_t (void)
 シンプル命令
typedef newtRef(*) nvm_func_t ()
 ネイティブ関数

関数

static newtErr NVMGetExceptionErrCode (newtRefArg r, bool dump)
static newtRef NVMMakeExceptionFrame (newtRefArg name, newtRefArg data)
static void NVMClearCurrException (void)
static void NVMSetFn (newtRefArg fn)
static void NVMNoStackFrameForReturn (void)
static void reg_rewind (int32_t sp)
static void reg_pop (void)
static void reg_push (int32_t sp)
static void reg_save (int32_t sp)
static newtRef stk_pop0 (void)
static newtRef stk_pop (void)
static void stk_pop_n (int32_t n, newtRef a[])
static void stk_remove (uint16_t n)
static newtRef stk_top (void)
static void stk_push (newtRefArg value)
static bool excp_push (newtRefArg sym, newtRefArg pc)
static void excp_pop (void)
static vm_excp_texcp_top (void)
static void excp_pop_handlers (void)
static newtRef liter_get (int16_t n)
static newtRef iter_new (newtRefArg r, newtRefArg deeply)
static void iter_next (newtRefArg iter)
static bool iter_done (newtRefArg iter)
static newtRef NVMMakeArgsArray (uint16_t numArgs)
static void NVMBindArgs (uint16_t numArgs)
static void NVMThrowBC (newtErr err, newtRefArg value, int16_t pop, bool push)
static newtErr NVMFuncCheck (newtRefArg fn, int16_t numArgs)
static void NVMCallNativeFn (newtRefArg fn, int16_t numArgs)
static void NVMCallNativeFunc (newtRefArg fn, newtRefArg rcvr, int16_t numArgs)
static void NVMFuncCall (newtRefArg fn, int16_t numArgs)
static void NVMMessageSend (newtRefArg impl, newtRefArg receiver, newtRefArg fn, int16_t numArgs)
static newtRef vm_send (int16_t b, newtErr *errP)
static newtRef vm_resend (int16_t b, newtErr *errP)
static void si_pop (void)
static void si_dup (void)
static void si_return (void)
static void si_pushself (void)
static void si_set_lex_scope (void)
static void si_iternext (void)
static void si_iterdone (void)
static void si_pop_handlers (void)
static void fn_add (void)
static void fn_subtract (void)
static void fn_aref (void)
static void fn_set_aref (void)
static void fn_equals (void)
static void fn_not (void)
static void fn_not_equals (void)
static void fn_multiply (void)
static void fn_divide (void)
static void fn_div (void)
static void fn_less_than (void)
static void fn_greater_than (void)
static void fn_greater_or_equal (void)
static void fn_less_or_equal (void)
static void fn_bit_and (void)
static void fn_bit_or (void)
static void fn_bit_not (void)
static void fn_new_iterator (void)
static void fn_length (void)
static void fn_clone (void)
static void fn_set_class (void)
static void fn_add_array_slot (void)
static void fn_stringer (void)
static void fn_has_path (void)
static void fn_classof (void)
static void is_dummy (int16_t b)
static void is_simple_instructions (int16_t b)
static void is_push (int16_t b)
static void is_push_constant (int16_t b)
static void is_call (int16_t b)
static void is_invoke (int16_t b)
static void is_send (int16_t b)
static void is_send_if_defined (int16_t b)
static void is_resend (int16_t b)
static void is_resend_if_defined (int16_t b)
static void is_branch (int16_t b)
static void is_branch_if_true (int16_t b)
static void is_branch_if_false (int16_t b)
static void is_find_var (int16_t b)
static void is_get_var (int16_t b)
static void is_make_frame (int16_t b)
static void is_make_array (int16_t b)
static void is_get_path (int16_t b)
static void is_set_path (int16_t b)
static void is_set_var (int16_t b)
static void is_find_and_set_var (int16_t b)
static void is_incr_var (int16_t b)
static void is_branch_if_loop_not_done (int16_t b)
static void is_freq_func (int16_t b)
static void is_new_handlers (int16_t b)
static void NVMDumpInstResult (FILE *f)
static void NVMDumpInstCode (FILE *f, uint8_t *bc, uint32_t pc, uint16_t len)
static void NVMInitREG (void)
static void NVMInitSTACK (void)
static void NVMCleanSTACK (void)
static void NVMInitGlobalFns0 (void)
static void NVMInitGlobalFns1 (void)
static void NVMInitExGlobalFns (void)
static void NVMInitDebugGlobalFns (void)
static void NVMInitGlobalFns (void)
static void NVMInitGlobalVars (void)
static void NVMInit (void)
static void NVMClean (void)
static void NVMLoop (uint32_t callsp)
static newtRef NVMInterpret2 (nps_syntax_node_t *stree, uint32_t numStree, newtErr *errP)
newtRef NVMSelf (void)
newtRef NVMCurrentFunction (void)
newtRef NVMCurrentImplementor (void)
bool NVMHasVar (newtRefArg name)
void NVMThrowData (newtRefArg name, newtRefArg data)
void NVMThrow (newtRefArg name, newtRefArg data)
void NVMRethrow (void)
newtRef NVMCurrentException (void)
void NVMClearException (void)
bool NVMFuncCheckNumArgs (newtRefArg fn, int16_t numArgs)
void NVMDumpInstName (FILE *f, uint8_t a, int16_t b)
void NVMDumpStackTop (FILE *f, char *s)
void NVMDumpCode (FILE *f, uint8_t *bc, uint32_t len)
void NVMDumpBC (FILE *f, newtRefArg instructions)
void NVMDumpFn (FILE *f, newtRefArg func)
void NVMDumpStacks (FILE *f)
void NVMFnCall (newtRefArg fn, int16_t numArgs)
newtRef NVMCall (newtRefArg fn, int16_t numArgs, newtErr *errP)
newtRef NVMInterpret (newtRefArg fn, newtErr *errP)
newtErr NVMInfo (const char *name)
newtRef NVMInterpretFile (const char *path, newtErr *errP)
newtRef NVMInterpretStr (const char *s, newtErr *errP)
newtRef NVMMessageSendWithArgArray (newtRefArg inImpl, newtRefArg inRcvr, newtRefArg inFunction, newtRefArg inArgs)

変数

vm_env_t vm_env
 VM 実行環境
static simple_instruction_t simple_instructions []
 シンプル命令テーブル
static simple_instruction_t fn_instructions []
 関数命令テーブル
static instruction_t is_instructions []
 命令セットテーブル
static char * simple_instruction_names []
 シンプル命令名テーブル
static char * fn_instruction_names []
 関数命令名テーブル
static char * vm_instruction_names []
 命令セット名テーブル


説明

VM

作者:
M.Nukui
日付:
2003-11-07
Copyright (C) 2003-2004 M.Nukui All rights reserved.

NewtVM.c で定義されています。


関数

void excp_pop ( void   )  [static]

例外スタックをポップ

戻り値:
なし

NewtVM.c835 行で定義されています。

参照先 EXCPSP.

参照元 excp_pop_handlers().

void excp_pop_handlers ( void   )  [static]

例外ハンドラをポップする

戻り値:
なし

NewtVM.c862 行で定義されています。

参照先 excp_pop()excp_top()vm_excp_t::excppc.

参照元 is_new_handlers()NVMClearCurrException()si_pop_handlers().

関数の呼び出しグラフ:

bool excp_push ( newtRefArg  sym,
newtRefArg  pc 
) [static]

例外スタックにプッシュ

引数:
sym [in] 例外シンボル
pc [in] プログラムカウンタ
戻り値:
true スタックされた
false スタックされなかった

NewtVM.c804 行で定義されています。

参照先 CALLSPvm_excp_t::callspvm_excp_t::excppcEXCPSPEXCPSTACKvm_env_t::excpstackNewtRefIsInteger()NewtRefIsSymbol()NewtRefToInteger()NewtStackExpand()vm_excp_t::pcPCvm_excp_t::symvm_env.

参照元 is_new_handlers().

関数の呼び出しグラフ:

vm_excp_t * excp_top ( void   )  [static]

例外スタックの先頭を取得

戻り値:
例外構造体へのポインタ

NewtVM.c847 行で定義されています。

参照先 EXCPSPEXCPSTACK.

参照元 excp_pop_handlers().

void fn_add ( void   )  [static]

加算

戻り値:
なし

NewtVM.c2026 行で定義されています。

参照先 NcAdd()stk_pop()stk_push().

関数の呼び出しグラフ:

void fn_add_array_slot ( void   )  [static]

配列オブジェクトにオブジェクトを追加する

戻り値:
なし

NewtVM.c2406 行で定義されています。

参照先 NcAddArraySlot()stk_pop()stk_pop0()stk_push().

関数の呼び出しグラフ:

void fn_aref ( void   )  [static]

オブジェクトの指定された位置から値を取得

戻り値:
なし

NewtVM.c2062 行で定義されています。

参照先 NcARef()stk_pop()stk_push().

関数の呼び出しグラフ:

void fn_bit_and ( void   )  [static]

ビット演算 AND

戻り値:
なし

NewtVM.c2283 行で定義されています。

参照先 NcBAnd()stk_pop()stk_push().

関数の呼び出しグラフ:

void fn_bit_not ( void   )  [static]

ビット演算 NOT

戻り値:
なし

NewtVM.c2319 行で定義されています。

参照先 NcBNot()stk_pop()stk_push().

関数の呼び出しグラフ:

void fn_bit_or ( void   )  [static]

ビット演算 OR

戻り値:
なし

NewtVM.c2301 行で定義されています。

参照先 NcBOr()stk_pop()stk_push().

関数の呼び出しグラフ:

void fn_classof ( void   )  [static]

オブジェクトのクラスシンボルを取得

戻り値:
なし

NewtVM.c2457 行で定義されています。

参照先 NcClassOf()stk_pop()stk_push().

関数の呼び出しグラフ:

void fn_clone ( void   )  [static]

オブジェクトをクローン複製する

戻り値:
なし

NewtVM.c2373 行で定義されています。

参照先 NcClone()stk_pop()stk_push().

関数の呼び出しグラフ:

void fn_div ( void   )  [static]

整数の割算

戻り値:
なし

NewtVM.c2193 行で定義されています。

参照先 NcDiv()stk_pop()stk_push().

関数の呼び出しグラフ:

void fn_divide ( void   )  [static]

割算

戻り値:
なし

NewtVM.c2175 行で定義されています。

参照先 NcDivide()stk_pop()stk_push().

関数の呼び出しグラフ:

void fn_equals ( void   )  [static]

オブジェクトの同値をチェック

戻り値:
なし

NewtVM.c2100 行で定義されています。

参照先 NcRefEqual()stk_pop()stk_push().

関数の呼び出しグラフ:

void fn_greater_or_equal ( void   )  [static]

オブジェクトの比較(>=)

戻り値:
なし

NewtVM.c2247 行で定義されています。

参照先 NcGreaterOrEqual()stk_pop()stk_push().

関数の呼び出しグラフ:

void fn_greater_than ( void   )  [static]

オブジェクトの比較(>)

戻り値:
なし

NewtVM.c2229 行で定義されています。

参照先 NcGreaterThan()stk_pop()stk_push().

関数の呼び出しグラフ:

void fn_has_path ( void   )  [static]

オブジェクト内のアクセスパスの有無を調べる

戻り値:
なし

NewtVM.c2439 行で定義されています。

参照先 NcHasPath()stk_pop()stk_push().

関数の呼び出しグラフ:

void fn_length ( void   )  [static]

オブジェクトの長さを取得

戻り値:
なし

NewtVM.c2358 行で定義されています。

参照先 NcLength()stk_pop()stk_push().

関数の呼び出しグラフ:

void fn_less_or_equal ( void   )  [static]

オブジェクトの比較(<=)

戻り値:
なし

NewtVM.c2265 行で定義されています。

参照先 NcLessOrEqual()stk_pop()stk_push().

関数の呼び出しグラフ:

void fn_less_than ( void   )  [static]

オブジェクトの比較(<)

戻り値:
なし

NewtVM.c2211 行で定義されています。

参照先 NcLessThan()stk_pop()stk_push().

関数の呼び出しグラフ:

void fn_multiply ( void   )  [static]

乗算

戻り値:
なし

NewtVM.c2157 行で定義されています。

参照先 NcMultiply()stk_pop()stk_push().

関数の呼び出しグラフ:

void fn_new_iterator ( void   )  [static]

イテレータの作成

戻り値:
なし

NewtVM.c2334 行で定義されています。

参照先 iter_new()kNErrNotAFrameOrArrayNewtRefIsBinary()NewtRefIsFrameOrArray()NewtThrow()stk_pop()stk_push().

関数の呼び出しグラフ:

void fn_not ( void   )  [static]

ブール値の否定

戻り値:
なし

NewtVM.c2118 行で定義されています。

参照先 NewtMakeBooleanNewtRefIsNIL()stk_pop()stk_push().

関数の呼び出しグラフ:

void fn_not_equals ( void   )  [static]

オブジェクトの違いをチェック

戻り値:
なし

NewtVM.c2136 行で定義されています。

参照先 NewtMakeBooleanNewtRefEqual()stk_pop()stk_push().

関数の呼び出しグラフ:

void fn_set_aref ( void   )  [static]

オブジェクトの指定された位置に値をセットする

戻り値:
なし

NewtVM.c2080 行で定義されています。

参照先 NcSetARef()stk_pop()stk_pop0()stk_push().

関数の呼び出しグラフ:

void fn_set_class ( void   )  [static]

オブジェクトにクラスをセットする

戻り値:
なし

NewtVM.c2388 行で定義されています。

参照先 NcSetClass()stk_pop()stk_push().

関数の呼び出しグラフ:

void fn_stringer ( void   )  [static]

配列オブジェクトの要素を文字列に合成する

戻り値:
なし

NewtVM.c2424 行で定義されています。

参照先 NcStringer()stk_pop()stk_push().

関数の呼び出しグラフ:

void fn_subtract ( void   )  [static]

減算

戻り値:
なし

NewtVM.c2044 行で定義されています。

参照先 NcSubtract()stk_pop()stk