Ejemplo n.º 1
0
void PostureStateEigen::storeHandDOF(const double *dof)
{
	double *eg = new double[ mHand->getEigenGrasps()->getSize() ];
	mHand->getEigenGrasps()->getAmp(eg, dof);
	for (int i=0; i < mHand->getEigenGrasps()->getSize(); i++) {
		getVariable(i)->setValue(eg[i]);
	}
	delete [] eg;
}
Ejemplo n.º 2
0
Object *ContainerParser::readVariable(const ObjectType &type, std::streamoff offset)
{
    Object* child = getVariable(type, offset);
    if (child != nullptr && child->size() == -1LL) {
        child->parse();
        child->setSize(child->_contentSize);
    }
    return child;
}
Ejemplo n.º 3
0
static Variable* getVariable(Scope* scope, StringSlice identifier, bool checkFather = true)
{
    Variable* result = findElement(&scope->variables, identifier, checkVariablePredicat);

    if (checkFather && !result && scope->father != nullptr)
        return getVariable(scope->father, identifier, true);
    else
        return result;
}
Ejemplo n.º 4
0
void StorageN11Action::suspend()
{
  XBT_IN("(%p)", this);
  if (suspended_ != 2) {
    lmm_update_variable_weight(getModel()->getMaxminSystem(), getVariable(), 0.0);
    suspended_ = 1;
  }
  XBT_OUT();
}
Ejemplo n.º 5
0
llvm::Value* VariableExprAST::codegen() {
  debug_info_helper->emitLocation(getLoc());
  llvm::Value* variable = getVariable(name_);
  if (variable == nullptr) {
    LOG(FATAL) << "Using unassigned variable: " << name_ << ", loc " << getLoc().toString();
  }
  llvm::LoadInst* load_inst = cur_builder->CreateLoad(variable, getTmpName());
  return load_inst;
}
Ejemplo n.º 6
0
 void StructuredBuffer::getVariable(const std::string& name, size_t elementIndex, VarType& value)
 {
     size_t offset;
     const auto* pData = mpReflector->getVariableData(name, offset);
     if ((_LOG_ENABLED == 0) || (pData && checkVariableType<VarType>(pData->type, name, mpReflector->getName())))
     {
         getVariable(offset, elementIndex, value);
     }
 }
