CodeBlock YpAssign(CBorLit lhs, CodeBlock rhs) { long initialPC; if (IS_LITERAL(lhs)) { /* this is definition of a variable */ long name= CBL_VALUE(lhs); int undecided= !(literalTypes[name]&L_REFERENCE); initialPC= rhs; if (CheckCodeSpace(2)) return initialPC; vmCode[nextPC++].Action= previousOp= &Define; VariableReference(name); if (undecided) { literalTypes[name]|= L_LOCAL; nLocal++; } } else { /* this is assignment to an lvalue */ initialPC= CBL_VALUE(lhs); if (CheckCodeSpace(1)) return initialPC; vmCode[nextPC++].Action= previousOp= ≔ WillPopStack(1L); } return initialPC; }
void madara::knowledge::containers::FlexMap::set_name( const std::string& var_name, KnowledgeBase& knowledge) { if (context_ != &(knowledge.get_context()) || name_ != var_name) { context_ = &(knowledge.get_context()); ContextGuard context_guard(*context_); MADARA_GUARD_TYPE guard(mutex_); name_ = var_name; if (context_->exists(var_name, settings_)) { KnowledgeUpdateSettings keep_local(true); variable_ = context_->get_ref(var_name, keep_local); } else { // reset variable reference variable_ = VariableReference(); } } }
Integer Process::registerVariableReference( Variable* aVariable, Integer aCoefficient, const bool isAccessor ) { theVariableReferenceVector.push_back( VariableReference( theNextSerial, aVariable, aCoefficient, isAccessor ) ); return theNextSerial++; }
Integer Process::registerVariableReference( String const& aName, Variable* aVariable, Integer aCoefficient, const bool isAccessor ) { theVariableReferenceVector.push_back( VariableReference( theNextSerial, aVariable, aCoefficient, isAccessor ) ); theVariableReferenceVector.back().setName( aName ); return theNextSerial++; }
void YpKeyword(Literal name, CodeBlock value) { int undecided = !(literalTypes[name] & L_REFERENCE); if (CheckCodeSpace(2)) return; vmCode[nextPC++].Action= previousOp= &FormKeyword; VariableReference(name); if (undecided) { /* default is for keywords to become local, not extern */ literalTypes[name] &= ~L_REFERENCE; literalTypes[name] |= L_LOCAL; /* note nLocal does not increment */ } WillPushStack(); }
CodeBlock YpNextArg(int which) { long initialPC= nextPC; if (!(hasPosList&1)) { YpError("next_arg() or more_args() needs .. function parameter"); } else { Literal name= YpName("*va*", 4L); if (CheckCodeSpace(2)) return initialPC; vmCode[nextPC++].Action= previousOp= which? &MoreArgs : &NextArg; VariableReference(name); WillPushStack(); } return initialPC; }
CodeBlock YpVariable(Literal name) { long initialPC= nextPC; if (CheckCodeSpace(2)) return initialPC; if (stackDepth==0 && reparsing) RecordLineNumber(nextPC); vmCode[nextPC++].Action= previousOp= &PushVariable; /* set wasUndecided flag if this is the first reference of this variable */ wasUndecided= !(literalTypes[name]&L_REFERENCE); if (wasUndecided && (literalTypes[name]&L_LOCAL)) literalTypes[name] &= ~L_LOCAL; /* now seen as other than keyword */ VariableReference(name); WillPushStack(); return initialPC; }
CodeBlock YpIncrement(CodeBlock lhs, int assop, CodeBlock rhs) { /* assop is 0-9: += -= *= /= %= <<= >>= &= ~= |= */ if (lhs+2==rhs && vmCode[lhs].Action==&PushVariable) { /* this is increment and redefine a variable */ if (CheckCodeSpace(3)) return lhs; vmCode[nextPC++].Action= Binaries[assopMap[assop]]; vmCode[nextPC++].Action= previousOp= &Define; VariableReference(vmCode[lhs+1].index); WillPopStack(1L); } else { /* this is increment of an lvalue */ if (CheckCodeSpace(3)) return lhs; vmCode[nextPC++].Action= &DupUnder; WillPushStack(); vmCode[nextPC++].Action= Binaries[assopMap[assop]]; vmCode[nextPC++].Action= previousOp= ≔ WillPopStack(2L); } return lhs; }
void madara::knowledge::containers::FlexMap::set_name( const std::string& var_name, Variables& knowledge) { if (context_ != knowledge.get_context() || name_ != var_name) { context_ = knowledge.get_context(); ContextGuard context_guard(*context_); MADARA_GUARD_TYPE guard(mutex_); name_ = var_name; if (context_->exists(var_name, settings_)) { update_variable(); } else { // reset variable reference variable_ = VariableReference(); } } }