void compileParams(void) { if (lookAhead->tokenType == SB_LPAR) { eat(SB_LPAR); compileParam(); while (lookAhead->tokenType == SB_SEMICOLON) { eat(SB_SEMICOLON); compileParam(); } eat(SB_RPAR); } }
void compileParams2(void) { while(lookAhead->tokenType == SB_SEMICOLON){ eat(SB_SEMICOLON); compileParam(); //compileParams2(); } }
void compileParams(void) { while(lookAhead->tokenType == SB_LPAR){ eat(SB_LPAR); compileParam(); compileParams2(); eat(SB_RPAR); } }
void compileParams2(void) { // TODO if(lookAhead->tokenType==SB_SEMICOLON) { eat(SB_SEMICOLON); compileParam(); compileParams2(); } }
void ExprCompiler::compile(Module* module, int maxLocals, gc<Pattern> leftParam, gc<Pattern> rightParam, gc<Pattern> valueParam, gc<Expr> body) { currentFile_ = chunk_->addFile(module->source()); module_ = module; // Reserve slots up front for all of the locals. This ensures that // temps will always be after locals. // TODO(bob): Using max here isn't optimal. Ideally a given temp only // needs to be after the locals that are in scope during the duration // of that temp. But calculating that is a bit hairy. For now, until we // have a more advanced compiler, this is a simple solution. numLocals_ = maxLocals; maxSlots_ = MAX(maxSlots_, numLocals_); PatternCompiler compiler(*this, true); // Track the slots used for the arguments and result. This code here // must be kept carefully in sync with the similar prelude code in // Resolver. int numParamSlots = 0; // Evaluate the method's parameter patterns. compileParam(compiler, leftParam, numParamSlots); compileParam(compiler, rightParam, numParamSlots); compileParam(compiler, valueParam, numParamSlots); // The result slot is just after the param slots. compile(body, numParamSlots); write(body->pos(), OP_RETURN, numParamSlots); ASSERT(numTemps_ == 0, "Should not have any temps left."); compiler.endJumps(); }
void compileParams2(void) { // TODO switch(lookAhead->tokenType){ case SB_SEMICOLON: eat(SB_SEMICOLON); compileParam(); compileParams2(); break; case SB_RPAR: break; default: error(ERR_INVALIDPARAM,lookAhead->lineNo,lookAhead->colNo); break; } }