Ejemplo n.º 7
0
bool ZMProcessor::executeExtendedInstruction()
{
    uint8_t inst = _memory[_pc + 1];
    uint8_t opCode = inst & 0x1f;  // opcode is bottom five bits
    int operands = (inst & 0x20) ? -1 : 2;
    uint8_t operandTypeFields = _memory[_pc + 2];
    int operandFieldCount;

    _operandOffset = 3;
    
    _operandTypes[0] = operandType(operandTypeFields >> 6);
    _operandTypes[1] = operandType(operandTypeFields >> 4);
    _operandTypes[2] = operandType(operandTypeFields >> 2);
    _operandTypes[3] = operandType(operandTypeFields);
    
    if (operands == 2)
    {
        _instructionLength = 3;
        operandFieldCount = 4;
    }
    else
    {
        _instructionLength = 3;
        operandFieldCount = 4;
        _operandTypes[4] = kOmitted;
        _operandTypes[5] = kOmitted;
        _operandTypes[6] = kOmitted;
        _operandTypes[7] = kOmitted;
    }
    
    _operandCount = 0;
    for (int i = 0; i < operandFieldCount; ++i)
    {
        if (_operandTypes[i] == kOmitted)
            break;
        else if (_operandTypes[i] == kLargeConstant)
        {
            _operands[_operandCount] = ZMMemory::readWordFromData(_memory.getData() + _pc + _instructionLength);
            _instructionLength += 2;
        }
        else if (_operandTypes[i] == kSmallConstant)
        {
            _operands[_operandCount] = _memory[_pc + _instructionLength];
            ++_instructionLength;
        }
        else if (_operandTypes[i] == kVariable)
        {
            _operands[_operandCount] = getVariable(_memory[_pc + _instructionLength]);
            _operandVariables[_operandCount] = _memory[_pc + _instructionLength];
            ++_instructionLength;
        }
        ++_operandCount;
    }
    
    return dispatchEXT(opCode);
}
Ejemplo n.º 8
0
static double eval_variableexpr(const struct VariableExpression* expression, struct Scope* scope)
{
    struct Variable* var = getVariable(expression->identifier, scope);
    if (var == NULL)
    {
        printf("unknown variable '%s'\n", expression->identifier);
        exit(1);
    }
    return var->value;
}
Ejemplo n.º 9
0
CpuCas01Action::CpuCas01Action(Model *model, double cost, bool failed, double speed, lmm_constraint_t constraint)
 : CpuAction(model, cost, failed, lmm_variable_new(model->getMaxminSystem(), this, 1.0, speed, 1))
{
  if (model->getUpdateMechanism() == UM_LAZY) {
    indexHeap_ = -1;
    lastUpdate_ = surf_get_clock();
    lastValue_ = 0.0;
  }
  lmm_expand(model->getMaxminSystem(), constraint, getVariable(), 1.0);
}
Ejemplo n.º 10
0
// TODO: make more reasonable error messages
static bool getValue(Scope* scope, ASTNode* dotExpression, RuntimeError* error, Value* result)
{
    if (dotExpression->nodeType == AST_EXPRESSION_IDENTIFIER)
    {
        Variable* variable = getVariable(scope, dotExpression->identifier.identifier);
        if (variable)
        {
            *result = variable->value;
            return true;
        }
        else
        {
            *error = RuntimeError{ 
                RET_UNDEFINED_VARIABLE, 
                dotExpression->identifier.identifier, 
                dotExpression->identifier.lineNumber 
            };

            return false;
        }
    }
    else if (dotExpression->nodeType == AST_EXPRESSION_DOT)
    {
        Value leftValue;
        if (getValue(scope, dotExpression->binary.left, error, &leftValue))
        {
            StructMember* member = findElement(
                &leftValue.type.definition->members,
                dotExpression->binary.right->identifier.identifier,
                checkStructMemberPredicat
            );

            if (member)
            {
                *result = Value{ member->type, leftValue.memory + member->offsetInBytes };
                return true;
            }
            else
            {
                *error = RuntimeError{ 
                    RET_UNDEFINED_VARIABLE, 
                    dotExpression->binary.right->identifier.identifier, 
                    dotExpression->binary.right->identifier.lineNumber 
                };

                return false;
            }
        }
        else
            return false;
    }

    assert(!"should not be happening");
    return false;
}
Ejemplo n.º 11
0
const char* Properties::getString(const char* name, const char* defaultValue) const
{
    char variable[256];
    const char* value = NULL;

    if (name)
    {
        // If 'name' is a variable, return the variable value
        if (isVariable(name, variable, 256))
        {
            return getVariable(variable, defaultValue);
        }

        for (std::vector<Property>::const_iterator itr = _properties.begin(); itr != _properties.end(); ++itr)
        {
            if (itr->name == name)
            {
                value = itr->value.c_str();
                break;
            }
        }
    }
    else
    {
        // No name provided - get the value at the current iterator position
        if (_propertiesItr != _properties.end())
        {
            value = _propertiesItr->value.c_str();
        }
    }

    if (value)
    {
        // If the value references a variable, return the variable value
        if (isVariable(value, variable, 256))
            return getVariable(variable, defaultValue);

        return value;
    }

    return defaultValue;
}
Ejemplo n.º 12
0
llvm::Value* AssignmentExprAST::codegen() {
  debug_info_helper->emitLocation(getLoc());
  llvm::Value* variable = getVariable(var_name_);
  if (variable == nullptr) {
    variable = createVariable(var_name_, getLoc(), 0);
  }
  CHECK(variable != nullptr);
  llvm::Value* value = right_->codegen();
  cur_builder->CreateStore(value, variable);
  return value;
}
Ejemplo n.º 13
0
/// Return the (constant) value of a variable.
stx::AnyScalar	VariableRegistry::lookupVariable(const std::string &varname) const{
	
	shared_ptr<Variable> var = getVariable(varname);
	if(var == NULL){
        throw UnknownVariableException(varname);
	}
	
 Datum value = *(var);
	stx::AnyScalar retval = value;
	return retval;
	
}
Ejemplo n.º 14
0
void PositionStateComplete::setTran(const transf &t)
{
	getVariable("Tx")->setValue( t.translation().x() );
	getVariable("Ty")->setValue( t.translation().y() );
	getVariable("Tz")->setValue( t.translation().z() );
	getVariable("Qw")->setValue( t.rotation().w );
	getVariable("Qx")->setValue( t.rotation().x );
	getVariable("Qy")->setValue( t.rotation().y );
	getVariable("Qz")->setValue( t.rotation().z );
}
Ejemplo n.º 15
0
/**
 * @brief Returns the lastModifiedTime of a variable.
 * @param varname STRING
 * @return a DT
 */
