本文整理汇总了C++中SymbolTable::InsertSymbol方法的典型用法代码示例。如果您正苦于以下问题:C++ SymbolTable::InsertSymbol方法的具体用法?C++ SymbolTable::InsertSymbol怎么用?C++ SymbolTable::InsertSymbol使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SymbolTable
的用法示例。
在下文中一共展示了SymbolTable::InsertSymbol方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: task_proc
static Symbol* task_proc(NodeFunction* pFunc, ParseInfo* pinfo, std::vector<Symbol*>* pvecSyms)
{
if(!pFunc || !pinfo) return 0;
SymbolTable *pTable = new SymbolTable();
SymbolArray arrArgs;
arrArgs.SetDontDel(1);
const NodeFunction *pThreadFunc = 0;
RuntimeInfo *pruninfo2 = new RuntimeInfo();
pThreadFunc = (NodeFunction*)pFunc/*->clone()->optimize()*/;
if(pvecSyms) arrArgs.GetArr() = *pvecSyms;
arrArgs.UpdateIndices();
pTable->InsertSymbol(T_STR"<args>", &arrArgs);
Symbol* pRet = pThreadFunc->eval(*pinfo, *pruninfo2, pTable);
pTable->RemoveSymbolNoDelete(T_STR"<ret>");
pTable->RemoveSymbolNoDelete(T_STR"<args>");
if(pTable) delete pTable;
if(pvecSyms) delete_symbols(pvecSyms);
//if(pThreadFunc) delete pThreadFunc;
delete pruninfo2;
return pRet;
}
示例2: if
//.........这里部分代码省略.........
// loading of input file
const char* pcFile = argv[iStartArg];
t_string strFile = STR_TO_WSTR(pcFile);
t_char* pcInput = load_file(pcFile);
if(!pcInput)
return -2;
ParseObj par;
ParseInfo info;
RuntimeInfo runinfo;
info.bEnableDebug = (uiDebugLevel>=4);
// lexing
par.strCurFile = strFile;
par.pLexer = new Lexer(pcInput, strFile.c_str());
delete[] pcInput;
pcInput = 0;
if(!par.pLexer->IsOk())
{
tl::log_err("Lexer returned with errors.");
return -3;
}
init_global_syms(info.pGlobalSyms);
// parsing
int iParseRet = yyparse(&par);
delete par.pLexer;
par.pLexer = 0;
if(iParseRet != 0)
{
tl::log_err("Parser returned with error code ", iParseRet, ".");
return -4;
}
// optimizing
par.pRoot = par.pRoot->optimize();
// executing
SymbolArray *parrMainArgs = new SymbolArray();
for(int iArg=iStartArg; iArg<argc; ++iArg)
{
SymbolString *pSymArg = new SymbolString();
pSymArg->SetVal(STR_TO_WSTR(argv[iArg]));
parrMainArgs->GetArr().push_back(pSymArg);
}
//std::vector<Symbol*> vecMainArgs = { &arrMainArgs };
SymbolTable *pTableSup = new SymbolTable();
info.pmapModules->insert(ParseInfo::t_mods::value_type(strFile, par.pRoot));
runinfo.strExecFkt = T_STR"main";
//info.pvecExecArg = &vecMainArgs;
runinfo.strInitScrFile = strFile;
SymbolArray arrMainArgs;
arrMainArgs.GetArr().push_back(parrMainArgs);
pTableSup->InsertSymbol(T_STR"<args>", &arrMainArgs);
par.pRoot->eval(info, runinfo, pTableSup);
pTableSup->RemoveSymbolNoDelete(T_STR"<args>");
delete pTableSup;
if(bShowSymbols)
{
tl::log_info("================================================================================");
tl::log_info("Global symbols:");
info.pGlobalSyms->print();
std::ostringstream ostrFkts;
for(const NodeFunction* pFunc : info.vecFuncs)
ostrFkts << pFunc->GetName() << ", ";
tl::log_info("Script functions: ", ostrFkts.str());
const t_mapFkts* pExtFkts = get_ext_calls();
std::ostringstream ostrSysFkts;
for(const auto& fktpair : *pExtFkts)
ostrSysFkts << fktpair.first << ", ";
tl::log_info("System functions: ", ostrSysFkts.str());
tl::log_info("================================================================================");
}
return 0;
}