aboutsummaryrefslogtreecommitdiffstats
path: root/src/resp.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/resp.hpp')
-rw-r--r--src/resp.hpp32
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;
};