ExprType ExprPrototypeNode::prep(bool wantScalar, ExprVarEnvBuilder& envBuilder) { // TODO: implement prototype bool error=false; checkCondition(false, "Prototypes are currently not supported",error); return ExprType().Error(); #if 0 bool error = false; if (_retTypeSet) checkCondition(returnType().isValid(), "Function has bad return type", error); _argTypes.clear(); for (int c = 0; c < numChildren(); c++) { ExprType type = child(c)->type(); checkCondition(type.isValid(), "Function has a parameter with a bad type", error); _argTypes.push_back(type); ExprLocalVar* localVar = new ExprLocalVar(type); envBuilder.current()->add(((ExprVarNode*)child(c))->name(), localVar); std::cerr << "after create localvar phi " << localVar->getPhi() << std::endl; child(c)->prep(wantScalar, envBuilder); } if (error) setType(ExprType().Error()); else setType(ExprType().None().Varying()); return _type; #endif }
ExprType ExprBlockNode::prep(bool wantScalar, ExprVarEnvBuilder& envBuilder) { ExprType assignType = child(0)->prep(false, envBuilder); ExprType resultType = child(1)->prep(wantScalar, envBuilder); if (!assignType.isValid()) setType(ExprType().Error()); else setType(resultType); return _type; }
ExprType ExprLocalFunctionNode::prep(bool wantScalar, ExprVarEnvBuilder& envBuilder) { #if 0 // TODO: no local functions for now bool error = false; // prep prototype and check for errors ExprPrototypeNode* prototype = (ExprPrototypeNode*)child(0); ExprVarEnv functionEnv; functionEnv.resetAndSetParent(&env); if (!prototype->prep(false, functionEnv).isValid()) error = true; // decide what return type we want bool returnWantsScalar = false; if (!error && prototype->isReturnTypeSet()) returnWantsScalar = prototype->returnType().isFP(1); // prep block and check for errors ExprNode* block = child(1); ExprType blockType = block->prep(returnWantsScalar, functionEnv); if (!error && blockType.isValid()) { if (prototype->isReturnTypeSet()) { if (blockType != prototype->returnType()) { checkCondition(false, "In function result of block '" + blockType.toString() + "' does not match given return type " + prototype->returnType().toString(), error); } } else prototype->setReturnType(blockType); // register the function in the symbol table env.addFunction(prototype->name(), this); } else { checkCondition(false, "Invalid type for blockType is " + blockType.toString(), error); error = true; } return _type = error ? ExprType().Error() : ExprType().None().Varying(); #else bool error=false; checkCondition(false,"Local functions are currently not supported.",error); return ExprType().Error(); #endif }