Fixed bugs with paramaters being passed to the wrong callsite

This commit is contained in:
Samuel D. Crow
2022-08-01 15:35:43 -05:00
parent 34f1abeda6
commit 820fb864bd
9 changed files with 64 additions and 29 deletions

View File

@@ -6,9 +6,11 @@ CFLAGS += -std=c++11
#CFLAGS += -Os
LFLAGS :=
.PHONY: all
all: binaries
binaries: bin_main
.PHONY: binaries
binaries: main
SRC := ../output/
@@ -16,7 +18,7 @@ OUTPUT_DEPS := $(SRC)consts.h $(SRC)heap.h $(SRC)functions.h runtime.h $(SRC)out
MAIN_OBJ_DEPS := output.o main.o
bin_main: $(MAIN_OBJ_DEPS)
main: $(MAIN_OBJ_DEPS)
$(CC) -o main $(MAIN_OBJ_DEPS)
main.o: $(OUTPUT_DEPS)

View File

@@ -11,14 +11,14 @@ subroutine *callStack=nullptr;
subroutine::subroutine(unsigned int r)
{
this->ret=r;
this->called=callStack;
this->callStackNode=callStack;
}
unsigned int subroutine::close()
{
if (callStack==nullptr) return STACK_UNDERFLOW_ERROR;
unsigned int r=callStack->ret;
subroutine *l=callStack->called;
subroutine *l=callStack->callStackNode;
delete callStack;
callStack=l;
return r;

View File

@@ -1,5 +1,5 @@
/*
** Practice runtime header for Yab2Cpp
** Runtime header for Yab2Cpp
**
** by Samuel D. Crow
*/
@@ -10,6 +10,9 @@
#include <cstdio>
using namespace std;
/*
This enum contains all of the error states used at runtime.
*/
enum STATES:unsigned int
{
EXIT,
@@ -18,9 +21,12 @@ enum STATES:unsigned int
START
};
/*
This class wraps the function class and is inherited by every subroutine.
*/
class subroutine
{
subroutine *called;
subroutine *callStackNode;
unsigned int ret;
public: