#ifndef COMPILER_TYPES_H #define COMPILER_TYPES_H #include #include #include #include // Typy operacji enum class OpType { ASSIGN, // a = 5 ADD, // a = b + c SUB, // a = b - c MUL, // a = b * c DIV, // a = b / c MOD, // a = b % c EQ, // a == b PRINT, // print(int) PRINT_STRING, // print(string) - NOWE JMP_FALSE, // if (false) skocz... ARRAY_DECLARE, // int t[10]; ARRAY_SET, // t[0] = 5; ARRAY_GET, // x = t[0]; - to obsłużymy w ASSIGN, ale warto mieć typ JMP, // else / pętla LOGIC_AND, // && LOGIC_OR, // || LABEL, // miejsce skoku CALL, // wywołanie funkcji RETURN, // return x MSGBOX, // msg box NOP // pusta instrukcja }; // Pojedynczy rozkaz struct Instruction { OpType type; std::string arg1; std::string arg2; std::string arg3; }; // Definicja funkcji struct Function { std::string name; std::string returnType; std::vector args; std::vector instructions; }; // GŁÓWNY STAN KOMPILATORA struct CompilerState { // Mapa funkcji std::map functions; // Zmienne globalne std::map globals; // Zarządzanie stosem std::map stackMap; int stackOffset = 0; // Stan parsera Function* currentFunction = nullptr; int labelCounter = 0; // Stosy bloków std::stack loopStack; std::stack blockStack; std::vector> stringLiterals; // Licznik do generowania nazw str_0, str_1... int stringCounter = 0; std::map varTypes; }; #endif