Ejemplo n.º 1
0
/// prototype
///   ::= id '(' id* ')'
std::unique_ptr<PrototypeAST> Parser::parsePrototype(s_cursor_t &it, const s_cursor_t &end) {
    if (_curTok != tok_identifier)
        return ErrorP("Expected function name in prototype");

    std::string fnName = _identifier;
    getNextToken(it, end);

    if ( _curTok != '(' )
        return ErrorP("Expected '(' in prototype");

    std::vector<std::string> argNames;
    getNextToken(it, end);
    while (_curTok == tok_identifier) {
        argNames.push_back(_identifier);
        if (getNextToken(it, end) == ',')
            getNextToken(it, end);
    }

    if ( _curTok != ')' )
        return ErrorP("Expected ')' in prototype");

    getNextToken(it, end); // eat ')'

    return llvm::make_unique<PrototypeAST>(&_builder, _module, fnName, std::move(argNames));
}
Ejemplo n.º 2
0
/// prototype
///   ::= id '(' id* ')'
static PrototypeAST *ParsePrototype() {
  if (CurTok != tok_identifier)
    return ErrorP("Expected function name in prototype");

  std::string FnName = IdentifierStr;
  getNextToken();

  if (CurTok != '(')
    return ErrorP("Expected '(' in prototype");

  std::vector<std::string> ArgNames;
  while (getNextToken() == tok_identifier)
    ArgNames.push_back(IdentifierStr);
  if (CurTok != ')')
    return ErrorP("Expected ')' in prototype");

  // success.
  getNextToken();  // eat ')'.

  return new PrototypeAST(FnName, ArgNames);
}
Ejemplo n.º 3
0
/// prototype
///   ::= id '(' id* ')'
static std::unique_ptr<PrototypeAST> ParsePrototype() {
    if (CurTok != tok_identifier)
        return ErrorP("Expected function name in prototype");

    std::string FnName = IdentifierStr;
    getNextToken();

    if (CurTok != '(')
        return ErrorP("Expected '(' in prototype");

    std::vector<std::string> ArgNames;
    while (getNextToken() == tok_identifier)
        ArgNames.push_back(IdentifierStr);
    if (CurTok != ')')
        return ErrorP("Expected ')' in prototype");

    // success.
    getNextToken(); // eat ')'.

    return helper::make_unique<PrototypeAST>(FnName, std::move(ArgNames));
}
Ejemplo n.º 4
0
FrictionForceGenerator::FrictionForceGenerator(Simulation *sim, RandomGenerator *random)
    : ForceGenerator(sim),
    myRandom(random, Sim->Config->FrictionSpringBreakage, Sim->Config->FrictionDeviation)
{
    mySpringsPerBlock = Sim->Config->SpringsPerBlock;
    mySpringData = new(nothrow) FrictionSpringInfo[Sim->Config->Rows * Sim->Config->Columns * Sim->Config->SpringsPerBlock];
    if(mySpringData == NULL)
    {
        ErrorP("Alloc failed");
        exit(1);
    }
    mySpringsPerBlock = Sim->Config->SpringsPerBlock;
    for(uint i = 0; i < Sim->Config->Rows * Sim->Config->Columns * Sim->Config->SpringsPerBlock; i++)
    {
        mySpringData[i].Anchor = 0;
        mySpringData[i].BreakForce = myRandom.GetNormalizedRandom();
        if(isnan(mySpringData[i].BreakForce))
        {
            ErrorP("Random is nan");
        }
        mySpringData[i].SpringConstant = Sim->Config->FrictionSpringConstant * sqrt(mySpringData[i].BreakForce/Sim->Config->FrictionSpringBreakage);
        //DebugPF(DDetail, "%dBreak force: %g, Constant: %g",i, mySpringData[i].BreakForce, mySpringData[i].SpringConstant);
    }
}