#include <stdio.h>
#include <stdlib.h>
#include "NewtCore.h"
#include "NewtBC.h"
#include "NewtVM.h"
#include "NewtIO.h"
#include "NewtMem.h"
データ構造 | |
| struct | nbc_env_t |
| バイトコード環境(構造体定義) [詳細] | |
| struct | freq_func_t |
| 関数命令テーブル構造体 [詳細] | |
マクロ定義 | |
| #define | ENV_BC(env) ((uint8_t*)env->bytecode.stackp) |
| バイトコード | |
| #define | ENV_CX(env) (env->bytecode.sp) |
| コードインデックス(プログラムカウンタ) | |
| #define | BC ENV_BC(newt_bc_env) |
| 作成中のバイトコード | |
| #define | CX ENV_CX(newt_bc_env) |
| 作成中のコードインデックス(プログラムカウンタ) | |
| #define | BREAKSTACK ((uint32_t*)newt_bc_env->breakstack.stackp) |
| ブレークスタック | |
| #define | BREAKSP (newt_bc_env->breakstack.sp) |
| ブレークスタックのスタックポインタ | |
| #define | ONEXCPSTACK ((uint32_t*)newt_bc_env->onexcpstack.stackp) |
| 例外スタック | |
| #define | ONEXCPSP (newt_bc_env->onexcpstack.sp) |
| 例外スタックのスタックポインタ | |
| #define | LITERALS (newt_bc_env->literals) |
| 作成中関数オブジェクトのリテラル | |
| #define | ARGFRAME (newt_bc_env->argFrame) |
| 作成中関数オブジェクトの引数フレーム | |
| #define | CONSTANT (newt_bc_env->constant) |
| 定数フレーム | |
| #define | NBCAddLiteral(r) NBCAddLiteralEnv(newt_bc_env, r) |
| リテラルリストにオブジェクトを追加 | |
| #define | NBCGenCode(a, b) NBCGenCodeEnv(newt_bc_env, a, b) |
| バイトコードを生成 | |
| #define | NBCGenCodeL(a, r) NBCGenCodeEnvL(newt_bc_env, a, r) |
| リテラルなオペデータのバイトコードを生成 | |
| #define | NBCGenPushLiteral(r) NBCGenPushLiteralEnv(newt_bc_env, r) |
| リテラルをプッシュするバイトコードを生成 | |
| #define | NBCGenBC_op(stree, r) NBCGenBC_stmt(stree, r, true) |
| 引数のバイトコードを生成する | |
| #define | NBCGenFreq(b) NBCGenCode(kNBCFreqFunc, b) |
| 関数命令のバイトコードを生成する | |
型定義 | |
| typedef nbc_env_t | nbc_env_t |
| バイトコード環境 | |
関数 | |
| static int16_t | NBCAddLiteralEnv (nbc_env_t *env, newtRefArg r) |
| static void | NBCGenCodeEnv (nbc_env_t *env, uint8_t a, int16_t b) |
| static void | NBCGenCodeEnvL (nbc_env_t *env, uint8_t a, newtRefArg r) |
| static int16_t | NBCGenPushLiteralEnv (nbc_env_t *env, newtRefArg r) |
| static void | NBCGenPUSH (newtRefArg r) |
| static void | NBCGenGetVar (nps_syntax_node_t *stree, newtRefArg r) |
| static void | NBCGenCallFn (newtRefArg fn, int16_t numArgs) |
| static int16_t | NBCMakeFnArgFrame (newtRefArg argFrame, nps_syntax_node_t *stree, nps_node_t r, bool *indefiniteP) |
| static int16_t | NBCMakeFnArgs (newtRefArg fn, nps_syntax_node_t *stree, nps_node_t r) |
| static nbc_env_t * | NBCMakeFnEnv (nps_syntax_node_t *stree, nps_node_t args) |
| static uint32_t | NBCGenBranch (uint8_t a) |
| static void | NBCDefLocal (newtRefArg type, newtRefArg r, bool init) |
| static void | NBCBackPatch (uint32_t cx, int16_t b) |
| static void | NBCPushBreakStack (uint32_t cx) |
| static void | NBCBreakBackPatchs (uint32_t loop_head, uint32_t cx) |
| static void | NBCPushOnexcpStack (uint32_t cx) |
| static void | NBCOnexcpBackPatchs (uint32_t try_head, uint32_t cx) |
| static void | NBCGenOnexcpPC (int32_t pc) |
| static void | NBCGenOnexcpBranch (void) |
| static void | NBCOnexcpBackPatchL (uint32_t sp, int32_t pc) |
| static newtRef | NBCMakeFn (nbc_env_t *env) |
| static void | NBCInitFreqFuncTable (void) |
| static nbc_env_t * | NBCEnvNew (nbc_env_t *parent) |
| static void | NBCEnvFree (nbc_env_t *env) |
| static newtRef | NBCFnDone (nbc_env_t **envP) |
| static void | NBCInit (void) |
| static void | NBCCleanup (void) |
| static void | NBCGenBC_stmt (nps_syntax_node_t *stree, nps_node_t r, bool ret) |
| static void | NBCGenConstant (nps_syntax_node_t *stree, nps_node_t r) |
| static void | NBCGenGlobalVar (nps_syntax_node_t *stree, nps_node_t r) |
| static void | NBCGenLocalVar (nps_syntax_node_t *stree, nps_node_t type, nps_node_t r) |
| static bool | NBCTypeValid (nps_node_t type) |
| static int16_t | NBCGenTryPre (nps_syntax_node_t *stree, nps_node_t r) |
| static int16_t | NBCGenTryPost (nps_syntax_node_t *stree, nps_node_t r, uint32_t *onexcpspP) |
| static void | NBCGenTry (nps_syntax_node_t *stree, nps_node_t expr, nps_node_t onexception_list) |
| static void | NBCGenIfThenElse (nps_syntax_node_t *stree, nps_node_t cond, nps_node_t thenelse, bool ret) |
| static void | NBCGenAnd (nps_syntax_node_t *stree, nps_node_t op1, nps_node_t op2) |
| static void | NBCGenOr (nps_syntax_node_t *stree, nps_node_t op1, nps_node_t op2) |
| static void | NBCGenLoop (nps_syntax_node_t *stree, nps_node_t expr) |
| static newtRef | NBCMakeTempSymbol (newtRefArg index, newtRefArg val, char *s) |
| static void | NBCGenFor (nps_syntax_node_t *stree, nps_node_t r, nps_node_t expr) |
| static void | NBCGenForeach (nps_syntax_node_t *stree, nps_node_t r, nps_node_t expr) |
| static void | NBCGenWhile (nps_syntax_node_t *stree, nps_node_t cond, nps_node_t expr) |
| static void | NBCGenRepeat (nps_syntax_node_t *stree, nps_node_t expr, nps_node_t cond) |
| static void | NBCGenBreak (nps_syntax_node_t *stree, nps_node_t expr) |
| static void | NBCGenStringer (nps_syntax_node_t *stree, nps_node_t op1, nps_node_t op2, char *dlmt) |
| static void | NBCGenAsign (nps_syntax_node_t *stree, nps_node_t lvalue, nps_node_t expr, bool ret) |
| static void | NBCGenExists (nps_syntax_node_t *stree, nps_node_t r) |
| static void | NBCGenReceiver (nps_syntax_node_t *stree, nps_node_t r) |
| static void | NBCGenMethodExists (nps_syntax_node_t *stree, nps_node_t receiver, nps_node_t name) |
| static void | NBCGenFn (nps_syntax_node_t *stree, nps_node_t args, nps_node_t expr) |
| static void | NBCGenGlobalFn (nps_syntax_node_t *stree, nps_node_t name, nps_node_t fn) |
| static void | NBCGenCall (nps_syntax_node_t *stree, nps_node_t name, nps_node_t args) |
| static void | NBCGenInvoke (nps_syntax_node_t *stree, nps_node_t fn, nps_node_t args) |
| static void | NBCGenFunc2 (nps_syntax_node_t *stree, newtRefArg name, nps_node_t op1, nps_node_t op2) |
| static void | NBCGenSend (nps_syntax_node_t *stree, uint32_t code, nps_node_t receiver, nps_node_t r) |
| static void | NBCGenResend (nps_syntax_node_t *stree, uint32_t code, nps_node_t name, nps_node_t args) |
| static void | NBCGenMakeArray (nps_syntax_node_t *stree, nps_node_t klass, nps_node_t r) |
| static void | NBCGenMakeFrame (nps_syntax_node_t *stree, nps_node_t r) |
| static void | NVCGenNoResult (bool ret) |
| static void | NBCGenSyntaxCode (nps_syntax_node_t *stree, nps_syntax_node_t *node, bool ret) |
| static int16_t | NBCCountNumArgs (nps_syntax_node_t *stree, nps_node_t r) |
| static newtRef | NBCGenMakeFrameSlots_sub (nps_syntax_node_t *stree, nps_node_t r) |
| static newtRef | NBCGenMakeFrameSlots (nps_syntax_node_t *stree, nps_node_t r) |
| static void | NBCGenBC_sub (nps_syntax_node_t *stree, uint32_t n, bool ret) |
| newtRef | NBCGenBC (nps_syntax_node_t *stree, uint32_t size, bool ret) |
| newtRef | NBCCompileFile (char *s, bool ret) |
| newtRef | NBCCompileStr (char *s, bool ret) |
| void | NBError (int32_t err) |
変数 | |
| static nbc_env_t * | newt_bc_env |
| バイドコード環境 | |
| static freq_func_t | freq_func_tb [] |
| 関数命令テーブル | |
NewtBC.c で定義されています。
| int16_t NBCAddLiteralEnv | ( | nbc_env_t * | env, | |
| newtRefArg | r | |||
| ) | [static] |
リテラルリストにオブジェクトを追加する
| env | [in] バイトコード環境 | |
| r | [in] オブジェクト |
参照先 nbc_env_t::literals・NcAddArraySlot()・NewtArrayLength.
参照元 NBCGenCodeEnvL()・NBCGenPushLiteralEnv().
関数の呼び出しグラフ:

| void NBCBackPatch | ( | uint32_t | cx, | |
| int16_t | b | |||
| ) | [static] |
バイトコードをバックパッチする
| cx | [in] バックパッチする位置 | |
| b | [in] バックパッチするオペデータ |
参照先 BC.
参照元 NBCBreakBackPatchs()・NBCGenAnd()・NBCGenFor()・NBCGenForeach()・NBCGenIfThenElse()・NBCGenOr()・NBCGenTry()・NBCGenWhile()・NBCOnexcpBackPatchs().
| void NBCBreakBackPatchs | ( | uint32_t | loop_head, | |
| uint32_t | cx | |||
| ) | [static] |
ループ内のブレーク命令をバックパッチする
| loop_head | [in] ループの開始位置 | |
| cx | [in] ループの終わり位置 |
参照先 BREAKSP・BREAKSTACK・NBCBackPatch().
参照元 NBCGenFor()・NBCGenForeach()・NBCGenLoop()・NBCGenRepeat()・NBCGenWhile().
関数の呼び出しグラフ:

| void NBCCleanup | ( | void | ) | [static] |
| newtRef NBCCompileFile | ( | char * | s, | |
| bool | ret | |||
| ) |
ソースファイルをコンパイル
| s | [in] ソースファイルのパス | |
| ret | [in] 戻り値の有無 |
参照先 kNewtRefUnbind・NBCGenBC()・NPSCleanup()・NPSParseFile().
参照元 NsCompileFile().
関数の呼び出しグラフ:

| newtRef NBCCompileStr | ( | char * | s, | |
| bool | ret | |||
| ) |
文字列をコンパイル
| s | [in] スクリプト文字列 | |
| ret | [in] 戻り値の有無 |
参照先 kNewtRefNIL・kNewtRefUnbind・NBCGenBC()・NewtThrow()・NPSCleanup()・NPSParseStr().
参照元 NsCompile().
関数の呼び出しグラフ:

| int16_t NBCCountNumArgs | ( | nps_syntax_node_t * | stree, | |
| nps_node_t | r | |||
| ) | [static] |
引数の数をカウントする
| stree | [in] 構文木 | |
| r | [in] 構文木ノード |
参照先 nps_syntax_node_t::code・kNewtRefUnbind・NPSRefIsSyntaxNode・NPSRefToSyntaxNode・nps_syntax_node_t::op1・nps_syntax_node_t::op2.
参照元 NBCGenCall()・NBCGenInvoke()・NBCGenMakeArray()・NBCGenResend()・NBCGenSend().
| void NBCDefLocal | ( | newtRefArg | type, | |
| newtRefArg | r, | |||
| bool | init | |||
| ) | [static] |
ローカル変数を定義するバイトコードを生成
| type | [in] 変数の型 | |
| r | [in] 変数名シンボル | |
| init | [in] 初期化 |
参照先 ARGFRAME・kNewtRefUnbind・NBCGenCode・NcSetSlot・NewtFindSlotIndex()・NewtFprintf().
参照元 NBCGenFor()・NBCGenForeach()・NBCGenLocalVar().
関数の呼び出しグラフ:

