void CCodeGenerator::operator()(Assignment* expr) { // Handle all types of assignment, including member assignment Expression::Ptr init = expr->initializer(); if (dynamic_cast<Empty*>(init.pointer())) { return_ = Operand(env_->integer("0")); } else { return_ = emit(init); } String::Ptr id = expr->identifier(); Variable::Ptr var = variable(id); Attribute::Ptr attr = class_ ? class_->attribute(id) : 0; if (var) { // Assignment to a local var that has already been initialized once in // the current scope. Type::Ptr type = var->type(); if (!type->is_value()) { refcount_dec(Operand(var->name())); } line(); out_ << id->string() << " = " << return_ << ";\n"; if (!type->is_value()) { refcount_inc(Operand(var->name())); } } else if (attr) { // Assignment to an attribute within a class /* Type::Ptr type = expr->type(); Variable::Ptr self = variable(env_->name("__self")); Operand addr = Operand::addr(, attr->slot()); Operand old = load(addr); if (!type->is_value() && !attr->is_weak()) { refcount_dec(old); } store(addr, return_); if (!type->is_value() && !attr->is_weak()) { refcount_inc(return_); } */ assert(!"not impl"); } else { // Assignment to a local var that has not yet been initialized in the // current scope. Type::Ptr declared = expr->declared_type(); if (declared->is_top()) { declared = expr->type(); } line(); brace(); operator()(declared); out_ << " " << id->string() << " = " << return_ << "; "; out_ << "(void)" << id->string() << ";\n"; variable(new Variable(id, declared)); if (!declared->is_value()) { refcount_inc(return_); } } }
static void swap() { int left_var = variable(), right_var = variable(); int reg_one = next_register(), reg_two = next_register(); CodeGen(LOAD, reg_one, left_var, EMPTY_FIELD); CodeGen(LOAD, reg_two, right_var, EMPTY_FIELD); CodeGen(STORE, left_var, reg_two, EMPTY_FIELD); CodeGen(STORE, right_var, reg_one, EMPTY_FIELD); }
void factor() { int clase_rerere_loca; switch (sbol->codigo) { case CIDENT: if(en_tabla(sbol->lexema) != NIL) { /*&*/ clase_rerere_loca = Clase_Ident(sbol->lexema); switch (clase_rerere_loca) { case CLASPAR: case CLASVAR: variable(); break; case CLASFUNC: llamada_funcion(); break; default: error_handler(8);// palabra reservada } } else { // no esta en la tabla error_handler(33); // identificador no declarado inf_id->ptr_tipo = en_tabla("TIPOERROR"); variable(); } break; case CCONS_ENT: case CCONS_FLO: case CCONS_CAR: constante(); break; case CCONS_STR: scanner(); break; case CPAR_ABR: { scanner(); expresion(); if (sbol->codigo == CPAR_CIE) { scanner(); } else { error_handler(20); // falta ) } break; } case CNEG: { scanner(); expresion(); break; } default: error_handler(31); // error de factor } }
// --- void QGAMES::MovementOneByOne::initialize () { QGAMES::Movement::initialize (); _speed = (int) variable (0); _baseSpeed = (int) variable (1); if (_baseSpeed == 0) _baseSpeed = 1; if (_speed == 0) _speed = _baseSpeed; _counterMSpeed[0] = _counterMSpeed[1] = 0; }
void UmlAccessVariableValueAction::html(Q3CString pfix, unsigned int rank, unsigned int level) { UmlActivityAction::html(); if (variable() != 0){ fw.write("<p>Variable : "); variable()->write(); fw.write("</p>"); } write_children(pfix, rank, level); unload(FALSE, FALSE); }
void parse_variable_length (int v) { if (variable().type == VariableInfo::VARIABLE) { switch (v) { case 1: variable().type = VariableInfo::VARIABLE1; case 2: variable().type = VariableInfo::VARIABLE2; } } variable().size = v; }
void CEquSystem::closeVarloop() const { // Make the loop of all appearance of given variable in different equations for (auto i = nVar(); i--;) { auto pVar = variable(i); if (pVar) { auto pVarNextEqu = variable(i + nVar()); pVar->setSameVarNextEqu(pVarNextEqu); while (pVarNextEqu->sameVarNextEqu() != pVar) pVarNextEqu = pVarNextEqu->sameVarNextEqu(); pVar->setSameVarPrevEqu(pVarNextEqu); } } }
struct syntax_node * factor(){ struct syntax_node * t; t = (struct syntax_node*)malloc(sizeof(struct syntax_node)); chushihua_t(t); if(strcmp(current_token->value, "(") == 0) { t->child[0] = zuokuohao(); t->child[1] = Exp(); t->child[2] = youkuohao(); } else if(strcmp(current_token->kind, "INTC") == 0) { t->child[0] = intc(); } else { t->child[0] = variable(); } strcpy(t->kind_name, "Factor"); return t; }
// --- void MovementIntoThePen::initialize () { PacmanEntityMovement::initialize (); _firstMove = true; int maxLoops = (int) variable (1); _counter = (maxLoops == 0) ? (rand () % 100) : (rand () % maxLoops); }
void VariableEditor::UpdateVars(const gedString item) { listVars->RemoveAll(); Script::PopulateLocalUserVars(listVars); GameControl::Get()->PopulateGlobalUserVars(listVars); listVars->Sort(); if(item.length()) { for(int index = 0; index < listVars->Count(); index++) { gedString variable(listVars->GetText(index)); int i = variable.find('['); if(i == gedString::npos) i = variable.find(' '); variable = variable.substr(0, i); if(variable == item) { listVars->SetItem(index); break; } } } }
type term(double t, double *X) { const int m = 1; if(c=='(' || c=='[') { type r; next(); r = E(t,X); if(c != ')' && c !=']') syntax(); next(); return m * r; } else if((c >= '0' && c <= '9') || c == '.') { return m * constant(t,X); } else if( c=='t' || c=='x' || c=='y' || c=='z' ) return m * variable(t,X); else if(c >= 'a' && c <= 'z') return m * function(t,X); return 0.0; }
Iter_ operator() (const Match_& a_match, Iter_& a_iter) const { const std::string field = (*(a_match[1]. first) == '{') ? a_match[2]. str() : a_match[1]. str(); std::string value; if (! field. empty() && *field. begin() == ':') { value = variable(field. substr(1)); } else { const placeholders_t::const_iterator found_at = m_placeholders. find(field); if (found_at != m_placeholders. end()) { value = (this ->* (found_at -> second))(); } else { value = "%{" + field + '}'; } } std::copy(value. begin(), value. end(), a_iter); return a_iter; }
//---------------------------------------------------------------------- void ShaderGenerator::AddOutVariable( const std::string& type, std::string name ) { ShaderVariable variable( GetVariableTypeFromString( type ), name, "", false ); variable.declarationStatment = "out " + GetVariableTypeAsString( variable.type ) + " " + name + ";"; unsigned int hash = HashStringTo32Bytes( name ); m_outVariables[ hash ] = variable; }
// ------------------------------------------------------------------- // MyOnlineState // ------------------------------------------------------------------- void SFSBuddyManager::MyOnlineState(bool value) { boost::shared_ptr<bool> pvalue (new bool()); *pvalue = value; boost::shared_ptr<BuddyVariable> variable(new SFSBuddyVariable(ReservedBuddyVariables::BV_ONLINE, pvalue, VARIABLETYPE_BOOL)); SetMyVariable (variable); }
BVTerm BVTerm::substitute(const std::map<BVVariable,BVTerm>& _substitutions) const { BVTermType type = this->type(); if(type == BVTermType::CONSTANT) { return *this; } if(type == BVTermType::VARIABLE) { auto iter = _substitutions.find(variable()); if(iter != _substitutions.end()) { return iter->second; } return *this; } if(typeIsUnary(type)) { BVTerm operandSubstituted = operand().substitute(_substitutions); return BVTerm(type, operandSubstituted, index()); } if(typeIsBinary(type)) { BVTerm firstSubstituted = first().substitute(_substitutions); BVTerm secondSubstituted = second().substitute(_substitutions); return BVTerm(type, firstSubstituted, secondSubstituted); } if(type == BVTermType::EXTRACT) { BVTerm operandSubstituted = operand().substitute(_substitutions); return BVTerm(type, operandSubstituted, highest(), lowest()); } assert(false); return BVTerm(); }
const wasm_module::Instruction* InterpreterThread::callFunction( const std::string& moduleName, const std::string& functionName, std::vector<wasm_module::Variable> parameters) { if (functionStack_.size() >= functionStackLimit) throw StackLimitReached(std::to_string(functionStack_.size())); const wasm_module::Function* func = nullptr; wasm_module::Module& module = env_.getModule(moduleName); func = &env_.getFunction(moduleName, functionName); if (func->variadic()) { std::vector<const wasm_module::Type*> types; for (auto& parameter : parameters) { types.push_back(¶meter.type()); } functionStack_.push_back(FunctionState(*func, types)); } else { // We push the new locals to the functionStack_ before entering. functionStack_.push_back(FunctionState(*func)); } for (uint32_t i = 0; i < parameters.size(); i++) { variable(i) = parameters.at(i); } return func->mainInstruction(); }
void bind_names ( node_t *root ) { if (root != NULL) { switch (root->type.index) { case PROGRAM: program(root); break; case FUNCTION_LIST: bind_functions(root); break; case FUNCTION: function(root); break; case VARIABLE: variable(root); break; case BLOCK: block(root); break; case DECLARATION: declaration(root); break; case TEXT: string(root); break; default: skipNode(root); break; } } }
void PixelMap :: paintEvent (QPaintEvent *) { QPainter p (this); auto t = term (); auto v = variable (); if (nullptr == t || nullptr == v) { p .fillRect (0, 0, width (), height (), Qt :: gray); return; } const int w = width (); const int h = height (); QImage i (w, h, QImage :: Format_RGB32); for (int y = h-1; y >= 0; --y) { for (int x = 0; x < w; ++x) { v -> set_value (screen_to_value ({x, y})); i .setPixel (x, y, colour (t -> value ())); } } p .drawImage (0, 10, i); }
// <factor> ::= <variable> // | <constant> // | ( <expression> ) // | NOT <factor> // <variable> ::= <simple variable> // | <index variable> // <simple variable> ::= <identifier of variable> // <index variable> ::= <variable array> [ <expression> ] // <variable array> ::= <simple variable> // <identifier of variable> ::= <identifier> // <constant> ::= <intconst> // | <charconst> // | <identifier of constant> // <identifier of constant> ::= <identifier> void SyntaxAnalyzer::factor() { switch (symbol) { case ident: variable(); break; case intconst: case charconst: // @todo - conflict // case ident: nextsymbol(); break; case leftparent: accept(leftparent); expression(); accept(rightparent); break; case notop: nextsymbol(); factor(); default: //@todo - what error ? break; } } // factor( )
Statement* Expand::operator()(For* f) { string variable(f->variable()); Expression* low = f->lower_bound()->perform(eval->with(env, backtrace)); if (low->concrete_type() != Expression::NUMBER) { error("lower bound of `@for` directive must be numeric", low->path(), low->position(), backtrace); } Expression* high = f->upper_bound()->perform(eval->with(env, backtrace)); if (high->concrete_type() != Expression::NUMBER) { error("upper bound of `@for` directive must be numeric", high->path(), high->position(), backtrace); } double lo = static_cast<Number*>(low)->value(); double hi = static_cast<Number*>(high)->value(); if (f->is_inclusive()) ++hi; Env new_env; new_env[variable] = new (ctx.mem) Number(low->path(), low->position(), lo); new_env.link(env); env = &new_env; Block* body = f->block(); for (double i = lo; i < hi; (*env)[variable] = new (ctx.mem) Number(low->path(), low->position(), ++i)) { append_block(body); } env = new_env.parent(); return 0; }
wasm_module::Instruction* Thread::callFunction( const std::string& moduleName, const std::string& functionName, std::vector<wasm_module::Variable> parameters) { wasm_module::Function* func = nullptr; wasm_module::Module& module = env_.getModule(moduleName); if (module.hasImport(functionName)) { const wasm_module::ModuleImport& moduleImport = module.getImport(functionName); func = &env_.getFunction(moduleImport.module(), moduleImport.signature().name()); } else { func = &env_.getFunction(moduleName, functionName); } enterFunction(*func); for (uint32_t i = 0; i < parameters.size(); i++) { variable(i) = parameters.at(i); } return func->mainInstruction(); }
void LLDBReply::FromJSON(const JSONElement& json) { m_replyType = json.namedObject("m_replyType").toInt(kReplyTypeInvalid); m_interruptResaon = json.namedObject("m_stopResaon").toInt(kInterruptReasonNone); m_line = json.namedObject("m_line").toInt(wxNOT_FOUND); m_filename = json.namedObject("m_filename").toString(); m_lldbId = json.namedObject("m_lldbId").toInt(); m_expression = json.namedObject("m_expression").toString(); m_debugSessionType = json.namedObject("m_debugSessionType").toInt(kDebugSessionTypeNormal); m_text = json.namedObject("m_text").toString(); m_breakpoints.clear(); JSONElement arr = json.namedObject("m_breakpoints"); for(int i = 0; i < arr.arraySize(); ++i) { LLDBBreakpoint::Ptr_t bp(new LLDBBreakpoint()); bp->FromJSON(arr.arrayItem(i)); m_breakpoints.push_back(bp); } m_variables.clear(); JSONElement localsArr = json.namedObject("m_locals"); m_variables.reserve(localsArr.arraySize()); for(int i = 0; i < localsArr.arraySize(); ++i) { LLDBVariable::Ptr_t variable(new LLDBVariable()); variable->FromJSON(localsArr.arrayItem(i)); m_variables.push_back(variable); } m_backtrace.Clear(); JSONElement backtrace = json.namedObject("m_backtrace"); m_backtrace.FromJSON(backtrace); m_threads = LLDBThread::FromJSON(json, "m_threads"); }
std::string dotNETServiceGenerator::generateHStub(Interface & i, Info & info) { string tmp = TEMPLATE_STUB; replaceAll(tmp, "<stubname>", info.name); string stub_upper = info.name; std::transform(stub_upper.begin(), stub_upper.end(), stub_upper.begin(), ::toupper); replaceAll(tmp, "<STUBNAME>", stub_upper); replaceAll(tmp, "<includes>", "#include \"" + info.getInterfaceHeader() + "\""); //std::string fname = jsonp ? "Json" : "Jsonp"; vector<string> fullnmspc = i.namesp; fullnmspc.push_back("DotNet"); replaceAll(tmp, "<namespaceStart>", generateNamespaceStart(fullnmspc)); replaceAll(tmp, "<namespaceEnd>", generateNamespaceEnd(fullnmspc)); //generate procedures std::string clientStr; std::string privateClientStr; std::string serversStr; for (Class::List::iterator c = i.classes.begin(); c != i.classes.end(); c++) { clientStr.append(generateClientMethodSignature(*c) + ";" + "\n"); privateClientStr.append(fullClassName(c->namesp, "I" + c->name) + "::Ptr " + variable(c->name) + ";" + "\n"); } replaceAll(tmp, "<clients>", clientStr); replaceAll(tmp, "<private>", privateClientStr); return tmp; }
//---------------------------------------------------------------------- void ShaderGenerator::AddInVariable( const std::string& type, std::string name ) { ShaderVariable variable( GetVariableTypeFromString( type ), name, "", false ); variable.declarationStatment = "in " + GetVariableTypeAsString( variable.type ) + " " + name + ";"; unsigned int hash = HashStringTo32Bytes( name ); m_inVariables[ hash ] = variable; m_orderToDeclareInVariables.push_back( &m_inVariables[ hash ] ); }
QVariantMap QgsExpressionContext::variablesToMap() const { QStringList names = variableNames(); QVariantMap m; Q_FOREACH ( const QString &name, names ) { m.insert( name, variable( name ) ); }
// --- void QGAMES::JumpMovement::initialize () { QGAMES::Movement::initialize (); _maxX = (QGAMES::bdata) variable (0); _maxY = (QGAMES::bdata) variable (1); _pass = (QGAMES::bdata) variable (2); setDirection ((int) variable (3)); _sqrtMaxY = sqrt (_maxY); // To speed up the calculation later on... _xAxis = (QGAMES::bdata) 0.0; _yAxis = (QGAMES::bdata) 0.0; _firstMovement = true; _originalPosition = QGAMES::Position::_cero; _isJumping = false; _count = (QGAMES::bdata) 0.0; }
// --- void PacmanEntityMovement::initialize () { // The speed is the variable 0, or the number changed during the game... _speed = (_changedSpeed == -1) ? (int) variable (0) : _changedSpeed; _accelerated = 1; // No acceleration... if (_speed == 0) _speed = __BASESPEED; // If the result is 0, then the minimum speed allowed is the base one... }
const variable operator -(const variable &left_value, const variable &right_value) { if (_STYLE(left_value.type) != _STYLE(right_value.type)) throw VARIABLE_OPERATION_ERROR; if (OBJ == left_value.type || STR == _EVT(left_value.type)) throw VARIABLE_OPERATION_ERROR; type_ type = _LEN(left_value.type) >= _LEN(right_value.type) ? left_value.type : right_value.type; try { switch (_EVT(type)) { case B_1: return variable(((b_1)left_value) - ((b_1)right_value)); case UB_1: return variable(((ub_1)left_value) - ((ub_1)right_value)); case B_2: return variable(((b_2)left_value) - ((b_2)right_value)); case UB_2: return variable(((ub_2)left_value) - ((ub_2)right_value)); case B_4: return variable(((b_4)left_value) - ((b_4)right_value)); case UB_4: return variable(((ub_4)left_value) - ((ub_4)right_value)); case B_8: return variable(((b_8)left_value) - ((b_8)right_value)); case UB_8: return variable(((ub_8)left_value) - ((ub_8)right_value)); case FB_4: return variable(((fb_4)left_value) - ((fb_4)right_value)); case FB_8: return variable(((fb_8)left_value) - ((fb_8)right_value)); default: throw VARIABLE_OPERATION_ERROR; } } catch (...) { throw; } }
void proposicion_e_s() { switch(sbol->codigo) { case CIN: { scanner(); if (sbol->codigo == CSHR) { scanner(); } else { error_handler(28); // falta >> } variable(); while (sbol->codigo == CSHR) { scanner(); variable(); } if (sbol->codigo == CPYCOMA) { scanner(); } else { error_handler(22); // falta ; } break; } case COUT: { scanner(); if (sbol->codigo == CSHL) { scanner(); } else { error_handler(29); // falta << } expresion(); while (sbol->codigo == CSHL) { scanner(); expresion(); } if (sbol->codigo == CPYCOMA) { scanner(); } else { error_handler(22); // falta ; } break; } default: error_handler(30); // %& //falta << o >> } }
StdString Parser::assignment(MethodGenerationContext* mgenc) { StdString v = variable(); VMSymbol* var = GetUniverse()->SymbolFor(v); mgenc->AddLiteralIfAbsent(var); expect(Assign); return v; }