diff options
author | David Robillard <d@drobilla.net> | 2010-12-29 00:35:28 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2010-12-29 00:35:28 +0000 |
commit | 42b51cce2575fa138fddf1cfd4581bf1d1568b24 (patch) | |
tree | 03ea8256f19d3418fd4e847391a4b5a84f8b6e0f /src/c.cpp | |
parent | 703f1840af79ca4480c664190cdcf7e6fbd7b90e (diff) | |
download | resp-42b51cce2575fa138fddf1cfd4581bf1d1568b24.tar.gz resp-42b51cce2575fa138fddf1cfd4581bf1d1568b24.tar.bz2 resp-42b51cce2575fa138fddf1cfd4581bf1d1568b24.zip |
Literal lists (i.e. list quoting).
Compile type expressions.
Only compile a top-level function if program has code to run (i.e. isn't just definitions).
Cast tuples to Object when necessary to avoid LLVM IR type mismatches (for cons stores and return values).
Fix memory leaks.
git-svn-id: http://svn.drobilla.net/resp/resp@369 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'src/c.cpp')
-rw-r--r-- | src/c.cpp | 37 |
1 files changed, 26 insertions, 11 deletions
@@ -43,18 +43,21 @@ struct CEngine : public Engine { CFunc startFn(CEnv& cenv, const string& name, const ATuple* args, const ATuple* type); void pushFnArgs(CEnv& cenv, const ATuple* prot, const ATuple* type, CFunc f); - void finishFn(CEnv& cenv, CFunc f, CVal ret); + void finishFn(CEnv& cenv, CFunc f, CVal ret, const AST* retT); void eraseFn(CEnv& cenv, CFunc f); - CVal compileCall(CEnv& cenv, CFunc f, const ATuple* funcT, const vector<CVal>& args); - CVal compileCons(CEnv& cenv, const ATuple* type, CVal rtti, const vector<CVal>& fields); - CVal compileDot(CEnv& cenv, CVal tup, int32_t index); - CVal compileGlobalSet(CEnv& cenv, const string& s, CVal v, const AST* t); - CVal compileGlobalGet(CEnv& cenv, const string& s, CVal v); - CVal compileIf(CEnv& cenv, const AST* cond, const AST* then, const AST* aelse); - CVal compileLiteral(CEnv& cenv, const AST* lit); - CVal compilePrimitive(CEnv& cenv, const ATuple* prim); - CVal compileString(CEnv& cenv, const char* str); + CVal compileCall(CEnv& cenv, CFunc f, const ATuple* funcT, const vector<CVal>& args); + CVal compileCons(CEnv& cenv, const ATuple* type, CVal rtti, const vector<CVal>& fields); + CVal compileDot(CEnv& cenv, CVal tup, int32_t index); + CVal compileGlobalSet(CEnv& cenv, const string& s, CVal v, const AST* t); + CVal compileGlobalGet(CEnv& cenv, const string& s, CVal v); + CVal compileIf(CEnv& cenv, const AST* cond, const AST* then, const AST* aelse); + CVal compileLiteral(CEnv& cenv, const AST* lit); + CVal compilePrimitive(CEnv& cenv, const ATuple* prim); + CVal compileString(CEnv& cenv, const char* str); + CType compileType(CEnv& cenv, const char* name, const AST* exp); + + CType objectType(CEnv& cenv); void writeModule(CEnv& cenv, std::ostream& os); @@ -159,6 +162,18 @@ CEngine::compileString(CEnv& cenv, const char* str) return new Value(string("\"") + str + "\""); } +CType +CEngine::compileType(CEnv& cenv, const char* name, const AST* expr) +{ + return NULL; +} + +CType +CEngine::objectType(CEnv& cenv) +{ + return new string("Object"); +} + CFunc CEngine::startFn(CEnv& cenv, const std::string& name, const ATuple* args, const ATuple* type) { @@ -212,7 +227,7 @@ CEngine::pushFnArgs(CEnv& cenv, const ATuple* prot, const ATuple* type, CFunc f) } void -CEngine::finishFn(CEnv& cenv, CFunc f, CVal ret) +CEngine::finishFn(CEnv& cenv, CFunc f, CVal ret, const AST* retT) { out += "return " + *(Value*)ret + ";\n}\n\n"; } |