diff options
author | David Robillard <d@drobilla.net> | 2009-06-24 04:46:57 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2009-06-24 04:46:57 +0000 |
commit | 2235923ea73318d3eeba64754f461209c23d9f2f (patch) | |
tree | 75fdcf48c25e26419c09f5eb064fb48dbe65fd86 | |
parent | 0c98e0fc52c08d9c87af4e72112b8f774a04f3af (diff) | |
download | resp-2235923ea73318d3eeba64754f461209c23d9f2f.tar.gz resp-2235923ea73318d3eeba64754f461209c23d9f2f.tar.bz2 resp-2235923ea73318d3eeba64754f461209c23d9f2f.zip |
Funcs => AFn::Impls
git-svn-id: http://svn.drobilla.net/resp/tuplr@146 ad02d1e2-f140-0410-9f75-f8b11f17cedd
-rw-r--r-- | Makefile | 10 | ||||
-rw-r--r-- | llvm.cpp | 8 | ||||
-rw-r--r-- | tuplr.hpp | 20 |
3 files changed, 23 insertions, 15 deletions
@@ -10,7 +10,15 @@ all: builddir build/tuplr builddir: mkdir -p build -build/tuplr: build/tuplr.o build/typing.o build/llvm.so build/gclib.so build/write.o build/gc.o +OBJECTS = \ + build/tuplr.o \ + build/typing.o \ + build/llvm.so \ + build/gclib.so \ + build/write.o \ + build/gc.o + +build/tuplr: $(OBJECTS) g++ -o $@ $^ $(LDFLAGS) build/%.o: %.cpp tuplr.hpp @@ -215,7 +215,7 @@ AFn::lift(CEnv& cenv) cenv.pop(); AType* type = cenv.type(this); - if (funcs.find(type) || !type->concrete()) + if (impls.find(type) || !type->concrete()) return; AType* protT = type->at(1)->as<AType*>(); @@ -243,7 +243,7 @@ AFn::liftCall(CEnv& cenv, const AType& argsT) } Object::pool.addRoot(thisType); - if (funcs.find(thisType)) + if (impls.find(thisType)) return; ATuple* protT = thisType->at(1)->as<ATuple*>(); @@ -321,7 +321,7 @@ AFn::liftCall(CEnv& cenv, const AType& argsT) try { // Define value first for recursion cenv.precompile(this, f); - funcs.push_back(make_pair(thisType, f)); + impls.push_back(make_pair(thisType, f)); CValue retVal = NULL; for (size_t i = 2; i < size(); ++i) retVal = cenv.compile(at(i)); @@ -380,7 +380,7 @@ ACall::compile(CEnv& cenv) TEnv::GenericTypes::const_iterator gt = cenv.tenv.genericTypes.find(c); assert(gt != cenv.tenv.genericTypes.end()); AType fnT(loc, cenv.penv.sym("Fn"), &protT, cenv.type(this), 0); - Function* f = (Function*)c->funcs.find(&fnT); + Function* f = (Function*)c->impls.find(&fnT); THROW_IF(!f, loc, (format("callee failed to compile for type %1%") % fnT.str()).str()); vector<Value*> params(size() - 1); @@ -340,15 +340,6 @@ struct Subst : public map<const AType*,AType*,typeLessThan> { } }; -/// Lifted system functions (of various types) for a single Tuplr function -struct Funcs : public list< pair<AType*, CFunction> > { - CFunction find(AType* type) const { - for (const_iterator f = begin(); f != end(); ++f) - if (*f->first == *type) - return f->second; - return NULL; - } -}; /// Closure (first-class function with captured lexical bindings) struct AFn : public ATuple { @@ -360,7 +351,16 @@ struct AFn : public ATuple { void liftCall(CEnv& cenv, const AType& argsT); CValue compile(CEnv& cenv); ATuple* prot() const { return at(1)->to<ATuple*>(); } - Funcs funcs; + /// System level implementations of this (polymorphic) fn + struct Impls : public list< pair<AType*, CFunction> > { + CFunction find(AType* type) const { + for (const_iterator f = begin(); f != end(); ++f) + if (*f->first == *type) + return f->second; + return NULL; + } + }; + Impls impls; mutable Subst subst; string name; }; |