| void NBCEnvFree | ( | nbc_env_t * | env | ) | [static] |
バイトコード環境を解放する
| env | [in] バイトコード環境 |
参照先 nbc_env_t::breakstack・nbc_env_t::bytecode・NewtMemFree()・NewtStackFree()・nbc_env_t::onexcpstack.
参照元 NBCCleanup()・NBCFnDone().
関数の呼び出しグラフ:

バイトコード環境を作成する
| parent | [in] 呼出し元のバイトコード環境 |
参照先 nbc_env_t::bytecode・NBCMakeFn()・NEWT_NUM_BYTECODE・NEWT_POOL・NewtMemCalloc()・NewtStackSetup()・nbc_env_t::parent.
参照元 NBCGenBC()・NBCMakeFnEnv().
関数の呼び出しグラフ:

関数オブジェクトの生成を終了する
| envP | [in] バイトコード環境へのポインタ |
参照先 ENV_BC・ENV_CX・nbc_env_t::func・kNewtRefNIL・NBCEnvFree()・NBCGenCodeEnv()・NcGetSlot・NcLength()・NcSetSlot・NewtMakeBinary()・NewtRefIsNotNIL・NSSYM0・nbc_env_t::parent.
参照元 NBCGenBC()・NBCGenFn().
関数の呼び出しグラフ:

| void NBCGenAnd | ( | nps_syntax_node_t * | stree, | |
| nps_node_t | op1, | |||
| nps_node_t | op2 | |||
| ) | [static] |
論理AND のバイトコードを生成する
| stree | [in] 構文木 | |
| op1 | [in] オペランド1の構文木ノード | |
| op2 | [in] オペランド2の構文木ノード |
参照先 CX・kNewtRefNIL・NBCBackPatch()・NBCGenBC_op・NBCGenBranch()・NBCGenPUSH().
参照元 NBCGenSyntaxCode().
関数の呼び出しグラフ:

| void NBCGenAsign | ( | nps_syntax_node_t * | stree, | |
| nps_node_t | lvalue, | |||
| nps_node_t | expr, | |||
| bool | ret | |||
| ) | [static] |
代入式のバイトコードを生成する
| stree | [in] 構文木 | |
| lvalue | [in] 左辺 | |
| expr | [in] 式 | |
| ret | [in] 戻り値の有無 |
参照先 nps_syntax_node_t::code・CONSTANT・kNErrAssignToConstant・kNErrSyntaxError・kNPSAref・kNPSGetPath・NBCGenBC_op・NBCGenCode・NBCGenCodeL・NBCGenFreq・NBCGenFunc2()・NBError()・NewtHasSlot()・NewtMakeInteger()・NewtMPToSymbol・NewtRefIsMagicPointer・NewtRefIsSymbol()・NPSRefIsSyntaxNode・NPSRefToSyntaxNode・NSSYM0・NVCGenNoResult()・nps_syntax_node_t::op1・nps_syntax_node_t::op2.
参照元 NBCGenSyntaxCode().
関数の呼び出しグラフ:

| newtRef NBCGenBC | ( | nps_syntax_node_t * | stree, | |
| uint32_t | size, | |||
| bool | ret | |||
| ) |
バイトコードの生成
| stree | [in] 構文木 | |
| size | [in] 構文木の長さ | |
| ret | [in] 戻り値の有無 |
参照先 NBCCleanup()・NBCEnvNew()・NBCFnDone()・NBCGenBC_sub()・NBCInit()・newt_bc_env・NEWT_DUMPBC・NewtFprintf()・NewtPackLiteral()・NewtRefIsNotNIL・NVMDumpFn().
参照元 NBCCompileFile()・NBCCompileStr()・NVMInterpret2().
関数の呼び出しグラフ:

| void NBCGenBC_stmt | ( | nps_syntax_node_t * | stree, | |
| nps_node_t | r, | |||
| bool | ret | |||
| ) | [static] |
文のバイトコードを生成する
| stree | [in] 構文木 | |
| r | [in] 構文木ノード | |
| ret | [in] 戻り値の有無 |
参照先 kNewtRefUnbind・NBCGenBC_sub()・NBCGenPUSH()・NPSRefIsSyntaxNode・NPSRefToSyntaxNode.
参照元 NBCGenFor()・NBCGenForeach()・NBCGenIfThenElse()・NBCGenLoop()・NBCGenRepeat()・NBCGenSyntaxCode()・NBCGenTryPost()・NBCGenWhile().
関数の呼び出しグラフ:

| void NBCGenBC_sub | ( | nps_syntax_node_t * | stree, | |
| uint32_t | n, | |||
| bool | ret | |||
| ) | [static] |
バイトコードの生成(再帰呼出し用)
| stree | [in] 構文木 | |
| n | [in] 構文木の長さ | |
| ret | [in] 戻り値の有無 |
参照先 nps_syntax_node_t::code・kNPSAdd・kNPSCall・kNPSGetPath・kNPSInvoke・kNPSMakeArray・kNPSMakeFrame・kNPSPopHandlers・kNPSResend・kNPSResendIfDefined・kNPSSend・kNPSSendIfDefined・NBCGenBC_op・NBCGenCall()・NBCGenCode・NBCGenFreq・NBCGenInvoke()・NBCGenMakeArray()・NBCGenMakeFrame()・NBCGenResend()・NBCGenSend()・NBCGenSyntaxCode()・NVCGenNoResult()・nps_syntax_node_t::op1・nps_syntax_node_t::op2.
参照元 NBCGenBC()・NBCGenBC_stmt().
関数の呼び出しグラフ:

| uint32_t NBCGenBranch | ( | uint8_t | a | ) | [static] |
分岐命令のバイトコードを生成
| a | [in] 命令 |
参照先 CX・NBCGenCode.
参照元 NBCGenAnd()・NBCGenBreak()・NBCGenFor()・NBCGenForeach()・NBCGenIfThenElse()・NBCGenOnexcpBranch()・NBCGenOr()・NBCGenTry()・NBCGenWhile().
| void NBCGenBreak | ( | nps_syntax_node_t * | stree, | |
| nps_node_t | expr | |||
| ) | [static] |
BREAK文のバイトコードを生成する
| stree | [in] 構文木 | |
| expr | [in] 実行文の構文木ノード |
参照先 kNewtRefNIL・kNewtRefUnbind・NBCGenBC_op・NBCGenBranch()・NBCGenPUSH()・NBCPushBreakStack().
参照元 NBCGenSyntaxCode().
関数の呼び出しグラフ:

| void NBCGenCall | ( | nps_syntax_node_t * | stree, | |
| nps_node_t | name, | |||
| nps_node_t | args | |||
| ) | [static] |
関数呼出しのバイトコードを生成する
| stree | [in] 構文木 | |
| name | [in] グローバル関数名 | |
| args | [in] 引数 |
参照先 NBCCountNumArgs()・NBCGenBC_op・NBCGenCallFn().
参照元 NBCGenBC_sub().
関数の呼び出しグラフ:

| void NBCGenCallFn | ( | newtRefArg | fn, | |
| int16_t | numArgs | |||
| ) | [static] |
関数呼出しのバイトコードを生成
| fn | [in] 関数オブジェクト | |
| numArgs | [in] 引数の数 |
参照先 freq_func_tb・kNErrWrongNumberOfArgs・freq_func_t::name・NBCGenCode・NBCGenFreq・NBCGenPUSH()・NBError()・NewtRefEqual().
参照元 NBCGenCall()・NBCGenExists()・NBCGenGlobalVar()・NBCGenMethodExists().
関数の呼び出しグラフ:

| void NBCGenCodeEnv | ( | nbc_env_t * | env, | |
| uint8_t | a, | |||
| int16_t | b | |||
| ) | [static] |
バイトコードを生成
| env | [in] バイトコード環境 | |
| a | [in] 命令 | |
| b | [in] オペデータ |
参照先 nbc_env_t::bytecode・ENV_BC・ENV_CX・kNBCFieldMask・NewtStackExpand().
参照元 NBCFnDone()・NBCGenCodeEnvL()・NBCGenPushLiteralEnv().
関数の呼び出しグラフ:

| void NBCGenCodeEnvL | ( | nbc_env_t * | env, | |
| uint8_t | a, | |||
| newtRefArg | r | |||
| ) | [static] |
リテラルなオペデータのバイトコードを生成
| env | [in] バイトコード環境 | |
| a | [in] 命令 | |
| r | [in] オブジェクト |
参照先 nbc_env_t::literals・NBCAddLiteralEnv()・NBCGenCodeEnv()・NewtFindArrayIndex()・NewtPackLiteral().
関数の呼び出しグラフ:

| void NBCGenConstant | ( | nps_syntax_node_t * | stree, | |
| nps_node_t | r | |||
| ) | [static] |
定数のバイトコードを生成する
| stree | [in] 構文木 | |
| r | [in] 構文木ノード |
参照先 nps_syntax_node_t::code・CONSTANT・kNErrSyntaxError・NBError()・NcSetSlot・NPSRefIsSyntaxNode・NPSRefToSyntaxNode・nps_syntax_node_t::op1・nps_syntax_node_t::op2.
参照元 NBCGenSyntaxCode().
関数の呼び出しグラフ:

| void NBCGenExists | ( | nps_syntax_node_t * | stree, | |
| nps_node_t | r | |||
| ) | [static] |
EXISTS式のバイトコードを生成する
| stree | [in] 構文木 | |
| r | [in] 構文木ノード |
参照先 nps_syntax_node_t::code・kNErrSyntaxError・kNewtRefTRUE・kNPSGetPath・LITERALS・NBCGenBC_op・NBCGenCallFn()・NBCGenFreq・NBCGenPUSH()・NBError()・NewtFindArrayIndex()・NewtRefIsSymbol()・NPSRefIsSyntaxNode・NPSRefToSyntaxNode・NSSYM0・nps_syntax_node_t::op1・nps_syntax_node_t::op2.
参照元 NBCGenSyntaxCode().
関数の呼び出しグラフ:

| void NBCGenFn | ( | nps_syntax_node_t * | stree, | |
| nps_node_t | args, | |||
| nps_node_t | expr | |||
| ) | [static] |
関数定義のバイトコードを生成する
| stree | [in] 構文木 | |
| args | [in] 引数 | |
| expr | [in] 式 |
参照先 NBCFnDone()・NBCGenBC_op・NBCGenCode・NBCGenPUSH()・NBCMakeFnEnv()・newt_bc_env.
参照元 NBCGenSyntaxCode().
関数の呼び出しグラフ:

| void NBCGenFor | ( | nps_syntax_node_t * | stree, |
| nps_node_t | r, | ||