void compileProcDecl(void) { Object* procObj; eat(KW_PROCEDURE); eat(TK_IDENT); // TODO: Check if a procedure identifier is fresh in the block checkFreshIdent(currentToken->string); // create a procedure object procObj = createProcedureObject(currentToken->string); // declare the procedure object declareObject(procObj); // enter the procedure's block enterBlock(procObj->procAttrs->scope); // parse the procedure's parameters compileParams(); eat(SB_SEMICOLON); compileBlock(); eat(SB_SEMICOLON); // exit the block exitBlock(); }
void compileProcDecl(void) { Object* procObj; eat(KW_PROCEDURE); eat(TK_IDENT); checkFreshIdent(currentToken->string); procObj = createProcedureObject(currentToken->string); procObj->procAttrs->codeAddress = getCurrentCodeAddress(); declareObject(procObj); enterBlock(procObj->procAttrs->scope); compileParams(); eat(SB_SEMICOLON); compileBlock(); eat(SB_SEMICOLON); exitBlock(); }
void compileFuncDecl(void) { // TODO: create and declare a function object Object* funcObj; Type* returnType; eat(KW_FUNCTION); eat(TK_IDENT); funcObj = createFunctionObject(currentToken->string); declareObject(funcObj); enterBlock(funcObj->funcAttrs->scope); compileParams(); eat(SB_COLON); returnType = compileBasicType(); funcObj->funcAttrs->returnType = returnType; eat(SB_SEMICOLON); compileBlock(); eat(SB_SEMICOLON); exitBlock(); }