diff options
author | David Robillard <d@drobilla.net> | 2010-12-03 00:35:28 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2010-12-03 00:35:28 +0000 |
commit | bbad3fe368b2086ec93f082a9436b1dfbc8f0e84 (patch) | |
tree | 941799ecdfeaeb15d3235ec85c6678b07a73e8d8 /src/resp.hpp | |
parent | 35e977e8786b667155bf6b186bebb9c0938fb587 (diff) | |
download | resp-bbad3fe368b2086ec93f082a9436b1dfbc8f0e84.tar.gz resp-bbad3fe368b2086ec93f082a9436b1dfbc8f0e84.tar.bz2 resp-bbad3fe368b2086ec93f082a9436b1dfbc8f0e84.zip |
Remove AFn.
git-svn-id: http://svn.drobilla.net/resp/resp@284 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'src/resp.hpp')
-rw-r--r-- | src/resp.hpp | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/src/resp.hpp b/src/resp.hpp index ff1bc19..0f372a1 100644 --- a/src/resp.hpp +++ b/src/resp.hpp @@ -525,15 +525,6 @@ struct List { typedef List<AType, AType> TList; -/// Fn (first-class function with captured lexical bindings) -struct AFn : public ATuple { - AFn(const ATuple* exp) : ATuple(*exp) {} - AFn(Cursor c, AST* ast, va_list args) : ATuple(c, ast, args) {} - bool operator==(const AST& rhs) const { return this == &rhs; } - void constrain(TEnv& tenv, Constraints& c) const throw(Error); - string name; -}; - /// Function call/application, e.g. "(func arg1 arg2)" struct ACall : public ATuple { ACall(const ATuple* exp) : ATuple(*exp) {} @@ -727,7 +718,7 @@ struct Engine { const ATuple* args, const AType* type) = 0; - virtual void pushFunctionArgs(CEnv& cenv, const AFn* fn, const AType* type, CFunc f) = 0; + virtual void pushFunctionArgs(CEnv& cenv, const ACall* fn, const AType* type, CFunc f) = 0; virtual void finishFunction(CEnv& cenv, CFunc f, CVal ret) = 0; virtual void eraseFunction(CEnv& cenv, CFunc f) = 0; @@ -809,15 +800,15 @@ struct CEnv { Env<const ASymbol*, const AST*> code; - typedef map<const AFn*, CFunc> Impls; + typedef map<const ACall*, CFunc> Impls; Impls impls; - CFunc findImpl(const AFn* fn, const AType* type) { + CFunc findImpl(const ACall* fn, const AType* type) { Impls::const_iterator i = impls.find(fn); return (i != impls.end()) ? i->second : NULL; } - void addImpl(const AFn* fn, CFunc impl) { + void addImpl(const ACall* fn, CFunc impl) { impls.insert(make_pair(fn, impl)); } @@ -826,8 +817,8 @@ struct CEnv { CFunc currentFn; ///< Currently compiling function struct FreeVars : public std::vector<ASymbol*> { - FreeVars(AFn* f, const std::string& n) : fn(f), implName(n) {} - AFn* const fn; + FreeVars(ACall* f, const std::string& n) : fn(f), implName(n) {} + ACall* const fn; const std::string implName; int32_t index(ASymbol* sym) { const_iterator i = find(begin(), end(), sym); @@ -842,6 +833,17 @@ struct CEnv { typedef std::stack<FreeVars> LiftStack; LiftStack liftStack; + typedef map<const ACall*, std::string> Names; + Names names; + + const std::string name(const ACall* fn) const { + Names::const_iterator i = names.find(fn); + return (i != names.end()) ? i->second : ""; + } + + void setName(const ACall* fn, const std::string& name) { + names.insert(make_pair(fn, name)); + } private: Engine* _engine; }; |