void iec_lastModifiedTime(BOOL EN, BOOL *ENO, param_ret_t *RET, UINT count, param_u_t *in) {
	TEST_EN
	STRING	VARNAME = in++->STRINGvar;

	char	*varname = strndup((char *)VARNAME.body, VARNAME.len);
	iec_variable_t *v = getVariable(getCurrentContext(), varname);
	free (varname);

	DT dt_null = {0,0};
	RET->t	= DTtype;
	RET->p.DTvar = v ? v->lastModifiedTime : dt_null;
}
Ejemplo n.º 16
0
/*!	Right now we define the distance as the max distance between any two 
	variables. Alternatively, the mean distance between all variables could 
	also be used. For position states we could also look at the distance in 
	actual position.
*/
double
VariableSet::distance(const VariableSet *s) const
{
	if (getNumVariables() != s->getNumVariables()) return -1;
	double distance = 0;
	for (int i=0; i<getNumVariables(); i++) {
		double altD;
		double d = readVariable(i) - s->readVariable(i);	

		if ( getVariable(i)->isCircular() ) {
			//if the variable is circular, the shortest distance might be around the end
			//going one direction or the other
			altD = fabs( readVariable(i) - getVariable(i)->mMinVal ) + 
				fabs( s->readVariable(i) - getVariable(i)->mMaxVal );
			d = std::min(d, altD);

			altD = fabs( s->readVariable(i) - getVariable(i)->mMinVal ) + 
				fabs( readVariable(i) - getVariable(i)->mMaxVal );
			d = std::min(d, altD);
		}
		d = fabs(d) / getVariable(i)->getRange();
		distance = std::max(d, distance);
	}
	return distance;
}
Ejemplo n.º 17
0
void
RichardsMultiphaseProblem::initialSetup()
{
  // the first argument to getVariable is threadID - i hope the following always works
  unsigned int tid = 0;
  MooseVariable & bounded = getVariable(tid, _bounded_var_name);
  MooseVariable & lower = getVariable(tid, _lower_var_name);

  // some checks
  if (!bounded.isNodal() || !lower.isNodal())
    mooseError("Both the bounded and lower variables must be nodal variables in RichardsMultiphaseProblem");
  if (bounded.feType().family != lower.feType().family)
    mooseError("Both the bounded and lower variables must belong to the same element family (eg LAGRANGE) in RichardsMultiphaseProblem");
  if (bounded.feType().order != lower.feType().order)
    mooseError("Both the bounded and lower variables must have the same order (eg FIRST) in RichardsMultiphaseProblem");

  // extract the required info
  _bounded_var_num = bounded.number();
  _lower_var_num = lower.number();

  FEProblem::initialSetup();
}
Ejemplo n.º 18
0
//------------------------------------------------------------------------------
std::string Console::printVariable(const std::vector<std::string> & args)
{
    if (args.size() != 1) return "Invalid number of arguments.";

    unsigned index = getVariable(args[0]);
    if (index == INVALID_INDEX) return "Variable unknown.";

    std::ostringstream str;

    variable_[index].second->writeToStream(str);

    return str.str();
}
Ejemplo n.º 19
0
// Get attribute value from scalar variable given by vr and type, 
// incl. default value provided by declared type, if any.
const char * getVariableAttributeString(ModelDescription* md, 
        fmiValueReference vr, Elm type, Att a){
    const char* value;
    //const char* declaredType;
    Type* tp; 
    ScalarVariable* sv = getVariable(md, vr, type);
    if (!sv) return NULL;
    value = getString(sv->typeSpec, a);
    if (value) return value; // found
    // search declared type, if any
    tp = getDeclaredType(md, getString(sv->typeSpec, att_declaredType));
    return tp ? getString(tp->typeSpec, a) : NULL;
}
Ejemplo n.º 20
0
t_axe_label * getLabelFromVariableID(t_program_infos *program, char *ID)
{
   t_axe_variable *var;
   
   var = getVariable(program, ID);
   if (var == NULL)
      return NULL;

   /* test the postconditions */
   assert(var->labelID != NULL);
   
   return var->labelID;
}
Ejemplo n.º 21
0
float Distribution::getP1() const {
   const Variable* var = Variable::get(getVariable());
   if(var->isUpperDiscrete()) {
      float p1 = getCdf(var->getMin());
      if(Global::isValid(p1))
         return 1-p1;
      else
         return Global::MV;
   }
   else {
      return 0;
   }
}
Ejemplo n.º 22
0
void GuiProgressBitmapCtrl::onPreRender()
{
   const char * var = getVariable();
   if(var)
   {
      F32 value = mClampF(dAtof(var), 0.f, 1.f);
      if(value != mProgress)
      {
         mProgress = value;
         setUpdate();
      }
   }
}
Ejemplo n.º 23
0
stx::AnyScalar VariableRegistry::lookupVariable(const std::string &varname, const stx::AnyScalar &subscript) const {
    shared_ptr<Variable> var = getVariable(varname);
    if (!var) {
        throw UnknownVariableException(varname);
    }
    
    shared_ptr<SelectionVariable> sel = boost::dynamic_pointer_cast<SelectionVariable>(var);
    if (!sel) {
        throw SimpleException("Variable does not support subscripts", varname);
    }
    
    stx::AnyScalar value = sel->getTentativeSelection(subscript.getInteger());
    return value;
}
Ejemplo n.º 24
0
static void exec_assignstatement(const struct AssignmentStatement* statement, struct Scope* scope)
{
    double val = eval_expression(statement->expression, scope);
    struct Variable* var = getVariable(statement->identifier, scope);
    
    // Create variable if it does not exist
    if (var == NULL)
    {
        var = &scope->variables[scope->variableCount++];
        var->name = statement->identifier;
    }
    
    // Assign the value
    var->value = val;
}
Ejemplo n.º 25
0
void dxfHeader::assign(dxfFile*, codeValue &cv)
{
    if (cv._groupCode == 9)
    {
        _inVariable = true;
        VariableList var;
        _variables[cv._string] = var;
        _currentVariable       = cv._string;
    }
    else if (_inVariable)
    {
        VariableList &var = getVariable(_currentVariable);
        var.push_back(cv);
    }
}
Ejemplo n.º 26
0
const char *evaluate(const char* string, bool echo, const char *fileName)
{
   if (echo)
   {
      if (string[0] == '%')
         Con::printf("%s", string);
      else
         Con::printf("%s%s", getVariable( "$Con::Prompt" ), string);
   }

   if(fileName)
      fileName = StringTable->insert(fileName);

   CodeBlock *newCodeBlock = new CodeBlock();
   return newCodeBlock->compileExec(fileName, string, false, fileName ? -1 : 0);
}
    virtual void visitNode(AST::WhileStmt &node)
    {
        unsigned loopNo = 0;
        while (getVariable(node.getVarName()))
        {
            if (loopNo >= LOOPS_COUNT_LIMIT)
                break;
            ++loopNo;

            auto time = _worldTime;
            node.statement()->visit(*this);
            // no action performed
            if (time == _worldTime)
                break;
        }
    }
