-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruntime.h
More file actions
39 lines (33 loc) · 1.32 KB
/
Copy pathruntime.h
File metadata and controls
39 lines (33 loc) · 1.32 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
/*
*AUTHOR: Samed Kahyaoglu
*GITHUB: urtuba
*/
#ifndef RUNTIME_H_
#define RUNTIME_H_
#define LANGUAGE_DEPTH 5 //defines how many functions can be worked as nested
#include<string>
struct Statement
{
std::string type;
std::string arg1;
std::string arg2;
};
typedef unsigned AddressValue;
typedef int ScalarValue;
template<typename T>
struct Stack
{
T variables[LANGUAGE_DEPTH][5];
//LANGUAGE_DEPTH is capacity of working with nested functions.
int degree;
//degree,for main degree=0, main calls a function: 1, the function calls another:2
//each function works with different level of data, until return statement allows it to copy its value to parent function.
Statement* const top; // makes possible to return first statement whether where you are at.
AddressValue degreeCalls[LANGUAGE_DEPTH];
//holds addresses of functions, there can be nested functions so they uses their data
//I had to store addresses of their caller, program can be compiled for more complex codes via changing LANGUAGE_DEPTH.
AddressValue currentAddress;
bool isDone;
};
AddressValue executeStatement( const Statement & statement, const AddressValue currentAddress, ScalarValue variables [5], Stack<ScalarValue> & callStack, const AddressValue addressOfCalleeIfCall, bool & isDone );
#endif /* RUNTIME_H_ */