diff options
author | David Robillard <d@drobilla.net> | 2009-06-18 03:55:17 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2009-06-18 03:55:17 +0000 |
commit | 4e34e229beb12164ea49b1121785dc71eb7c3566 (patch) | |
tree | 3951bb94748289698cba24cc220be5323938e645 | |
parent | 815991c906f912c4eb52e1d3646a6110d472a8ec (diff) | |
download | resp-4e34e229beb12164ea49b1121785dc71eb7c3566.tar.gz resp-4e34e229beb12164ea49b1121785dc71eb7c3566.tar.bz2 resp-4e34e229beb12164ea49b1121785dc71eb7c3566.zip |
Strip trailing whitespace.
git-svn-id: http://svn.drobilla.net/resp/tuplr@118 ad02d1e2-f140-0410-9f75-f8b11f17cedd
-rw-r--r-- | llvm.cpp | 30 | ||||
-rw-r--r-- | tuplr.cpp | 10 | ||||
-rw-r--r-- | tuplr.hpp | 8 | ||||
-rw-r--r-- | typing.cpp | 4 | ||||
-rw-r--r-- | write.cpp | 10 |
5 files changed, 31 insertions, 31 deletions
@@ -173,7 +173,7 @@ compileFunction(CEnv& cenv, const std::string& name, const Type* retT, const ATu if (!argNames.empty()) for (size_t i = 0; i != protT.size(); ++a, ++i) a->setName(argNames.at(i)); - + BasicBlock* bb = BasicBlock::Create("entry", f); llengine(cenv)->builder.SetInsertPoint(bb); @@ -232,7 +232,7 @@ AClosure::liftCall(CEnv& cenv, const vector<AType*>& argsT) return; ATuple* protT = thisType->at(1)->as<ATuple*>(); - + // Write function declaration string name = this->name == "" ? cenv.gensym("_fn") : this->name; Function* f = compileFunction(cenv, name, @@ -286,9 +286,9 @@ ACall::lift(CEnv& cenv) at(i)->lift(cenv); argsT.push_back(cenv.type(at(i))); } - + if (!c) return; // Primitive - + if (c->prot()->size() < size() - 1) throw Error((format("too many arguments to function `%1%'") % at(0)->str()).str(), loc); if (c->prot()->size() > size() - 1) @@ -301,7 +301,7 @@ CValue ACall::compile(CEnv& cenv) { AClosure* c = cenv.tenv.resolve(at(0))->to<AClosure*>(); - + if (!c) return NULL; // Primitive AType* protT = new AType(loc, NULL); @@ -425,7 +425,7 @@ APrimitive::compile(CEnv& cenv) else return llengine(cenv)->builder.CreateICmp(pred, a, b); } - + throw Error("unknown primitive", loc); } @@ -444,9 +444,9 @@ AConsCall::lift(CEnv& cenv) AType* funcType = functionType(cenv); if (funcs.find(functionType(cenv))) return; - + ACall::lift(cenv); - + ATuple* protT = new ATuple(loc, cenv.type(at(1)), cenv.type(at(2)), 0); vector<const Type*> types; @@ -457,12 +457,12 @@ AConsCall::lift(CEnv& cenv) sz += t->getPrimitiveSizeInBits(); } sz = (sz % 8 == 0) ? sz / 8 : sz / 8 + 1; - + llvm::IRBuilder<>& builder = llengine(cenv)->builder; StructType* sT = StructType::get(types, false); Type* pT = PointerType::get(sT, 0); - + // Write function declaration vector<string> argNames; argNames.push_back("car"); @@ -474,14 +474,14 @@ AConsCall::lift(CEnv& cenv) Value* s = builder.CreateGEP(cell, ConstantInt::get(Type::Int32Ty, 0), "pair"); Value* carP = builder.CreateStructGEP(s, 0, "car"); Value* cdrP = builder.CreateStructGEP(s, 1, "cdr"); - + Function::arg_iterator ai = func->arg_begin(); Value& carArg = *ai++; Value& cdrArg = *ai++; builder.CreateStore(&carArg, carP); builder.CreateStore(&cdrArg, cdrP); builder.CreateRet(cell); - + cenv.optimise(func); funcs.push_back(make_pair(funcType, func)); } @@ -599,7 +599,7 @@ repl(CEnv& cenv) AST* body = cenv.penv.parse(exp); // Parse input Constraints c; body->constrain(cenv.tenv, c); // Constrain types - + Subst oldSubst = cenv.tsubst; cenv.tsubst = Subst::compose(cenv.tsubst, TEnv::unify(c)); // Solve type constraints @@ -607,7 +607,7 @@ repl(CEnv& cenv) if (!bodyT) throw Error("call to untyped body", cursor); body->lift(cenv); - + if (lltype(bodyT)) { // Create anonymous function to insert code into Function* f = compileFunction(cenv, cenv.gensym("_repl"), lltype(bodyT), ATuple(cursor)); @@ -637,7 +637,7 @@ newCenv(PEnv& penv, TEnv& tenv) { LLVMEngine* engine = new LLVMEngine(); CEnv* cenv = new CEnv(penv, tenv, engine); - + // Host provided allocation primitive prototypes std::vector<const Type*> argsT(1, Type::Int32Ty); FunctionType* funcT = FunctionType::get(PointerType::get(Type::Int8Ty, 0), argsT, false); @@ -160,7 +160,7 @@ initLang(PEnv& penv, TEnv& tenv) penv.reg(true, "cons", PEnv::Handler(parseCall<AConsCall>)); penv.reg(true, "car", PEnv::Handler(parseCall<ACarCall>)); penv.reg(true, "cdr", PEnv::Handler(parseCall<ACdrCall>)); - + // Numeric primitives penv.reg(true, "+", PEnv::Handler(parseCall<APrimitive>)); penv.reg(true, "-", PEnv::Handler(parseCall<APrimitive>)); @@ -228,12 +228,12 @@ main(int argc, char** argv) } int ret = 0; - + string output; map<string,string>::const_iterator a = args.find("-o"); if (a != args.end()) output = a->second; - + a = args.find("-p"); if (a != args.end()) { ifstream is(files.front().c_str()); @@ -251,7 +251,7 @@ main(int argc, char** argv) istringstream is(a->second); ret = eval(*cenv, "(command line)", is); } - + for (list<string>::iterator f = files.begin(); f != files.end(); ++f) { ifstream is(f->c_str()); if (is.good()) { @@ -265,7 +265,7 @@ main(int argc, char** argv) if (args.find("-r") != args.end() || (files.empty() && args.find("-e") == args.end())) ret = repl(*cenv); - + if (output != "") { ofstream os(output.c_str()); if (os.good()) { @@ -433,7 +433,7 @@ inline ostream& operator<<(ostream& out, const Constraints& c) { out << i->first << " : " << i->second << endl; return out; } - + struct Subst : public map<const AType,AType*> { Subst(AType* s=0, AType* t=0) { if (s && t) { assert(s != t); insert(make_pair(*s, t)); } } static Subst compose(const Subst& delta, const Subst& gamma); @@ -506,10 +506,10 @@ struct TEnv : public Env< const ASymbol*, pair<AST*, AType*> > { struct CEnv { CEnv(PEnv& p, TEnv& t, CEngine e, ostream& os=std::cout, ostream& es=std::cerr); ~CEnv(); - + typedef Env<const ASymbol*, AST*> Code; typedef Env<const AST*, CValue> Vals; - + CEngine engine(); string gensym(const char* s="_") { return (format("%s%d") % s % symID++).str(); } void push() { tenv.push(); vals.push(); } @@ -528,7 +528,7 @@ struct CEnv { tenv.def(sym, make_pair(c, t)); vals.def(sym, v); } - + ostream& out; ostream& err; PEnv& penv; @@ -122,7 +122,7 @@ ACall::constrain(TEnv& tenv, Constraints& c) const at(0)->constrain(tenv, c); for (size_t i = 1; i < size(); ++i) at(i)->constrain(tenv, c); - + AST* callee = tenv.resolve(at(0)); AClosure* closure = callee->to<AClosure*>(); if (closure) { @@ -263,7 +263,7 @@ ACdrCall::constrain(TEnv& tenv, Constraints& c) const /*************************************************************************** - * Type Inferencing/Substitution * + * Type Inference/Substitution * ***************************************************************************/ static void @@ -23,11 +23,11 @@ operator<<(ostream& out, const AST* ast) const ALiteral<float>* flit = ast->to<const ALiteral<float>*>(); if (flit) return out << showpoint << flit->val; - + const ALiteral<int32_t>* ilit = ast->to<const ALiteral<int32_t>*>(); if (ilit) return out << ilit->val; - + const ALiteral<bool>* blit = ast->to<const ALiteral<bool>*>(); if (blit) return out << (blit->val ? "#t" : "#f"); @@ -35,7 +35,7 @@ operator<<(ostream& out, const AST* ast) const ASymbol* sym = ast->to<const ASymbol*>(); if (sym) return out << sym->cppstr; - + const AType* type = ast->to<const AType*>(); if (type) { switch (type->kind) { @@ -44,7 +44,7 @@ operator<<(ostream& out, const AST* ast) case AType::EXPR: break; // will catch Tuple case below } } - + const ATuple* tup = ast->to<const ATuple*>(); if (tup) { out << "("; @@ -52,7 +52,7 @@ operator<<(ostream& out, const AST* ast) out << tup->at(i) << ((i != tup->size() - 1) ? " " : ""); return out << ")"; } - + return out << "?"; } |