本文整理汇总了C++中SymbolTable类的典型用法代码示例。如果您正苦于以下问题:C++ SymbolTable类的具体用法?C++ SymbolTable怎么用?C++ SymbolTable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SymbolTable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QString
Ilwis::OperationImplementation::State Coord2Pixel::prepare(ExecutionContext *ctx, const SymbolTable& symTable)
{
QString raster = _expression.parm(0).value();
if (!_inputGC.prepare(raster)) {
ERROR2(ERR_COULD_NOT_LOAD_2,raster,"");
return sPREPAREFAILED;
}
if ( _expression.parameterCount() == 2) {
QString name = _expression.parm(1).value();
QVariant var = symTable.getValue(name);
_coord = var.value<Coordinate>();
}
if ( _expression.parameterCount() == 3) {
bool ok1, ok2, ok3=true;
double x = _expression.parm(1).value().toDouble(&ok1);
double y = _expression.parm(2).value().toDouble(&ok2);
double z = 0;
if(_expression.parameterCount() == 4) {
z = _expression.parm(2).value().toDouble(&ok3);
}
if (! (ok1 && ok2 && ok3)) {
ERROR2(ERR_ILLEGAL_VALUE_2,"Coordinate", QString("%1 %2 %3").arg(x,y,x));
return sPREPAREFAILED;
}
_coord = Coordinate(x,y,z) ;
}
if ( _expression.parameterCount(false) == 1) {
_outName = _expression.parm(0,true,false).value();
}
if ( _coord.isValid())
return sPREPARED;
return sPREPAREFAILED;
}
示例2: doIDStatement
bool TermNode::doIDStatement(SymbolTable &symbols, int scope, ExecutionContext *ctx) {
QString expression;
if ( ctx->_additionalInfo.find(IMPLICITPARMATER0) != ctx->_additionalInfo.end()){
_value = { _id->id(), NodeValue::ctID};
return true;
}
_id->evaluate(symbols, scope, ctx);
QString value;
if ( _id->isReference()) {
if ( symbols.getSymbol(_id->id(),scope).isValid())
value = _id->id();
else
return false;
}
else
value = _id->id();
if ( _selectors.size() > 0) {
// selectors are handled by successive calls to the selection operation and in the end giving the temp object to the value
expression = buildBracketSelection(value);
if(!Ilwis::commandhandler()->execute(expression, ctx, symbols)) {
throw ScriptExecutionError(TR("Expression execution error in script; script aborted. See log for further details"));
}
QString outgc = ctx->_results[0];
value = outgc;
}
_value = {value, NodeValue::ctID};
return value != "" && value != sUNDEF;
}
示例3: doMethodStatement
bool TermNode::doMethodStatement(SymbolTable &symbols, int scope, ExecutionContext *ctx){
QString parms = "(";
for(int i=0; i < ctx->_additionalInfo.size() && ctx->_useAdditionalParameters; ++i){
QString extrapar = IMPLICITPARMATER + QString::number(i);
auto iter = ctx->_additionalInfo.find(extrapar);
if ( iter != ctx->_additionalInfo.end()){
if ( parms.size() > 1)
parms += ",";
parms += (*iter).second;
}
}
for(int i=0; i < _parameters->noOfChilderen(); ++i) {
bool ok = _parameters->child(i)->evaluate(symbols, scope, ctx);
if (!ok)
return false;
QString name = getName(_parameters->child(i)->value());
if ( parms.size() > 1)
parms += ",";
parms += name;
}
parms += ")";
QString expression = _id->id() + parms;
bool ok = Ilwis::commandhandler()->execute(expression, ctx, symbols);
if ( !ok || ctx->_results.size() != 1)
throw ScriptExecutionError(TR("Expression execution error in script; script aborted. See log for further details"));
_value = {symbols.getValue(ctx->_results[0]), ctx->_results[0], NodeValue::ctMethod};
return true;
}
示例4: eval
ExprResult IdentifierNode::eval()
{
ExprResult result;
ActivationReg* areg = ActivationReg::getInstance();
SymbolTable* table = areg->top();
Symbol* sym = table->get(mName);
if (sym != NULL && sym->isVar())
{
result.setType(sym->getType());
result.setValue(sym->getValue());
}
else
{
Log::fatal("Uso de identificador não definido");
}
return result;
}
示例5: extract
void NameSpace::extract(Symbol::Kind kind, SymbolTable& table) const
{
for (SymbolTable::const_iterator it = _symbols.begin(); it != _symbols.end(); ++it)
{
if (it->second->kind() == kind)
table.insert(*it);
}
}
示例6: constructJSWebAssemblyModule
static EncodedJSValue JSC_HOST_CALL constructJSWebAssemblyModule(ExecState* state)
{
VM& vm = state->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSValue val = state->argument(0);
// If the given bytes argument is not a BufferSource, a TypeError exception is thrown.
JSArrayBuffer* arrayBuffer = val.getObject() ? jsDynamicCast<JSArrayBuffer*>(val.getObject()) : nullptr;
JSArrayBufferView* arrayBufferView = val.getObject() ? jsDynamicCast<JSArrayBufferView*>(val.getObject()) : nullptr;
if (!(arrayBuffer || arrayBufferView))
return JSValue::encode(throwException(state, scope, createTypeError(state, ASCIILiteral("first argument to WebAssembly.Module must be an ArrayBufferView or an ArrayBuffer"), defaultSourceAppender, runtimeTypeForValue(val))));
if (arrayBufferView ? arrayBufferView->isNeutered() : arrayBuffer->impl()->isNeutered())
return JSValue::encode(throwException(state, scope, createTypeError(state, ASCIILiteral("underlying TypedArray has been detatched from the ArrayBuffer"), defaultSourceAppender, runtimeTypeForValue(val))));
size_t byteOffset = arrayBufferView ? arrayBufferView->byteOffset() : 0;
size_t byteSize = arrayBufferView ? arrayBufferView->length() : arrayBuffer->impl()->byteLength();
const auto* base = arrayBufferView ? static_cast<uint8_t*>(arrayBufferView->vector()) : static_cast<uint8_t*>(arrayBuffer->impl()->data());
Wasm::Plan plan(&vm, base + byteOffset, byteSize);
// On failure, a new WebAssembly.CompileError is thrown.
plan.run();
if (plan.failed())
return JSValue::encode(throwException(state, scope, createWebAssemblyCompileError(state, plan.errorMessage())));
// On success, a new WebAssembly.Module object is returned with [[Module]] set to the validated Ast.module.
auto* structure = InternalFunction::createSubclassStructure(state, state->newTarget(), asInternalFunction(state->jsCallee())->globalObject()->WebAssemblyModuleStructure());
RETURN_IF_EXCEPTION(scope, { });
// The export symbol table is the same for all Instances of a Module.
SymbolTable* exportSymbolTable = SymbolTable::create(vm);
for (auto& exp : plan.exports()) {
auto offset = exportSymbolTable->takeNextScopeOffset(NoLockingNecessary);
exportSymbolTable->set(NoLockingNecessary, exp.field.impl(), SymbolTableEntry(VarOffset(offset)));
}
// Only wasm-internal functions have a callee, stubs to JS do not.
unsigned calleeCount = plan.internalFunctionCount();
JSWebAssemblyModule* result = JSWebAssemblyModule::create(vm, structure, plan.takeModuleInformation(), plan.takeCallLinkInfos(), plan.takeWasmToJSStubs(), plan.takeFunctionIndexSpace(), exportSymbolTable, calleeCount);
plan.initializeCallees(state->jsCallee()->globalObject(),
[&] (unsigned calleeIndex, JSWebAssemblyCallee* jsEntrypointCallee, JSWebAssemblyCallee* wasmEntrypointCallee) {
result->setJSEntrypointCallee(vm, calleeIndex, jsEntrypointCallee);
result->setWasmEntrypointCallee(vm, calleeIndex, wasmEntrypointCallee);
});
return JSValue::encode(result);
}
示例7: main
int main( int /* argc */, char** /* argv */ )
{
Scanner scanner = Scanner();
SymbolTable st = SymbolTable();
Token *currTok;
currTok = scanner.nextToken();
while( 1 )
{
std::cout << currTok->tokenCodeToString();
if( currTok->getDataType() == dt_OP )
std::cout << "(" << currTok->opCodeToString() << ")";
else if( currTok->getDataType() != dt_KEYWORD && currTok->getDataType() != dt_NONE )
{
std::cout << "(" << currTok->getDataValue().lexeme << ")";
}
std::cout << " ";
//symtab
if( currTok->getTokenCode() == tc_ID || currTok->getTokenCode() == tc_NUMBER )
{
SymbolTableEntry *entry = st.lookup( currTok->getDataValue().lexeme );
if(!entry)
{
entry = st.insert( currTok->getDataValue().lexeme );
currTok->setSymTabEntry( entry );
}
currTok->setSymTabEntry( entry );
}
if(currTok->getTokenCode() == tc_EOF)
break;
currTok = scanner.nextToken();
}
std::cout << "\n\n";
st.print();
return 0;
}
示例8: VarDefinition
void VarDefinition(SymbolTable &table)
{
if (symbol!=IDEN) ErrorHandler("Error defination shold begin with iden");//Throw Error while define var, expect iden
table.Push(token, varsk);
do {
GetNextSym();
if (symbol==COLON) break;
if (symbol!=COMMA) ErrorHandler("multi-var should be seperate via ,");
GetNextSym();
if (symbol!=IDEN) ErrorHandler("Error defination should be iden, but you used "+token); //throw error while define var
table.Push(token, varsk);
} while (true);
GetNextSym();
if (symbol==INTTK) table.SetType( integerst);
else if (symbol==CHARTK) table.SetType( charst);
//table.SetKind(varsk);
else if (symbol==ARRAYTK) {
GetNextSym();
if (symbol!=LBRACK) ErrorHandler("Error while define arr,miss [");//Throw Error expect [
GetNextSym();
if (symbol!=INTCON) ErrorHandler("[k] k should be number");// Throw Error expect number
table.SetTypeValue( arrOfCh, number);
GetNextSym();
if (symbol!=RBRACK) ErrorHandler("define arr, miss ]");//Throw Error expect ]
GetNextSym();
if (symbol!=OFTK) ErrorHandler("define arr miss of");//Throw Error expect of
GetNextSym();
if (symbol!=INTTK && symbol!=CHARTK) ErrorHandler("define arr miss char or integer"); //Throw error expect char or integer
if (symbol==INTTK) table.SetType( arrOfInt);
} else ErrorHandler("var type illegal");
table.FillBack();
GetNextSym();
if (symbol==IDEN) ErrorHandler("miss ;");
}
示例9: assert
Symbol*
SymbolTable::findInAll(SymbolTable* gamma, std::string key)
{
assert(gamma && "No gamma!");
SymbolTable* current = gamma;
List<SymbolTable*>* blocks = current->getBlocks();
for (int i = 0; i < blocks->getNumElements(); i++)
{
SymbolTable* tmpST = blocks->getNth(i);
Symbol* sym = tmpST->findLocal(key);
if (sym != NULL)
{
return sym;
}
}
return NULL;
}
示例10: traverseFullDepTree2
void traverseFullDepTree2()
{
// assign a class index to all classes
if (!parseFailed && !compileErrors) {
buildClassTree();
gNumClasses = 0;
// now I index them during pass one
indexClassTree(class_object, 0);
setSelectorFlags();
if (2*numClassDeps != gNumClasses) {
error("There is a discrepancy.\n");
/* not always correct
if(2*numClassDeps < gNumClasses) {
post("Duplicate files may exist in the directory structure.\n");
} else {
post("Some class files may be missing.\n");
}
*/
post("numClassDeps %d gNumClasses %d\n", numClassDeps, gNumClasses);
findDiscrepancy();
compileErrors++;
} else {
double elapsed;
buildBigMethodMatrix();
SymbolTable* symbolTable = gMainVMGlobals->symbolTable;
post("\tNumber of Symbols %d\n", symbolTable->NumItems());
post("\tByte Code Size %d\n", totalByteCodes);
//elapsed = TickCount() - compileStartTime;
//elapsed = 0;
elapsed = elapsedTime() - compileStartTime;
post("\tcompiled %d files in %.2f seconds\n",
gNumCompiledFiles, elapsed );
if(numOverwrites == 1){
post("\nInfo: One method is currently overwritten by an extension. To see which, execute:\nMethodOverride.printAll\n\n");
}
else if(numOverwrites > 1){
post("\nInfo: %i methods are currently overwritten by extensions. To see which, execute:\nMethodOverride.printAll\n\n", numOverwrites);
}
post("compile done\n");
}
}
}
示例11: log_variable
void log_variable( string variable_name, SymbolTable& table, bool status_key )
{
if( status_key )
{
if( table.exist_symbol( variable_name ) )
{
Symbol variable = table.find_symbol_by_name( variable_name );
variable.list_attributes_symbol();
} else
{
print_message_undeclared_variable( );
}
} else
{
// Nothing To Do
}
}
示例12: Symbol
SymbolTable *
SymbolTable::addWithScope(std::string key, TType* ttype, int scope)
{
SymbolTable *newGamma = new SymbolTable;
Symbol *sym;
newGamma->setParent(this);
if (_this)
{
newGamma->setThis(_this);
}
sym = new Symbol(key, ttype, scope, newGamma);
assert(sym && "No symbol to enter to ST");
_table->enter(key, sym, false);
_blocks->append(newGamma);
return newGamma;
}
示例13:
Symbol *
SymbolTable::findSuper(std::string key)
{
SymbolTable *current = _super;
if (!_super)
{
return NULL;
}
for ( ; current != NULL; current = current->getSuper())
{
if (Symbol* sym = current->findLocal(key))
{
return sym;
}
}
return NULL;
}
示例14: Codegen
Function* FunctionAST::Codegen()
{
Function* theFunction = Proto->Codegen();
if(theFunction == 0)
return 0;
BasicBlock* BB = BasicBlock::Create(getGlobalContext(),"entry",theFunction);
Builder.SetInsertPoint(BB);
Proto->CreateArgumentAllocas(theFunction);
vector<ExprAST*>::iterator it = Body.begin();
Value* last;
for(it = Body.begin(); it != Body.end(); ++it)
{
last = (*it)->Codegen();
if (!last)
break;
}
if(last)
{
Builder.CreateRet(last);
verifyFunction(*theFunction);
NamedValues.clear();
return theFunction;
}
//If it gets here there's an error! erase the function
theFunction->eraseFromParent();
return 0;
}
示例15: get
bool HashMap::get( const std::string& key, std::string& value) const
{
uint32_t id = m_symtab.get( key);
if (!id) return false;
value.append( m_value_strings.c_str() + m_value_refs[ id-1]);
return true;
}