Ejemplo n.º 28
0
/**
 * @brief Force the variable to be updated to the GSCL at the current TIC
 * @param varname STRING
 * @return TRUE
 */
void iec_forceUpdate(BOOL EN, BOOL *ENO, param_ret_t *RET, UINT count, param_u_t *in) {
	TEST_EN
	STRING	VARNAME = in++->STRINGvar;

	char	*varname = strndup((char *)VARNAME.body, VARNAME.len);

	iec_variable_t *v = getVariable(getCurrentContext(), varname);
	if	(v) {
		v->flags |= VARFLAG_CHANGED;
	}

	free (varname);

	RET->t	= BOOLtype;
	RET->p.BOOLvar = TRUE;
}
Ejemplo n.º 29
0
int SipRequestContext::toString(UtlString& dumpString)
{
   int count = 0;
   UtlString name;
   UtlString value;
   dumpString.remove(0);

   while(getVariable(count, name, value))
   {
      dumpString.append(name);
      dumpString.append(": ");
      dumpString.append(value);
      dumpString.append("\n");
   }

   return(count);
}
Ejemplo n.º 30
0
	void Preprocessor::removeTrivialClauses(void)
	{
		SAT::CNF& formula(context().formula);
		formula.erase(std::remove_if(formula.begin(), formula.end(), [](SAT::Clause& clause) {
			for (auto itr = clause.begin();
				itr != clause.end();
				itr++)
			{
				if (itr + 1 != clause.end() && itr->getVariable() != (itr + 1)->getVariable())
					itr++;
				else
					return true;
			}
			return false;
		}
		), formula.end());
	}