-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodeGen.h
More file actions
27 lines (21 loc) · 713 Bytes
/
CodeGen.h
File metadata and controls
27 lines (21 loc) · 713 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <string>
#include "CPPAST.h"
std::string generateCode(std::list < CPPFunction* > functions) {
std::string str = "//Autogenerated C++ Source Code DO NOT EDIT\n";
str += "#include <Arduino.h>\n";
str += "#include <runtime.h>\n";
//str += "#include \"arduino_bindings.h\"\n";
str += "\n";
for(CPPFunction* f : functions) {
str += f->genCode();
}
str += "void setup() {\n";
str += "\tSerial.begin(9600);\n";
str += "\twhile(!Serial);\n";
str += "\ttopEnv = new Environment();\n";
str += "\tSerial.println(unwrapReal(_main_(makeRecord({}, topEnv), topEnv)));\n";
str += "}\n";
str += "void loop() {\n";
str += "}\n";
return str;
}