fixes scope bug in test code, typo in runtime and makefiles

This commit is contained in:
Samuel D. Crow
2021-03-25 14:38:17 -05:00
parent 48505d1ef8
commit fd89b1a054
4 changed files with 22 additions and 9 deletions

View File

@@ -1,6 +1,8 @@
CC := g++ CC := g++
CFLAGS := -Wall CFLAGS := -Wall
CFLAGS += -std=c++11 CFLAGS += -std=c++11
CFLAGS += -fno-rtti
CFLAGS += -fno-exceptions
CFLAGS += -Os CFLAGS += -Os
LFLAGS := LFLAGS :=

View File

@@ -1,6 +1,8 @@
CC := g++ CC := g++
CFLAGS := -Wall CFLAGS := -Wall
CFLAGS += -std=c++11 CFLAGS += -std=c++11
CFLAGS += -fno-rtti
CFLAGS += -fno-exceptions
CFLAGS += -Os CFLAGS += -Os
LFLAGS := LFLAGS :=
@@ -18,10 +20,10 @@ bin_main: $(MAIN_OBJ_DEPS)
$(CC) -o main $(MAIN_OBJ_DEPS) $(CC) -o main $(MAIN_OBJ_DEPS)
main.o: $(OUTPUT_DEPS) main.o: $(OUTPUT_DEPS)
$(CC) -o main.o -c main.cpp $(CC) $(CFLAGS) -o main.o -c main.cpp
output.o: $(OUTPUT_DEPS) output.o: $(OUTPUT_DEPS)
$(CC) -I$(SRC) -o output.o -c $(SRC)output.cpp $(CC) $(CFLAGS) -I$(SRC) -o output.o -c $(SRC)output.cpp
.PHONY: clean .PHONY: clean
clean: clean:

View File

@@ -4,8 +4,9 @@
** by Samuel D. Crow ** by Samuel D. Crow
*/ */
#ifndef YAB_RUNTIME #ifndef YAB_RUNTIME
#define YAB_RUTTIME #define YAB_RUNTIME
#include <string>
#include <cstdio> #include <cstdio>
using namespace std; using namespace std;

View File

@@ -151,7 +151,7 @@ int main(int argc, char *argv[])
helpText(argv[0]); helpText(argv[0]);
break; break;
} }
cout << "vamanos!" <<endl; cout << "program exiting" <<endl;
return 0; return 0;
} }
@@ -262,17 +262,25 @@ void shutDown()
{ {
output_cpp << "default:\nstate=UNDEFINED_STATE_ERROR;\n" output_cpp << "default:\nstate=UNDEFINED_STATE_ERROR;\n"
<< "break;\n}\n}\nreturn state;\n}"<< endl; << "break;\n}\n}\nreturn state;\n}"<< endl;
funcs_h.flush();
consts_h.flush();
heap_h.flush();
} }
globals.clear();
locals.clear();
statics.clear();
} }
shared_ptr<string>name;
shared_ptr<variableType>v;
shared_ptr<printSegment>print;
void testInt() void testInt()
{ {
string name="v"; name=shared_ptr<string>(new string("v"));
shared_ptr<variableType>v= v=variableType::getOrCreateVar(*name, T_INTVAR);
variableType::getOrCreateVar(name, T_INTVAR);
v->assignment(shared_ptr<expression>(new expression( v->assignment(shared_ptr<expression>(new expression(
shared_ptr<operands>(new constOp("2", T_INT))))); shared_ptr<operands>(new constOp("2", T_INT)))));
shared_ptr<printSegment>print=shared_ptr<printSegment>( print=shared_ptr<printSegment>(
new printSegment(shared_ptr<expression>(new expression(v)))); new printSegment(shared_ptr<expression>(new expression(v))));
print->generate(); print->generate();
label::generateEnd(); label::generateEnd();