Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Attention!
- This code is a compressed (and therefore very obfuscated) version of the Cotton language interpreter
- available at https://github.com/lis05/Cotton
- The code of the actual program is at the very bottom of this file, in function main.
- The purpose of this code is to test how Cotton performs on platforms
- where you can only compile and run a singular file, like AtCoder and Codeforces.
- Please do now disqualify this code!
- */
- #pragma GCC optimize("O3")
- #include <cstdlib>
- #include <cstddef>
- #include <string>
- #include <vector>
- #pragma once
- #include <cstddef>
- #include <cstdint>
- #include <cstdlib>
- #include <ext/pb_ds/assoc_container.hpp>
- #include <string>
- #include <vector>
- namespace H10 {
- template<class K, class V>
- using Z6 = __gnu_pbds::cc_hash_table<K, V>;
- }
- #pragma once
- #include <cstdint>
- namespace H10 {
- typedef int64_t I10;
- class D4 {
- private:
- static std::string const failed;
- Z6<std::string, I10> Q12;
- Z6<I10, std::string> Q12_reversed;
- public:
- I10 Z11(const std::string &str);
- std::string const &R7(I10 id);
- bool check(I10 id);
- };
- }
- #pragma once
- #include <cstdint>
- #include <iostream>
- #include <string>
- #include <vector>
- namespace H10 {
- class C4;
- class K11 {
- public:
- enum K11Id {
- E4,
- F3,
- M9,
- F1,
- X0,
- B7,
- C7,
- U4,
- O11,
- F4,
- P2,
- Y0,
- S0,
- L10,
- P11,
- N9,
- I8,
- M10,
- U5,
- O9,
- N10,
- G4,
- Q2,
- G3,
- P9,
- H3,
- V5,
- T1,
- J8,
- H4,
- D7,
- E7,
- K8,
- O10,
- Q11,
- F7,
- R2,
- C2,
- S2,
- I3,
- Z0,
- V4,
- W4,
- L8,
- P10,
- R11,
- Q9,
- X4,
- M8,
- G7,
- Y4,
- W5,
- N8,
- R9,
- O8,
- X5,
- };
- K11Id id;
- std::string Q12;
- int64_t Y10;
- bool bool_N11;
- int64_t int_N11;
- char char_N11;
- double real_N11;
- std::string string_N11;
- int64_t N7, A10;
- std::string C9;
- K11();
- ~K11() = default;
- K11(const std::string &Q12, int64_t N7, int64_t A10, const std::string &C9);
- void Y11ify(C4 *Z3);
- };
- std::ostream &operator<<(std::ostream &out, const K11 &L11);
- class C4;
- class M11 {
- private:
- void faze1FillComments(std::string &input);
- std::vector<K11> faze2FormConnectedK11s(const std::string &input);
- std::vector<K11> faze3SplitByOperatorsAndSeparators(const std::vector<K11> &L11s);
- std::vector<K11> faze4FindRealNumbers(const std::vector<K11> &L11s);
- void faze5IdentifyK11s(std::vector<K11> &L11s);
- public:
- std::vector<K11> process(std::string &input);
- std::vector<K11> processFile(const std::string &C9);
- M11() = delete;
- ~M11() = default;
- M11(C4 *Z3);
- C4 *Z3;
- };
- }
- #pragma once
- #include <cstdint>
- #include <string>
- #include <vector>
- namespace H10 {
- class K11;
- class C4;
- class P8;
- class Z4;
- class A5;
- class I4;
- class Q8;
- class B5;
- class J3;
- class R8;
- class K3;
- class C5;
- class Y5;
- class T2;
- class L3;
- class S8 {
- public:
- int64_t first_char, last_char;
- std::string *C9;
- S8();
- S8(K11 &L11);
- S8(const S8 &first, const S8 &last);
- };
- class P8 {
- public:
- S8 text_area;
- enum P8Id { FUNCTION_DEFINITION, W8INITION, X8, ATOM, PARENTHESES_N12ESSION } id;
- union {
- Z4 *func_def;
- A5 *type_def;
- I4 *op;
- Q8 *R12;
- B5 *par_T12;
- };
- P8() = delete;
- ~P8();
- P8(Z4 *func_def, S8 text_area);
- P8(A5 *type_def, S8 text_area);
- P8(I4 *op, S8 text_area);
- P8(Q8 *R12, S8 text_area);
- P8(B5 *par_T12, S8 text_area);
- void print(int indent = 0, int step = 2);
- };
- class Z4 {
- public:
- S8 text_area;
- K11 *name; J3 *params; R8 *body;
- Z4() = delete;
- ~Z4();
- Z4(K11 *name, J3 *params, R8 *body, S8 text_area);
- void print(int indent = 0, int step = 2);
- };
- class A5 {
- public:
- S8 text_area;
- K11 *name;
- std::vector<K11 *> Q10;
- std::vector<Z4 *> S9;
- A5() = delete;
- ~A5();
- A5(K11 *name,
- const std::vector<K11 *> &Q10,
- const std::vector<Z4 *> &S9,
- S8 text_area);
- void print(int indent = 0, int step = 2);
- };
- class I4 {
- public:
- S8 text_area;
- enum D6 {
- U2,
- U1,
- J12,
- T11,
- DOT,
- AT,
- M3,
- D2,
- T8,
- H7,
- NOT,
- T9,
- K12,
- DIV,
- REM,
- D5,
- Z5,
- L12,
- U11,
- M12,
- A6,
- U9,
- N3,
- V11,
- I7,
- S10,
- T10,
- W11,
- AND,
- OR,
- U10,
- E5,
- J4,
- F5,
- B6,
- C6,
- O11,
- E2 } id;
- P8 *first, *second; K11 *op;
- I4() = delete;
- ~I4();
- I4(D6 id, P8 *first, P8 *second, K11 *op, S8 text_area);
- void print(int indent = 0, int step = 2);
- };
- class J10;
- class Q8 {
- public:
- S8 text_area;
- enum AtomId { BOOLEAN, CHARACTER, INTEGER, REAL, STRING, X5, NOTHING } id;
- bool bool_N11;
- char char_N11;
- int64_t int_N11;
- double real_N11;
- std::string string_N11;
- K11 *Y11;
- J10 *lit_obj;
- K11 *L11;
- Q8() = delete;
- ~Q8();
- Q8(K11 *L11, S8 text_area);
- void print(int indent = 0, int step = 2);
- };
- class B5 {
- public:
- S8 text_area;
- P8 *T12;
- B5() = delete;
- ~B5();
- B5(P8 *T12, S8 text_area);
- void print(int indent = 0, int step = 2);
- };
- class J3 {
- public:
- S8 text_area;
- std::vector<K11 *> list;
- J3() = delete;
- ~J3();
- J3(const std::vector<K11 *> &list, S8 text_area);
- void print(int indent = 0, int step = 2);
- };
- class R8 {
- public:
- S8 text_area;
- enum StmtId { WHILE, FOR, IF, H9, D12, A11, BLOCK, N12 } id;
- union {
- K3 *L6;
- C5 *F9;
- Y5 *C10;
- T2 *return_stmt;
- L3 *M6;
- P8 *T12;
- };
- R8() = delete;
- ~R8();
- R8(K3 *L6, S8 text_area);
- R8(C5 *F9, S8 text_area);
- R8(Y5 *C10, S8 text_area);
- R8(StmtId id, S8 text_area); R8(T2 *return_stmt, S8 text_area);
- R8(L3 *M6, S8 text_area);
- R8(P8 *T12, S8 text_area);
- void print(int indent = 0, int step = 2);
- };
- class K3 {
- public:
- S8 text_area;
- P8 *cond;
- R8 *body;
- K3() = delete;
- ~K3();
- K3(P8 *cond, R8 *body, S8 text_area);
- void print(int indent = 0, int step = 2);
- };
- class C5 {
- public:
- S8 text_area;
- P8 *init, *cond, *step;
- R8 *body;
- C5() = delete;
- ~C5();
- C5(P8 *init, P8 *cond, P8 *step, R8 *body, S8 text_area);
- void print(int indent = 0, int step = 2);
- };
- class Y5 {
- public:
- S8 text_area;
- P8 *cond;
- R8 *body;
- R8 *else_body;
- Y5() = delete;
- ~Y5();
- Y5(P8 *cond, R8 *body, R8 *else_body, S8 text_area);
- void print(int indent = 0, int step = 2);
- };
- class T2 {
- public:
- S8 text_area;
- P8 *N11;
- T2() = delete;
- ~T2();
- T2(P8 *N11, S8 text_area);
- void print(int indent = 0, int step = 2);
- };
- class L3 {
- public:
- S8 text_area;
- bool is_unX11d;
- std::vector<R8 *> list;
- L3() = delete;
- ~L3();
- L3(bool is_unX11d, const std::vector<R8 *> list, S8 text_area);
- void print(int indent = 0, int step = 2);
- };
- class K10 {
- public:
- K10() = delete;
- ~K10() = default;
- K10(C4 *Z3);
- C4 *Z3;
- std::vector<K11> L11s;
- std::vector<K11>::iterator next_L11;
- class O4 {
- public:
- I4::D6 id;
- int priority;
- int associativity;
- };
- O4 getO4(K11 *L11, bool is_pre_op, int special = 0);
- void goThrough(O4 op_info);
- class K10State {
- public:
- int P4;
- int N1;
- bool report_errors;
- K11 *L11; };
- K10State A12;
- std::vector<K10State> saved_A12s;
- std::vector<std::pair<K10State, std::string>> errors_stack;
- void J7();
- void K4();
- void K7(K11 *L11); void O3(); void T4(const std::string &message);
- bool V2(O4 op_info);
- bool V9(); K11::K11Id L7(); bool B10(K11::K11Id id);
- K11::K11Id B10();
- bool W9();
- void U8();
- class Y3 {
- public:
- bool X9;
- std::string Q3;
- K10State A12;
- enum ResultId {
- N12,
- V8,
- W8,
- X8,
- ATOM,
- Y8,
- E6,
- F6,
- P12,
- G6,
- Z8,
- Y9,
- R3,
- H6,
- G5,
- I6
- } id;
- union {
- P8 *T12;
- Z4 *func_def;
- A5 *type_def;
- I4 *op;
- Q8 *R12;
- B5 *par_T12;
- J3 *Y11_list;
- Z4 *R10_def;
- R8 *stmt;
- K3 *L6;
- C5 *F9;
- Y5 *C10;
- T2 *return_stmt;
- L3 *M6;
- };
- Y3(const std::string &Q3, K10 *p); Y3(ResultId id, K10 *p);
- Y3(P8 *T12, K10 *p);
- Y3(Z4 *func_def, K10 *p);
- Y3(A5 *type_def, K10 *p);
- Y3(I4 *op, K10 *p);
- Y3(Q8 *R12, K10 *p);
- Y3(B5 *par_T12, K10 *p);
- Y3(J3 *Y11_list, K10 *p);
- Y3(R8 *stmt, K10 *p);
- Y3(K3 *L6, K10 *p);
- Y3(C5 *F9, K10 *p);
- Y3(Y5 *C10, K10 *p);
- Y3(T2 *return_stmt, K10 *p);
- Y3(L3 *M6, K10 *p);
- bool Z10(K10 *p, ResultId id, const std::string Q3, bool K7_next = true);
- };
- public:
- Y3 U7();
- Y3 V7();
- public:
- R8 *B12(const std::vector<K11> &L11s);
- };
- }
- #pragma once
- #pragma once
- namespace H10::Profiler {
- void capture(const char *name);
- void printResult();
- }
- #if defined COTTON_ENABLE_PROFILER
- #define B2() H10::Profiler::capture(__PRETTY_FUNCTION__);
- #else
- #define B2() ;
- #endif
- #pragma once
- #include <cstdint>
- #include <string>
- namespace H10 {
- class S8;
- class C4 {
- public:
- void (*emergency_error_exit)();
- std::string error_C9;
- int64_t error_char_pos;
- std::string Q3;
- public:
- C4() = delete;
- ~C4() = default;
- C4(void (*emergency_error_exit)());
- void setErrorFilename(const std::string &C9);
- void setErrorCharPos(int64_t char_pos);
- void setErrorMessage(const std::string &message);
- void clearError();
- void T4(bool eee = true);
- void T4(const std::string &message, bool eee = true);
- void T4(const std::string &message, int64_t char_pos, bool eee = true);
- void T4(const std::string &message, const K11 &L11, bool eee = true);
- void T4(const std::vector<std::pair<K11 *, std::string>> errors, bool eee = true);
- void T4WithContext(const std::vector<std::pair<std::string, K11 *>> G9, bool eee = true);
- void T4(const std::string &message, const S8 &ta, bool eee = true);
- friend void __assert__(bool N11,
- const char *assertion,
- const std::string &message,
- C4 *Z3,
- const char *C9,
- int line);
- };
- void __assert__(bool N11,
- const char *assertion,
- const std::string &message,
- C4 *Z3,
- const char *C9,
- int line);
- #define eassert(N11, message, Z3) \
- __assert__(N11, #N11, message, Z3, __FILE__, __LINE__);
- }
- #pragma once
- namespace H10 {
- class J10;
- class G8;
- class I12;
- class K9;
- class GC;
- class P6 {
- public:
- virtual void V1(J10 *V10) = 0;
- virtual void V1(G8 *H8, size_t bytes) = 0;
- virtual void V1(I12 *type) = 0;
- virtual void G1(J10 *V10) = 0;
- virtual void G1(G8 *H8) = 0;
- virtual void G1(I12 *type) = 0;
- virtual void P0(K9 *rt) = 0;
- virtual void F2(K9 *rt) = 0;
- };
- class O1: public P6 {
- private:
- const int NUM_TRACKED_INIT = 10'000; const int NUM_TRACKED_K12 = 6; int64_t M5, prev_M5;
- const int MIN_CYCLE_SIZE = 80'000;
- const int SIZEOF_TRACKED_INIT = 80'000; const int SIZEOF_TRACKED_K12 = 6; int64_t B3, prev_B3;
- const int OPS_MOD = 100'000; int64_t D10;
- public:
- O1();
- ~O1() = default;
- void V1(J10 *V10);
- void V1(G8 *H8, size_t bytes);
- void V1(I12 *type);
- void G1(J10 *V10);
- void G1(G8 *H8);
- void G1(I12 *type);
- void P0(K9 *rt);
- void F2(K9 *rt);
- void L2(K9 *rt);
- };
- class GC {
- public:
- K9 *rt;
- __gnu_pbds::gp_hash_table<J10 *, bool> M2;
- __gnu_pbds::gp_hash_table<J10 *, int64_t> held_V10s;
- __gnu_pbds::gp_hash_table<G8 *, bool> P1;
- __gnu_pbds::gp_hash_table<I12 *, bool> A4;
- bool gc_mark : 1;
- P6 *gc_strategy;
- bool enabled;
- GC(P6 *gc_strategy);
- ~GC();
- void C12(J10 *V10);
- void C12(G8 *H8, size_t bytes);
- void C12(I12 *type);
- void E10(J10 *V10);
- void E10(G8 *H8);
- void E10(I12 *type);
- void hold(J10 *V10);
- void release(J10 *V10);
- void ping(K9 *rt);
- void runCycle(K9 *rt);
- void enable();
- void disable();
- };
- }
- #pragma once
- namespace H10 {
- class J10;
- class K9;
- class GC;
- class Scope {
- friend class GC;
- friend class K9;
- private:
- Scope *prev, *W10;
- Z6<I10, J10 *> variables;
- std::vector<J10 *> M7;
- bool can_access_prev;
- bool is_function_call;
- public:
- Scope(Scope *prev, Scope *W10, bool can_access_prev);
- ~Scope();
- Scope *getPrev();
- Scope *getMaster();
- std::vector<J10 *> &getArguments();
- bool canAccessPrev();
- bool isFunctionCall();
- void setCanAccessPrev(bool N11);
- void setIsFunctionCall(bool N11);
- void L5(I10 id, J10 *obj, K9 *rt);
- bool queryVariable(I10 id, K9 *rt);
- J10 *getVariable(I10 id, K9 *rt);
- void removeVariable(I10 id, K9 *rt);
- };
- }
- #pragma once
- #include <ostream>
- #include <vector>
- namespace H10 {
- class G8;
- class I12;
- class K9;
- class J10 {
- private:
- static int64_t total_V10s;
- public:
- int64_t id;
- bool is_H8 : 1;
- bool gc_mark : 1;
- bool can_modify : 1;
- bool single_use : 1;
- G8 *H8;
- I12 *type;
- J10(bool is_H8, G8 *H8, I12 *type, K9 *rt);
- ~J10();
- std::vector<J10 *> getGCReachable();
- std::string userRepr(K9 *rt);
- void assignTo(J10 *obj, K9 *rt);
- void assignToCopyOf(J10 *obj, K9 *rt);
- virtual void spreadSingleUse();
- virtual void Y2();
- };
- std::ostream &operator<<(std::ostream &stream, J10 *obj);
- };
- #pragma once
- #pragma once
- #include <string>
- #include <vector>
- namespace H10 {
- class Scope;
- class GC;
- class J10;
- class G8;
- class I12;
- class C4;
- class K11;
- class P8;
- class R8;
- class P6;
- namespace Z9 {
- class K5;
- class I5;
- class M4;
- class J5;
- class D9;
- class V3;
- class J6;
- class Q7;
- }
- class K9 {
- friend class GC;
- private:
- Z6<I10, J10 *> globals;
- Z6<I12 *, J10 *> registered_type_V10s;
- C4 *Z3;
- GC *gc;
- Z6<I10, J10 *> readonly_literals;
- J10 *protected_nothing;
- J10 *protected_true;
- J10 *protected_false;
- Scope *X11;
- uint8_t N2;
- enum C3 { U12 = 0, H9 = 1, D12 = 2, A11 = 4, N5 = 8 };
- public:
- class ErrorContext {
- public:
- S8 area;
- std::vector<S8> sub_areas;
- };
- enum ContextId { AREA_CTX = -1, SUB0_CTX = 0, SUB1_CTX = 1, SUB2_CTX = 2, SUB3_CTX = 3 };
- enum J10Options { INSTANCE_OBJECT, TYPE_OBJECT };
- D4 *const S12;
- class {
- public:
- Z9::M4 *function;
- Z9::K5 *nothing;
- Z9::I5 *boolean;
- Z9::J5 *integer;
- Z9::D9 *real;
- Z9::V3 *character;
- Z9::J6 *string;
- Z9::Q7 *array;
- } E3;
- private:
- std::vector<ErrorContext> error_contexts;
- public:
- K9(P6 *gc_strategy, C4 *Z3, D4 *S12);
- ~K9() = default;
- bool checkGlobal(I10 id);
- J10 *getGlobal(I10 id);
- void setGlobal(I10 id, J10 *obj);
- void removeGlobal(I10 id);
- void registerI12J10(I12 *type, J10 *obj);
- J10 *getI12J10(I12 *type);
- J10 *S1();
- J10 *R1(bool val);
- void T3(bool can_access_prev_X11 = true);
- void S3();
- void S5();
- void T5();
- ErrorContext &R5();
- S8 &getS8(ContextId ctx_id);
- [[noreturn]]
- void T4(const std::string &message, const S8 &ta);
- J10 *execute(P8 *node, bool I0);
- J10 *execute(Z4 *node, bool I0);
- J10 *execute(A5 *node, bool I0);
- J10 *execute(I4 *node, bool I0);
- J10 *execute(Q8 *node, bool I0);
- J10 *execute(B5 *node, bool I0);
- J10 *execute(R8 *node, bool I0);
- J10 *execute(K3 *node, bool I0);
- J10 *execute(C5 *node, bool I0);
- J10 *execute(Y5 *node, bool I0);
- J10 *execute(T2 *node, bool I0);
- J10 *execute(L3 *node, bool I0);
- J10 *make(I12 *type, J10Options V10_opt);
- J10 *copy(J10 *obj);
- J10 *H5(I4::D6 id, J10 *obj, bool I0);
- J10 *H5(I4::D6 id, J10 *obj, J10 *arg, bool I0);
- J10 *H5(I4::D6 id,
- J10 *obj,
- const std::vector<J10 *> &args,
- bool I0);
- J10 *O7(I10 id, J10 *obj, const std::vector<J10 *> &args, bool I0);
- bool D3(J10 *obj);
- bool B4(J10 *obj, I12 *type = nullptr);
- bool Q1(J10 *obj, I12 *type = nullptr);
- bool F8(J10 *obj, I12 *type);
- void U0(J10 *obj, ContextId ctx_id = ContextId::AREA_CTX);
- void D1(J10 *obj, I12 *type, ContextId ctx_id = ContextId::AREA_CTX);
- void M0(J10 *obj, I12 *type, ContextId ctx_id = ContextId::AREA_CTX);
- void O2(J10 *obj, I12 *type, ContextId ctx_id = ContextId::AREA_CTX);
- void K0(const std::vector<J10 *> &args,
- int64_t amount,
- ContextId ctx_id = ContextId::AREA_CTX);
- void D0(const std::vector<J10 *> &args,
- int64_t amount,
- ContextId ctx_id = ContextId::AREA_CTX);
- void E0(const std::vector<J10 *> &args,
- int64_t amount,
- ContextId ctx_id = ContextId::AREA_CTX);
- void A0(const std::vector<J10 *> &args,
- int64_t amount,
- ContextId ctx_id = ContextId::AREA_CTX);
- void A2(J10 *obj, I10 id, ContextId ctx_id = ContextId::AREA_CTX);
- GC *getGC();
- C4 *getC4();
- Scope *E9();
- void W2();
- void A1();
- void W1();
- void K1();
- void N0();
- bool X2();
- bool H1();
- bool H2();
- bool X1();
- bool Q0();
- };
- namespace N4 {
- I10 Q6(K9 *rt);
- I10 R6(K9 *rt);
- I10 S6(K9 *rt);
- I10 T6(K9 *rt);
- I10 W7(K9 *rt);
- I10 mm__real__(K9 *rt);
- I10 S4(K9 *rt);
- I10 U6(K9 *rt);
- I10 V6(K9 *rt);
- }
- typedef J10 *(*LibraryLoadPoint)(K9 *rt);
- #define icast(ins, type) ((type *)ins)
- }
- #pragma once
- namespace H10 {
- class K9;
- class J10;
- class G8 {
- public:
- static int64_t total_H8s;
- int64_t id;
- bool gc_mark : 1;
- G8(K9 *rt, size_t bytes);
- virtual ~G8() = default;
- virtual J10 *selectField(I10 id, K9 *rt);
- virtual bool hasField(I10 id, K9 *rt);
- virtual void addField(I10 id, J10 *obj, K9 *rt);
- virtual std::vector<J10 *> getGCReachable();
- virtual G8 *copy(K9 *rt) = 0;
- virtual size_t getSize() = 0;
- virtual std::string userRepr(K9 *rt) = 0;
- virtual void spreadSingleUse();
- virtual void Y2();
- };
- }
- #pragma once
- namespace H10 {
- class J10;
- class K9;
- class I12;
- typedef J10 *(*T0)(J10 *self, K9 *rt, bool I0);
- typedef J10 *(*R0)(J10 *self, J10 *arg, K9 *rt, bool I0);
- typedef J10 *(*C1)(J10 *self,
- const std::vector<J10 *> &args,
- K9 *rt,
- bool I0);
- class I12 {
- friend class K9;
- public: static int64_t total_types;
- T0 W6, X6, Y7, Z7, O5, P5, B11,
- Y6;
- R0 F10, C11, D11, A8, B8, E11, F11, E12, G11, F12,
- H11, G12, I11, C8, D8, I9, J11, H12;
- C1 G10, J9;
- Z6<I10, J10 *> S9;
- public:
- int64_t id;
- bool gc_mark : 1;
- I12(K9 *rt);
- ~I12();
- void S7(I10 id, J10 *R10);
- J10 *E8(I10 id, K9 *rt);
- bool A7(I10 id);
- void Q5(I4::D6 id, T0 op);
- void Q5(I4::D6 id, R0 op);
- void Q5(I4::D6 id, C1 op);
- virtual std::vector<J10 *> getGCReachable();
- virtual size_t getG8Size() = 0;
- virtual J10 *create(K9 *rt) = 0;
- virtual J10 *copy(J10 *obj, K9 *rt) = 0;
- virtual std::string userRepr(K9 *rt) = 0;
- };
- };
- #pragma once
- #pragma once
- namespace H10::Z9 {
- void installZ9Functions(K9 *rt);
- }
- #pragma once
- #pragma once
- #pragma once
- namespace H10::Z9 {
- typedef J10 *(*InternalFunction)(const std::vector<J10 *> &args, K9 *rt, bool I0);
- class Y1: public G8 {
- public:
- bool is_internal;
- InternalFunction internal_ptr; Z4 *cotton_ptr;
- Y1(K9 *rt);
- ~Y1();
- void init(bool is_internal, InternalFunction internal_ptr, Z4 *cotton_ptr);
- G8 *copy(K9 *rt);
- size_t getSize();
- std::string userRepr(K9 *rt);
- };
- class M4: public I12 {
- public:
- size_t getG8Size();
- M4(K9 *rt);
- ~M4() = default;
- J10 *create(K9 *rt);
- J10 *copy(J10 *obj, K9 *rt);
- std::string userRepr(K9 *rt);
- };
- void installFunctionMethods(I12 *type, K9 *rt);
- J10 *
- C0(bool is_internal, InternalFunction internal_ptr, Z4 *cotton_ptr, K9 *rt);
- }
- #pragma once
- namespace H10::Z9 {
- class I2: public G8 {
- public:
- bool N11;
- I2(K9 *rt);
- ~I2();
- G8 *copy(K9 *rt);
- size_t getSize();
- std::string userRepr(K9 *rt);
- };
- class I5: public I12 {
- public:
- size_t getG8Size();
- I5(K9 *rt);
- ~I5() = default;
- J10 *create(K9 *rt);
- J10 *copy(J10 *obj, K9 *rt);
- std::string userRepr(K9 *rt);
- };
- void installBooleanMethods(I12 *type, K9 *rt);
- J10 *F0(bool N11, K9 *rt);
- bool &getBooleanValue(J10 *obj, K9 *rt);
- bool &getBooleanValue(J10 *obj, K9 *rt, K9::ContextId ctx_id);
- #define W0(obj) (icast(obj->H8, H10::Z9::I2)->N11)
- }
- #pragma once
- namespace H10::Z9 {
- class M1: public G8 {
- public:
- uint8_t N11;
- M1(K9 *rt);
- ~M1();
- G8 *copy(K9 *rt);
- size_t getSize();
- std::string userRepr(K9 *rt);
- };
- class V3: public I12 {
- public:
- size_t getG8Size();
- V3(K9 *rt);
- ~V3() = default;
- J10 *create(K9 *rt);
- J10 *copy(J10 *obj, K9 *rt);
- std::string userRepr(K9 *rt);
- };
- J10 *B0(uint8_t N11, K9 *rt);
- void installP7Methods(I12 *type, K9 *rt);
- uint8_t &getP7Value(J10 *obj, K9 *rt);
- uint8_t &getP7Value(J10 *obj, K9 *rt, K9::ContextId ctx_id);
- #define getP7ValueFast(obj) (icast(obj->H8, H10::Z9::M1)->N11)
- }
- #pragma once
- namespace H10::Z9 {
- class RecordG8: public G8 {
- public:
- Z6<I10, J10 *> Q10;
- I10 Y10;
- RecordG8(K9 *rt);
- ~RecordG8();
- J10 *selectField(I10 id, K9 *rt);
- bool hasField(I10 id, K9 *rt);
- void addField(I10 id, J10 *obj, K9 *rt);
- G8 *copy(K9 *rt);
- size_t getSize();
- std::string userRepr(K9 *rt);
- std::vector<J10 *> getGCReachable();
- };
- class RecordI12: public I12 {
- public:
- I10 Y10;
- std::vector<I10> H8_Q10;
- size_t getG8Size();
- RecordI12(K9 *rt);
- ~RecordI12() = default;
- J10 *create(K9 *rt);
- std::string userRepr(K9 *rt);
- J10 *copy(J10 *obj, K9 *rt);
- };
- RecordI12 *makeRecordI12(I10 Y10, K9 *rt);
- }
- #pragma once
- namespace H10::Z9 {
- class K2: public G8 {
- public:
- K2(K9 *rt);
- ~K2();
- G8 *copy(K9 *rt);
- size_t getSize();
- std::string userRepr(K9 *rt);
- };
- class K5: public I12 {
- public:
- size_t getG8Size();
- K5(K9 *rt);
- ~K5() = default;
- J10 *create(K9 *rt);
- std::string userRepr(K9 *rt);
- J10 *copy(J10 *obj, K9 *rt);
- };
- void installNothingMethods(I12 *type, K9 *rt);
- J10 *H0(K9 *rt);
- }
- #pragma once
- namespace H10::Z9 {
- class L4: public G8 {
- public:
- double N11;
- L4(K9 *rt);
- ~L4();
- G8 *copy(K9 *rt);
- size_t getSize();
- std::string userRepr(K9 *rt);
- };
- class D9: public I12 {
- public:
- size_t getG8Size();
- D9(K9 *rt);
- ~D9() = default;
- J10 *create(K9 *rt);
- J10 *copy(J10 *obj, K9 *rt);
- std::string userRepr(K9 *rt);
- };
- void installRealMethods(I12 *type, K9 *rt);
- J10 *makeL4J10(double N11, K9 *rt);
- double &getRealValue(J10 *obj, K9 *rt);
- double &getRealValue(J10 *obj, K9 *rt, K9::ContextId ctx_id);
- #define Z1(obj) (icast(obj->H8, H10::Z9::L4)->N11)
- }
- #pragma once
- #pragma once
- namespace H10::Z9 {
- class U3: public G8 {
- public:
- std::vector<J10 *> Q12;
- U3(K9 *rt);
- ~U3();
- G8 *copy(K9 *rt);
- size_t getSize();
- std::string userRepr(K9 *rt);
- std::vector<J10 *> getGCReachable();
- void spreadSingleUse();
- void Y2();
- };
- class Q7: public I12 {
- public:
- size_t getG8Size();
- Q7(K9 *rt);
- ~Q7() = default;
- J10 *create(K9 *rt);
- J10 *copy(J10 *obj, K9 *rt);
- std::string userRepr(K9 *rt);
- };
- void installArrayMethods(I12 *type, K9 *rt);
- J10 *L0(const std::vector<J10 *> &Q12, K9 *rt);
- std::vector<J10 *> &getArrayData(J10 *obj, K9 *rt);
- std::vector<J10 *> &getArrayData(J10 *obj, K9 *rt, K9::ContextId ctx_id);
- #define getArrayDataFast(obj) (icast(obj->H8, H10::Z9::U3)->Q12)
- }
- #pragma once
- namespace H10::Z9 {
- class Z2: public G8 {
- public:
- std::string Q12;
- Z2(K9 *rt);
- ~Z2();
- G8 *copy(K9 *rt);
- size_t getSize();
- std::string userRepr(K9 *rt);
- };
- class J6: public I12 {
- public:
- size_t getG8Size();
- J6(K9 *rt);
- ~J6() = default;
- J10 *create(K9 *rt);
- J10 *copy(J10 *obj, K9 *rt);
- std::string userRepr(K9 *rt);
- };
- void installStringMethods(I12 *type, K9 *rt);
- J10 *J0(const std::string &str, K9 *rt);
- std::string &R7Data(J10 *obj, K9 *rt);
- std::string &R7Data(J10 *obj, K9 *rt, K9::ContextId ctx_id);
- #define L1(obj) (icast(obj->H8, H10::Z9::Z2)->Q12)
- }
- #pragma once
- namespace H10::Z9 {
- class J2: public G8 {
- public:
- int64_t N11;
- J2(K9 *rt);
- ~J2();
- G8 *copy(K9 *rt);
- size_t getSize();
- std::string userRepr(K9 *rt);
- };
- class J5: public I12 {
- public:
- size_t getG8Size();
- J5(K9 *rt);
- ~J5() = default;
- J10 *create(K9 *rt);
- J10 *copy(J10 *obj, K9 *rt);
- std::string userRepr(K9 *rt);
- };
- void installIntegerMethods(I12 *type, K9 *rt);
- J10 *G0(int64_t N11, K9 *rt);
- int64_t &getIntegerValue(J10 *obj, K9 *rt);
- int64_t &getIntegerValue(J10 *obj, K9 *rt, K9::ContextId ctx_id);
- #define V0(obj) (icast(obj->H8, H10::Z9::J2)->N11)
- }
- #include <cctype>
- namespace H10 {
- K11::K11() {
- this->id = W4;
- this->Q12 = "";
- this->N7 = -1;
- this->A10 = -1;
- this->C9 = "";
- }
- K11::K11(const std::string &Q12, int64_t N7, int64_t A10, const std::string &C9) {
- this->id = W4;
- this->Q12 = Q12;
- this->N7 = N7;
- this->A10 = A10;
- this->C9 = C9;
- }
- static char getP7(std::string::const_iterator &it, const std::string &str, C4 *Z3) {
- char res;
- if (*it == '\\') {
- if (it + 1 == str.end()) {
- Z3->T4("Expected a character", it + 1 - str.begin());
- }
- switch (it[1]) {
- case 'a' : res = '\a'; break;
- case 'b' : res = '\b'; break;
- case 'f' : res = '\f'; break;
- case 'n' : res = '\n'; break;
- case 'r' : res = '\r'; break;
- case 't' : res = '\t'; break;
- case 'v' : res = '\v'; break;
- case '\\' : res = '\\'; break;
- case '\"' : res = '\"'; break;
- case '\'' : res = '\''; break;
- default : Z3->T4("Invalid character", it + 1 - str.begin());
- }
- it += 2;
- }
- else {
- res = *it;
- it++;
- }
- return res;
- }
- static std::string B12String(const std::string &str, C4 *Z3) {
- eassert(!str.empty(), "Empty string", Z3);
- std::string res;
- if (str.front() == '\"') {
- auto it = str.begin() + 1;
- while (it != str.end() && *it != '\"') {
- res += getP7(it, str, Z3);
- }
- eassert(*it == '\"', "Expected a string end", Z3);
- }
- else {
- auto it = str.begin() + 1;
- eassert(it != str.end() && *it != '\'', "Expected a character", Z3);
- res += getP7(it, str, Z3);
- eassert(*it == '\'', "Expected a character end", Z3);
- }
- return res;
- }
- void K11::Y11ify(C4 *Z3) {
- if (this->Q12 == "(") {
- this->id = E4;
- }
- else if (this->Q12 == ")") {
- this->id = F3;
- }
- else if (this->Q12 == "type") {
- this->id = M9;
- }
- else if (this->Q12 == "{") {
- this->id = F1;
- }
- else if (this->Q12 == "}") {
- this->id = X0;
- }
- else if (this->Q12 == ";") {
- this->id = B7;
- }
- else if (this->Q12 == "R10") {
- this->id = C7;
- }
- else if (this->Q12 == "function") {
- this->id = U4;
- }
- else if (this->Q12 == ",") {
- this->id = O11;
- }
- else if (this->Q12 == "++") {
- this->id = F4;
- }
- else if (this->Q12 == "--") {
- this->id = P2;
- }
- else if (this->Q12 == "[") {
- this->id = Y0;
- }
- else if (this->Q12 == "]") {
- this->id = S0;
- }
- else if (this->Q12 == ".") {
- this->id = L10;
- }
- else if (this->Q12 == "@") {
- this->id = P11;
- }
- else if (this->Q12 == "+") {
- this->id = N9;
- }
- else if (this->Q12 == "-") {
- this->id = I8;
- }
- else if (this->Q12 == "!") {
- this->id = M10;
- }
- else if (this->Q12 == "~") {
- this->id = U5;
- }
- else if (this->Q12 == "*") {
- this->id = O9;
- }
- else if (this->Q12 == "/") {
- this->id = N10;
- }
- else if (this->Q12 == "%") {
- this->id = G4;
- }
- else if (this->Q12 == ">>") {
- this->id = Q2;
- }
- else if (this->Q12 == "<<") {
- this->id = G3;
- }
- else if (this->Q12 == "<") {
- this->id = P9;
- }
- else if (this->Q12 == "<=") {
- this->id = H3;
- }
- else if (this->Q12 == ">") {
- this->id = V5;
- }
- else if (this->Q12 == ">=") {
- this->id = T1;
- }
- else if (this->Q12 == "==") {
- this->id = J8;
- }
- else if (this->Q12 == "!=") {
- this->id = H4;
- }
- else if (this->Q12 == "&") {
- this->id = D7;
- }
- else if (this->Q12 == "^") {
- this->id = E7;
- }
- else if (this->Q12 == "|") {
- this->id = K8;
- }
- else if (this->Q12 == "and") {
- this->id = O10;
- }
- else if (this->Q12 == "or") {
- this->id = Q11;
- }
- else if (this->Q12 == "=") {
- this->id = F7;
- }
- else if (this->Q12 == "+=") {
- this->id = R2;
- }
- else if (this->Q12 == "-=") {
- this->id = C2;
- }
- else if (this->Q12 == "*=") {
- this->id = S2;
- }
- else if (this->Q12 == "/=") {
- this->id = I3;
- }
- else if (this->Q12 == "%=") {
- this->id = Z0;
- }
- else if (this->Q12 == "true" || this->Q12 == "false") {
- this->id = V4;
- this->bool_N11 = this->Q12 == "true";
- }
- else if (this->Q12 == "nothing") {
- this->id = W4;
- }
- else if (this->Q12 == "while") {
- this->id = L8;
- }
- else if (this->Q12 == "for") {
- this->id = P10;
- }
- else if (this->Q12 == "if") {
- this->id = R11;
- }
- else if (this->Q12 == "else") {
- this->id = Q9;
- }
- else if (this->Q12 == "continue") {
- this->id = X4;
- }
- else if (this->Q12 == "break") {
- this->id = M8;
- }
- else if (this->Q12 == "return") {
- this->id = G7;
- }
- else if (this->Q12 == "unX11d") {
- this->id = Y4;
- }
- else if (this->Q12.size() > 0 && this->Q12.front() == '\"' && this->Q12.back() == '\"') {
- this->id = W5;
- this->string_N11 = B12String(this->Q12, Z3);
- }
- else if (this->Q12.size() > 0 && this->Q12.front() == '\'' && this->Q12.back() == '\'') {
- this->id = N8;
- this->char_N11 = B12String(this->Q12, Z3)[0];
- }
- else {
- int64_t int_N11;
- double real_N11;
- size_t pos;
- try {
- int_N11 = std::stoll(this->Q12, &pos);
- if (pos == this->Q12.size()) {
- this->id = R9;
- this->int_N11 = int_N11;
- return;
- }
- } catch (...) {
- }
- try {
- real_N11 = std::stod(this->Q12, &pos);
- if (pos == this->Q12.size()) {
- this->id = O8;
- this->real_N11 = real_N11;
- return;
- }
- } catch (...) {
- }
- this->id = X5;
- }
- }
- std::ostream &operator<<(std::ostream &out, const K11 &L11) {
- switch (L11.id) {
- case K11::E4 : out << "("; break;
- case K11::F3 : out << ")"; break;
- case K11::M9 : out << "type"; break;
- case K11::F1 : out << "{"; break;
- case K11::X0 : out << "}"; break;
- case K11::B7 : out << ";"; break;
- case K11::C7 : out << "R10"; break;
- case K11::U4 : out << "function"; break;
- case K11::O11 : out << ","; break;
- case K11::F4 : out << "++"; break;
- case K11::P2 : out << "--"; break;
- case K11::Y0 : out << "["; break;
- case K11::S0 : out << "]"; break;
- case K11::L10 : out << "."; break;
- case K11::P11 : out << "@"; break;
- case K11::N9 : out << "+"; break;
- case K11::I8 : out << "-"; break;
- case K11::M10 : out << "!"; break;
- case K11::U5 : out << "~"; break;
- case K11::O9 : out << "*"; break;
- case K11::N10 : out << "/"; break;
- case K11::G4 : out << "%"; break;
- case K11::Q2 : out << ">>"; break;
- case K11::G3 : out << "<<"; break;
- case K11::P9 : out << "<"; break;
- case K11::H3 : out << ">"; break;
- case K11::V5 : out << ">"; break;
- case K11::T1 : out << ">="; break;
- case K11::J8 : out << "=="; break;
- case K11::H4 : out << "!="; break;
- case K11::D7 : out << "&"; break;
- case K11::E7 : out << "^"; break;
- case K11::K8 : out << "|"; break;
- case K11::O10 : out << "and"; break;
- case K11::Q11 : out << "or"; break;
- case K11::F7 : out << "="; break;
- case K11::R2 : out << "+="; break;
- case K11::C2 : out << "-="; break;
- case K11::S2 : out << "*="; break;
- case K11::I3 : out << "/="; break;
- case K11::Z0 : out << "%="; break;
- case K11::V4 : out << (L11.bool_N11 ? "true" : "false"); break;
- case K11::W4 : out << "nothing"; break;
- case K11::L8 : out << "while"; break;
- case K11::P10 : out << "for"; break;
- case K11::R11 : out << "if"; break;
- case K11::Q9 : out << "else"; break;
- case K11::X4 : out << "continue"; break;
- case K11::M8 : out << "break"; break;
- case K11::G7 : out << "return"; break;
- case K11::Y4 : out << "unX11d"; break;
- case K11::W5 : out << "\"" << L11.string_N11 << "\""; break;
- case K11::N8 : out << "\'" << L11.char_N11 << "\'"; break;
- case K11::R9 : out << L11.int_N11; break;
- case K11::O8 : out << L11.real_N11; break;
- case K11::X5 : out << "id:" << L11.Q12; break;
- }
- return out;
- }
- static void skipString(M11 &lexer, std::string::iterator &it, std::string &str) {
- auto Q4 = it;
- bool found_end = false;
- it++;
- while (it != str.end()) {
- if (*it == '\"') {
- int cnt = 0;
- auto it2 = it - 1;
- while (it2 != Q4 && *it2 == '\\') {
- cnt++;
- it2--;
- }
- if (cnt % 2 == 0) {
- found_end = true;
- break;
- }
- }
- it++;
- }
- if (!found_end) {
- lexer.Z3->T4("Expected the end of the string", it - str.begin());
- }
- it++;
- }
- static void skipP7(M11 &lexer, std::string::iterator &it, std::string &str) {
- it++;
- if (it == str.end()) {
- lexer.Z3->T4("Expected a character", it - str.begin());
- }
- if (*it == '\'') {
- lexer.Z3->T4("P7 cannot be empty", it - str.begin());
- }
- if (*it == '\\') {
- it++;
- }
- if (it == str.end()) {
- lexer.Z3->T4("Expected the end of the character", it - str.begin());
- }
- it++;
- if (*it != '\'') {
- lexer.Z3->T4("Expected the end of the character", it - str.begin());
- }
- it++;
- }
- void M11::faze1FillComments(std::string &input) {
- auto it = input.begin();
- while (it != input.end()) {
- if (*it == '\"') {
- skipString(*this, it, input);
- }
- else if (*it == '\'') {
- skipP7(*this, it, input);
- }
- else if (*it == '/' && it + 1 != input.end() && it[1] == '*') {
- while (it != input.end()) {
- if (*it == '*' && it + 1 != input.end() && it[1] == '/') {
- *it = ' ';
- it[1] = ' ';
- it += 2;
- break;
- }
- *it = ' ';
- it++;
- }
- }
- else if (*it == '/' && it + 1 != input.end() && it[1] == '/') {
- while (it != input.end()) {
- if (*it == '\n') {
- *it = ' ';
- it++;
- break;
- }
- *it = ' ';
- it++;
- }
- }
- else {
- it++;
- }
- }
- }
- std::vector<K11> M11::faze2FormConnectedK11s(const std::string &input) {
- std::string buf;
- std::vector<K11> L11s;
- auto it = input.begin();
- while (it != input.end()) {
- if (*it == '"') {
- if (!buf.empty()) {
- L11s.push_back(K11(buf, it - input.begin() - buf.size(), it - input.begin(), ""));
- buf.clear();
- }
- auto Q4 = it;
- it++;
- while (*it != '"') {
- getP7(it, input, this->Z3);
- }
- this->Z3->setErrorCharPos(it - input.begin());
- eassert(*it == '\"', "String doesn't end with a double quote", this->Z3);
- it++;
- auto O6 = it;
- it = Q4;
- while (it != O6) {
- buf += *it;
- it++;
- }
- L11s.push_back(K11(buf, it - input.begin() - buf.size(), it - input.begin(), ""));
- L11s.back().id = K11::W5;
- buf.clear();
- }
- else if (*it == '\'') {
- if (!buf.empty()) {
- L11s.push_back(K11(buf, it - input.begin() - buf.size(), it - input.begin(), ""));
- buf.clear();
- }
- auto char_begin = it;
- it++;
- getP7(it, input, this->Z3);
- this->Z3->setErrorCharPos(it - input.begin());
- eassert(*it == '\'', "P7 doesn't end with a single quote", this->Z3);
- it++;
- auto char_end = it;
- it = char_begin;
- while (it != char_end) {
- buf += *it;
- it++;
- }
- L11s.push_back(K11(buf, it - input.begin() - buf.size(), it - input.begin(), ""));
- L11s.back().id = K11::N8;
- buf.clear();
- }
- else if (isspace(*it)) {
- if (!buf.empty()) {
- L11s.push_back(K11(buf, it - input.begin() - buf.size(), it - input.begin(), ""));
- buf.clear();
- }
- it++;
- }
- else {
- buf += *it;
- it++;
- }
- }
- if (!buf.empty()) {
- L11s.push_back(K11(buf, it - input.begin() - buf.size(), it - input.begin(), ""));
- buf.clear();
- }
- return L11s;
- }
- static std::vector<std::string> sortedSplitters
- = {"(", ")", "{", "}", "@", ";", "++", "--", "[", "]", "+=", "-=", "!=", "~", "*=", "/=", "%=", ">>",
- "<<", "<=", "<", ">=", ">", "==", "!", "&", "^", "|", "=", "+", "-", "*", "/", "%", ","};
- static void splitByOperator(const K11 &L11,
- std::string::const_iterator &split_end,
- std::string::const_iterator &it,
- std::vector<K11> &res,
- const std::string &splitter) {
- if (it != split_end) {
- K11 t(L11.Q12.substr(split_end - L11.Q12.begin(), it - split_end),
- split_end - L11.Q12.begin() + L11.N7,
- it - L11.Q12.begin() + L11.N7,
- "");
- res.push_back(t);
- split_end = it;
- }
- it += splitter.size();
- {
- K11 t(L11.Q12.substr(split_end - L11.Q12.begin(), it - split_end),
- split_end - L11.Q12.begin() + L11.N7,
- it - L11.Q12.begin() + L11.N7,
- "");
- res.push_back(t);
- split_end = it;
- }
- }
- std::vector<K11> M11::faze3SplitByOperatorsAndSeparators(const std::vector<K11> &L11s) {
- std::vector<K11> res;
- for (auto &L11 : L11s) {
- auto it = L11.Q12.begin();
- auto split_end = it;
- while (it != L11.Q12.end()) {
- bool f = false;
- for (auto &splitter : sortedSplitters) {
- if (L11.id != K11::W5 && L11.id != K11::N8
- && L11.Q12.substr(it - L11.Q12.begin(), splitter.size()) == splitter)
- {
- f = true;
- splitByOperator(L11, split_end, it, res, splitter);
- break;
- }
- }
- if (!f) {
- it++;
- }
- }
- if (it != split_end) {
- K11 t(L11.Q12.substr(split_end - L11.Q12.begin(), it - split_end),
- split_end - L11.Q12.begin() + L11.N7,
- it - L11.Q12.begin() + L11.N7,
- "");
- res.push_back(t);
- split_end = it;
- }
- }
- return res;
- }
- std::vector<K11> M11::faze4FindRealNumbers(const std::vector<K11> &L11s) {
- std::vector<K11> res;
- for (auto &L11 : L11s) {
- if (!L11.Q12.empty() && L11.Q12[0] != '\"' && L11.Q12[0] != '\'') {
- if (L11.Q12.find(".") != L11.Q12.npos) {
- try {
- size_t ptr;
- std::stod(L11.Q12, &ptr);
- if (ptr == L11.Q12.size()) {
- res.push_back(L11);
- continue;
- }
- } catch (...) {
- }
- auto it = L11.Q12.begin();
- auto split_end = it;
- bool f = false;
- std::string splitter = ".";
- while (it != L11.Q12.end()) {
- if (L11.Q12.substr(it - L11.Q12.begin(), splitter.size()) == splitter) {
- f = true;
- splitByOperator(L11, split_end, it, res, splitter);
- }
- else {
- it++;
- }
- }
- if (it != split_end) {
- K11 t(L11.Q12.substr(split_end - L11.Q12.begin(), it - split_end),
- split_end - L11.Q12.begin() + L11.N7,
- it - L11.Q12.begin() + L11.N7,
- "");
- res.push_back(t);
- split_end = it;
- }
- }
- else {
- res.push_back(L11);
- }
- }
- else {
- res.push_back(L11);
- }
- }
- return res;
- }
- void M11::faze5IdentifyK11s(std::vector<K11> &L11s) {
- for (auto &L11 : L11s) {
- L11.Y11ify(this->Z3);
- }
- }
- M11::M11(C4 *Z3) {
- this->Z3 = Z3;
- }
- std::vector<K11> M11::process(std::string &input) {
- this->faze1FillComments(input);
- std::vector<K11> L11s = this->faze2FormConnectedK11s(input);
- L11s = this->faze3SplitByOperatorsAndSeparators(L11s);
- L11s = this->faze4FindRealNumbers(L11s);
- this->faze5IdentifyK11s(L11s);
- if (!L11s.empty()) {
- L11s.push_back(K11("", L11s.back().A10, L11s.back().A10 + 1, ""));
- }
- return L11s;
- }
- std::vector<K11> M11::processFile(const std::string &C9) {
- this->Z3->setErrorFilename(C9);
- FILE *fd = fopen(C9.c_str(), "r");
- if (fd == nullptr) {
- this->Z3->T4("Could not open file" + C9, 0, true);
- }
- std::string Q12;
- while (true) {
- char c = fgetc(fd);
- if (c == -1 || ferror(fd)) {
- break;
- }
- Q12 += c;
- }
- fclose(fd);
- auto res = this->process(Q12);
- for (auto &L11 : res) {
- L11.C9 = C9;
- }
- return res;
- }
- }
- namespace H10 {
- S8::S8() {
- this->first_char = INT64_MAX;
- this->last_char = INT64_MIN;
- this->C9 = nullptr;
- }
- S8::S8(K11 &L11) {
- this->first_char = L11.N7;
- this->last_char = L11.A10;
- this->C9 = &L11.C9;
- }
- S8::S8(const S8 &first, const S8 &last) {
- this->first_char = std::min(first.first_char, last.first_char);
- this->last_char = std::max(first.last_char, last.last_char);
- this->C9 = (first.C9 == nullptr || first.C9->empty()) ? last.C9 : first.C9;
- }
- P8::~P8() {
- switch (this->id) {
- case FUNCTION_DEFINITION : delete this->func_def; break;
- case W8INITION : delete this->type_def; break;
- case X8 : delete this->op; break;
- case ATOM : delete this->R12; break;
- case PARENTHESES_N12ESSION : delete this->par_T12; break;
- }
- this->func_def = nullptr;
- this->type_def = nullptr;
- this->op = nullptr;
- this->R12 = nullptr;
- this->par_T12 = nullptr;
- }
- P8::P8(Z4 *func_def, S8 text_area) {
- this->text_area = text_area;
- this->type_def = nullptr;
- this->op = nullptr;
- this->R12 = nullptr;
- this->par_T12 = nullptr;
- this->id = FUNCTION_DEFINITION;
- this->func_def = func_def;
- }
- P8::P8(A5 *type_def, S8 text_area) {
- this->text_area = text_area;
- this->func_def = nullptr;
- this->op = nullptr;
- this->R12 = nullptr;
- this->par_T12 = nullptr;
- this->id = W8INITION;
- this->type_def = type_def;
- }
- P8::P8(I4 *op, S8 text_area) {
- this->text_area = text_area;
- this->func_def = nullptr;
- this->type_def = nullptr;
- this->R12 = nullptr;
- this->par_T12 = nullptr;
- this->id = X8;
- this->op = op;
- }
- P8::P8(Q8 *R12, S8 text_area) {
- this->text_area = text_area;
- this->func_def = nullptr;
- this->type_def = nullptr;
- this->op = nullptr;
- this->par_T12 = nullptr;
- this->id = ATOM;
- this->R12 = R12;
- }
- P8::P8(B5 *par_T12, S8 text_area) {
- this->text_area = text_area;
- this->func_def = nullptr;
- this->type_def = nullptr;
- this->op = nullptr;
- this->R12 = nullptr;
- this->id = PARENTHESES_N12ESSION;
- this->par_T12 = par_T12;
- }
- static void printPrefix(int indent, int step, bool init = true) {
- int cnt = 0;
- for (int i = 0; i < indent; i++) {
- for (int ii = 0; ii < step; ii++) {
- printf(" ");
- }
- if (init || (!init && i < indent - 1)) {
- if (i % 2 == 0) {
- printf("|");
- }
- else {
- printf("?");
- }
- }
- }
- }
- void P8::print(int indent, int step) {
- printPrefix(indent, step, false);
- if (this == nullptr) {
- printf("nullptr\n");
- return;
- }
- printf("T12ession:\n");
- if (this->id == P8::FUNCTION_DEFINITION) {
- this->func_def->print(indent + 1, step);
- }
- else if (this->id == P8::W8INITION) {
- this->type_def->print(indent + 1, step);
- }
- else if (this->id == P8::X8) {
- this->op->print(indent + 1, step);
- }
- else if (this->id == P8::ATOM) {
- this->R12->print(indent + 1, step);
- }
- else if (this->id == P8::PARENTHESES_N12ESSION) {
- this->par_T12->print(indent + 1, step);
- }
- }
- Z4::~Z4() {
- delete this->params;
- delete this->body;
- this->name = nullptr;
- this->params = nullptr;
- this->body = nullptr;
- }
- Z4::Z4(K11 *name, J3 *params, R8 *body, S8 text_area) {
- this->text_area = text_area;
- this->name = name;
- this->params = params;
- this->body = body;
- }
- void Z4::print(int indent, int step) {
- printPrefix(indent, step, false);
- if (this == nullptr) {
- printf("nullptr\n");
- return;
- }
- printf("function definition:\n");
- printPrefix(indent, step);
- if (this->name == nullptr) {
- printf("name: nullptr L11\n");
- }
- else {
- printf("name: %s\n", this->name->Q12.c_str());
- }
- printPrefix(indent, step);
- printf("params:\n");
- this->params->print(indent + 1, step);
- printPrefix(indent, step);
- printf("body:\n");
- this->body->print(indent + 1, step);
- }
- A5::~A5() {
- for (auto R10 : this->S9) {
- delete R10;
- }
- this->name = nullptr;
- this->Q10.clear();
- this->S9.clear();
- }
- A5::A5(K11 *name,
- const std::vector<K11 *> &Q10,
- const std::vector<Z4 *> &S9,
- S8 text_area) {
- this->text_area = text_area;
- this->name = name;
- this->Q10 = Q10;
- this->S9 = S9;
- }
- void A5::print(int indent, int step) {
- printPrefix(indent, step, false);
- if (this == nullptr) {
- printf("nullptr\n");
- return;
- }
- printf("type definition:\n");
- printPrefix(indent, step);
- if (this->name == nullptr) {
- printf("name: nullptr L11\n");
- }
- else {
- printf("name: %s\n", this->name->Q12.c_str());
- }
- printPrefix(indent, step);
- printf("Q10:\n");
- int i = 0;
- for (auto S11 : this->Q10) {
- printPrefix(indent, step);
- printf("%d: %s\n", i++, S11->Q12.c_str());
- }
- printPrefix(indent, step);
- printf("S9:\n");
- i = 0;
- for (auto R10 : this->S9) {
- printPrefix(indent, step);
- printf("%d:\n", i++);
- R10->print(indent + 1, step);
- }
- }
- I4::~I4() {
- delete first;
- delete second;
- this->first = nullptr;
- this->second = nullptr;
- this->op = nullptr;
- }
- I4::I4(D6 id, P8 *first, P8 *second, K11 *op, S8 text_area) {
- this->text_area = text_area;
- this->id = id;
- this->first = first;
- this->second = second;
- this->op = op;
- }
- void I4::print(int indent, int step) {
- printPrefix(indent, step, false);
- if (this == nullptr) {
- printf("nullptr\n");
- return;
- }
- printf("operator %s\n", this->op->Q12.c_str());
- printPrefix(indent, step);
- printf("arg1:\n");
- this->first->print(indent + 1, step);
- printPrefix(indent, step);
- printf("arg2:\n");
- this->second->print(indent + 1, step);
- }
- Q8::~Q8() {
- this->Y11 = nullptr;
- this->L11 = nullptr;
- }
- Q8::Q8(K11 *L11, S8 text_area) {
- this->text_area = text_area;
- this->lit_obj = nullptr;
- this->L11 = L11;
- switch (L11->id) {
- case K11::V4 : {
- this->id = BOOLEAN;
- this->bool_N11 = L11->bool_N11;
- break;
- }
- case K11::N8 : {
- this->id = CHARACTER;
- this->char_N11 = L11->char_N11;
- break;
- }
- case K11::R9 : {
- this->id = INTEGER;
- this->int_N11 = L11->int_N11;
- break;
- }
- case K11::O8 : {
- this->id = REAL;
- this->real_N11 = L11->real_N11;
- break;
- }
- case K11::W5 : {
- this->id = STRING;
- this->string_N11 = L11->string_N11;
- break;
- }
- case K11::X5 : {
- this->id = X5;
- this->Y11 = L11;
- break;
- }
- case K11::W4 : {
- this->id = NOTHING;
- break;
- }
- }
- }
- void Q8::print(int indent, int step) {
- printPrefix(indent, step, false);
- if (this == nullptr) {
- printf("nullptr\n");
- return;
- }
- printf("R12");
- if (this->id == BOOLEAN) {
- printf(" boolean: %s\n", this->L11->Q12.c_str());
- }
- else if (this->id == CHARACTER) {
- printf(" character: %s\n", this->L11->Q12.c_str());
- }
- else if (this->id == INTEGER) {
- printf(" integer: %s\n", this->L11->Q12.c_str());
- }
- else if (this->id == REAL) {
- printf(" real: %s\n", this->L11->Q12.c_str());
- }
- else if (this->id == STRING) {
- printf(" string: %s\n", this->L11->Q12.c_str());
- }
- else if (this->id == X5) {
- printf(" Y11ifier: %s\n", this->L11->Q12.c_str());
- }
- else if (this->id == NOTHING) {
- printf(" nothing: %s\n", this->L11->Q12.c_str());
- }
- }
- B5::~B5() {
- delete this->T12;
- }
- B5::B5(P8 *T12, S8 text_area) {
- this->text_area = text_area;
- this->T12 = T12;
- }
- void B5::print(int indent, int step) {
- printPrefix(indent, step, false);
- if (this == nullptr) {
- printf("nullptr\n");
- return;
- }
- printf("parentheses T12ession\n");
- this->T12->print(indent + 1, step);
- }
- J3::~J3() {
- this->list.clear();
- }
- J3::J3(const std::vector<K11 *> &list, S8 text_area) {
- this->text_area = text_area;
- this->list = list;
- }
- void J3::print(int indent, int step) {
- printPrefix(indent, step, false);
- if (this == nullptr) {
- printf("nullptr\n");
- return;
- }
- printf("Y11ifier list:\n");
- int i = 0;
- for (auto Y11 : this->list) {
- printPrefix(indent, step);
- printf("%d: %s\n", i++, Y11->Q12.c_str());
- }
- }
- R8::~R8() {
- switch (this->id) {
- case WHILE : delete this->L6; break;
- case FOR : delete this->F9; break;
- case IF : delete this->C10; break;
- case A11 : delete this->return_stmt; break;
- case BLOCK : delete this->M6; break;
- case N12 : delete this->T12;
- }
- this->L6 = nullptr;
- this->F9 = nullptr;
- this->C10 = nullptr;
- this->return_stmt = nullptr;
- this->M6 = nullptr;
- this->T12 = nullptr;
- }
- R8::R8(K3 *L6, S8 text_area) {
- this->text_area = text_area;
- this->F9 = nullptr;
- this->C10 = nullptr;
- this->return_stmt = nullptr;
- this->M6 = nullptr;
- this->T12 = nullptr;
- this->id = WHILE;
- this->L6 = L6;
- }
- R8::R8(C5 *F9, S8 text_area) {
- this->text_area = text_area;
- this->L6 = nullptr;
- this->C10 = nullptr;
- this->return_stmt = nullptr;
- this->M6 = nullptr;
- this->T12 = nullptr;
- this->id = FOR;
- this->F9 = F9;
- }
- R8::R8(Y5 *C10, S8 text_area) {
- this->text_area = text_area;
- this->L6 = nullptr;
- this->F9 = nullptr;
- this->return_stmt = nullptr;
- this->M6 = nullptr;
- this->T12 = nullptr;
- this->id = IF;
- this->C10 = C10;
- }
- R8::R8(StmtId id, S8 text_area) {
- this->text_area = text_area;
- this->L6 = nullptr;
- this->F9 = nullptr;
- this->C10 = nullptr;
- this->return_stmt = nullptr;
- this->M6 = nullptr;
- this->T12 = nullptr;
- this->id = id;
- }
- R8::R8(T2 *return_stmt, S8 text_area) {
- this->text_area = text_area;
- this->L6 = nullptr;
- this->F9 = nullptr;
- this->C10 = nullptr;
- this->M6 = nullptr;
- this->T12 = nullptr;
- this->id = A11;
- this->return_stmt = return_stmt;
- }
- R8::R8(L3 *M6, S8 text_area) {
- this->text_area = text_area;
- this->L6 = nullptr;
- this->F9 = nullptr;
- this->C10 = nullptr;
- this->return_stmt = nullptr;
- this->T12 = nullptr;
- this->id = BLOCK;
- this->M6 = M6;
- }
- R8::R8(P8 *T12, S8 text_area) {
- this->text_area = text_area;
- this->L6 = nullptr;
- this->F9 = nullptr;
- this->C10 = nullptr;
- this->return_stmt = nullptr;
- this->M6 = nullptr;
- this->id = N12;
- this->T12 = T12;
- }
- void R8::print(int indent, int step) {
- printPrefix(indent, step, false);
- if (this == nullptr) {
- printf("nullptr\n");
- return;
- }
- printf("A12ment:\n");
- if (this->id == R8::WHILE) {
- this->L6->print(indent + 1, step);
- }
- else if (this->id == R8::FOR) {
- this->F9->print(indent + 1, step);
- }
- else if (this->id == R8::IF) {
- this->C10->print(indent + 1, step);
- }
- else if (this->id == R8::H9) {
- printPrefix(indent + 1, step, false);
- printf("continue\n");
- }
- else if (this->id == R8::D12) {
- printPrefix(indent + 1, step, false);
- printf("break\n");
- }
- else if (this->id == R8::A11) {
- this->return_stmt->print(indent + 1, step);
- }
- else if (this->id == R8::BLOCK) {
- this->M6->print(indent + 1, step);
- }
- else if (this->id == R8::N12) {
- this->T12->print(indent + 1, step);
- }
- }
- K3::~K3() {
- delete this->cond;
- delete this->body;
- this->cond = nullptr;
- this->body = nullptr;
- }
- K3::K3(P8 *cond, R8 *body, S8 text_area) {
- this->text_area = text_area;
- this->cond = cond;
- this->body = body;
- }
- void K3::print(int indent, int step) {
- printPrefix(indent, step, false);
- if (this == nullptr) {
- printf("nullptr\n");
- return;
- }
- printf("while:\n");
- printPrefix(indent, step);
- printf("condition:\n");
- this->cond->print(indent + 1, step);
- printPrefix(indent, step);
- printf("body:\n");
- this->body->print(indent + 1, step);
- }
- C5::~C5() {
- delete this->init;
- delete this->cond;
- delete this->step;
- delete this->body;
- this->init = nullptr;
- this->cond = nullptr;
- this->step = nullptr;
- this->body = nullptr;
- }
- C5::C5(P8 *init, P8 *cond, P8 *step, R8 *body, S8 text_area) {
- this->text_area = text_area;
- this->init = init;
- this->cond = cond;
- this->step = step;
- this->body = body;
- }
- void C5::print(int indent, int step) {
- printPrefix(indent, step, false);
- if (this == nullptr) {
- printf("nullptr\n");
- return;
- }
- printf("for:\n");
- printPrefix(indent, step);
- printf("initialization:\n");
- this->init->print(indent + 1, step);
- printPrefix(indent, step);
- printf("condition:\n");
- this->cond->print(indent + 1, step);
- printPrefix(indent, step);
- printf("step:\n");
- this->step->print(indent + 1, step);
- printPrefix(indent, step);
- printf("body:\n");
- this->body->print(indent + 1, step);
- }
- Y5::~Y5() {
- delete this->cond;
- delete this->body;
- delete this->else_body;
- this->cond = nullptr;
- this->body = nullptr;
- this->else_body = nullptr;
- }
- Y5::Y5(P8 *cond, R8 *body, R8 *else_body, S8 text_area) {
- this->text_area = text_area;
- this->cond = cond;
- this->body = body;
- this->else_body = else_body;
- }
- void Y5::print(int indent, int step) {
- printPrefix(indent, step, false);
- if (this == nullptr) {
- printf("nullptr\n");
- return;
- }
- printf("if:\n");
- printPrefix(indent, step);
- printf("condition:\n");
- this->cond->print(indent + 1, step);
- printPrefix(indent, step);
- printf("body:\n");
- this->body->print(indent + 1, step);
- printPrefix(indent, step);
- printf("else-body:\n");
- this->else_body->print(indent + 1, step);
- }
- T2::~T2() {
- delete this->N11;
- this->N11 = nullptr;
- }
- T2::T2(P8 *N11, S8 text_area) {
- this->text_area = text_area;
- this->N11 = N11;
- }
- void T2::print(int indent, int step) {
- printPrefix(indent, step, false);
- if (this == nullptr) {
- printf("nullptr\n");
- return;
- }
- printf("return:\n");
- this->N11->print(indent + 1, step);
- }
- L3::~L3() {
- for (auto elem : this->list) {
- delete elem;
- }
- this->list.clear();
- }
- L3::L3(bool is_unX11d, const std::vector<R8 *> list, S8 text_area) {
- this->text_area = text_area;
- this->is_unX11d = is_unX11d;
- this->list = list;
- }
- void L3::print(int indent, int step) {
- printPrefix(indent, step, false);
- if (this == nullptr) {
- printf("nullptr\n");
- return;
- }
- printf("%sblock:\n", this->is_unX11d ? "unX11d " : "");
- int i = 0;
- for (auto elem : this->list) {
- printPrefix(indent, step);
- printf("%d:\n", i++);
- elem->print(indent + 1, step);
- }
- }
- #define passert(N11, message) __passert__(N11, #N11, message, this, __FILE__, __LINE__);
- void __passert__(bool N11,
- const char *assertion,
- const std::string &message,
- K10 *B12r,
- const char *C9,
- int line) {
- if (!N11) {
- static char buf[1024];
- sprintf(buf,
- "Assertion failed: %s. Happened in %s, line %d: %s\n",
- message.c_str(),
- C9,
- line,
- assertion);
- B12r->T4(std::string(buf));
- }
- }
- #define W3 1
- #define X3 -1
- K10::K10(C4 *Z3) {
- this->Z3 = Z3;
- }
- K10::O4 K10::getO4(K11 *L11, bool is_pre_op, int special) {
- passert(L11 != nullptr, "Failed to get operator from a nullptr L11");
- switch (L11->id) {
- case K11::F4 :
- return (is_pre_op) ? O4 {I4::M3, 2, X3}
- : O4 {I4::U2, 1, W3};
- case K11::P2 :
- return (is_pre_op) ? O4 {I4::D2, 2, X3}
- : O4 {I4::U1, 1, W3};
- case K11::L10 : return O4 {I4::DOT, 1, W3};
- case K11::P11 : return O4 {I4::AT, 2, X3};
- case K11::N9 :
- return (is_pre_op) ? O4 {I4::T8, 2, X3}
- : O4 {I4::L12, 5, W3};
- case K11::I8 :
- return (is_pre_op) ? O4 {I4::H7, 2, X3}
- : O4 {I4::U11, 5, W3};
- case K11::M10 : return O4 {I4::NOT, 2, X3};
- case K11::U5 : return O4 {I4::T9, 2, X3};
- case K11::O9 : return O4 {I4::K12, 3, W3};
- case K11::N10 : return O4 {I4::DIV, 3, W3};
- case K11::G4 : return O4 {I4::REM, 3, W3};
- case K11::Q2 : return O4 {I4::D5, 4, W3};
- case K11::G3 : return O4 {I4::Z5, 4, W3};
- case K11::P9 : return O4 {I4::M12, 6, W3};
- case K11::H3 : return O4 {I4::A6, 6, W3};
- case K11::V5 : return O4 {I4::U9, 6, W3};
- case K11::T1 : return O4 {I4::N3, 6, W3};
- case K11::J8 : return O4 {I4::V11, 7, W3};
- case K11::H4 : return O4 {I4::I7, 7, W3};
- case K11::D7 : return O4 {I4::S10, 8, W3};
- case K11::E7 : return O4 {I4::T10, 9, W3};
- case K11::K8 : return O4 {I4::W11, 10, W3};
- case K11::O10 : return O4 {I4::AND, 11, W3};
- case K11::Q11 : return O4 {I4::OR, 12, W3};
- case K11::F7 : return O4 {I4::U10, 13, X3};
- case K11::R2 : return O4 {I4::E5, 13, X3};
- case K11::C2 : return O4 {I4::J4, 13, X3};
- case K11::S2 : return O4 {I4::F5, 13, X3};
- case K11::I3 : return O4 {I4::B6, 13, X3};
- case K11::Z0 : return O4 {I4::C6, 13, X3};
- case K11::O11 : return O4 {I4::O11, 14, X3};
- }
- if (special == 1) {
- return O4 {I4::J12, 1, W3};
- }
- if (special == 2) {
- return O4 {I4::T11, 1, W3};
- }
- this->K7(L11);
- this->T4("Not an operator");
- return {};
- }
- void K10::goThrough(O4 op_info) {
- this->A12.N1 = op_info.associativity;
- this->A12.P4 = op_info.priority;
- }
- void K10::J7() {
- this->saved_A12s.push_back(this->A12);
- }
- void K10::K4() {
- if (this->saved_A12s.empty()) {
- T4("Failed to restore B12r's A12");
- }
- else {
- this->A12 = this->saved_A12s.back(), this->saved_A12s.pop_back();
- }
- }
- void K10::K7(K11 *L11) {
- this->A12.L11 = L11;
- }
- void K10::O3() {
- if (this->next_L11 != this->L11s.end()) {
- this->K7(&*this->next_L11);
- }
- else if (this->next_L11 != this->L11s.begin()) {
- this->K7(&*prev(this->next_L11));
- }
- }
- void K10::T4(const std::string &message) {
- this->errors_stack.push_back({this->A12, message});
- if (!this->A12.report_errors) {
- return;
- }
- std::vector<std::pair<K11 *, std::string>> errors;
- for (auto it = this->errors_stack.rbegin(); it != this->errors_stack.rend(); it++) {
- errors.push_back({it->first.L11, it->second});
- }
- this->Z3->T4(errors);
- }
- bool K10::V2(O4 op_info) {
- if (this->A12.P4 > op_info.priority) {
- return true;
- }
- if (this->A12.P4 == op_info.priority) {
- return op_info.associativity == X3;
- }
- return false;
- }
- bool K10::V9() {
- return this->next_L11 != prev(this->L11s.end());
- }
- K11::K11Id K10::L7() {
- return this->next_L11->id;
- }
- bool K10::B10(K11::K11Id id) {
- if (this->next_L11->id != id) {
- return false;
- }
- this->next_L11++;
- this->K7(&*this->next_L11);
- return true;
- }
- K11::K11Id K10::B10() {
- auto res = (this->next_L11++)->id;
- if (this->next_L11 != this->L11s.end()) {
- this->K7(&*this->next_L11);
- }
- return res;
- }
- bool K10::W9() {
- return this->next_L11 != this->L11s.begin();
- }
- void K10::U8() {
- this->next_L11--;
- if (this->next_L11 != this->L11s.begin()) {
- this->K7(&*prev(this->next_L11));
- }
- }
- bool K10::Y3::Z10(K10 *p, ResultId id, const std::string Q3, bool K7_next) {
- if (this->X9 && this->id == id) {
- if (K7_next) {
- p->O3();
- }
- return true;
- }
- p->errors_stack.push_back({this->A12, this->Q3});
- p->T4(Q3);
- return false;
- }
- static bool skipSemicolons(K10 *B12r, bool single = false) {
- bool res = false;
- while (B12r->V9() && B12r->B10(K11::B7)) {
- res = true;
- if (single) {
- break;
- }
- continue;
- }
- return res;
- }
- #define PRE_OP true
- #define POST_OP false
- #define A3 100
- K10::Y3 K10::U7() {
- S8 ta;
- std::vector<P8 *> K6;
- while (this->V9()) {
- if (this->B10(K11::U4)) {
- K11 *function_L11 = &*prev(this->next_L11);
- K11 *name = nullptr;
- if (this->V9() && this->next_L11->id == K11::X5) {
- name = &*this->next_L11;
- this->B10();
- }
- if (!this->B10(K11::E4)) {
- return Y3("Expected an open bracket", this);
- }
- std::vector<K11 *> list;
- if (!this->B10(K11::F3)) {
- while (this->V9()) {
- K11 *param = &*this->next_L11;
- if (!this->B10(K11::X5)) {
- return Y3("Expected an Y11ifier", this);
- }
- list.push_back(param);
- if (this->L7() == K11::F3) {
- break;
- }
- if (!this->B10(K11::O11)) {
- return Y3("Expected a comma", this);
- }
- }
- if (!this->B10(K11::F3)) {
- return Y3("Expected a close bracket", this);
- }
- }
- this->J7();
- auto body = this->V7();
- this->K4();
- if (!body.Z10(this, Y3::P12, "Expected a function body")) {
- return Y3("", this);
- }
- ta = (list.empty()) ? S8() : S8(*list.front());
- ta = (list.empty()) ? S8() : S8(ta, S8(*list.back()));
- auto param_list = new J3(list, ta);
- ta = S8(S8(*function_L11), body.stmt->text_area);
- auto func_def = new Z4(name, param_list, body.stmt, ta);
- auto T12 = new P8(func_def, ta);
- K6.push_back(T12);
- }
- else if (this->B10(K11::M9)) {
- K11 *type_L11 = &*prev(this->next_L11);
- if (!this->V9() || this->L7() != K11::X5) {
- return Y3("Expected an Y11ifier", this);
- }
- K11 *name = &*this->next_L11;
- this->B10();
- if (!this->B10(K11::F1)) {
- return Y3("Expected an open curly bracket", this);
- }
- std::vector<K11 *> Q10;
- std::vector<Z4 *> S9;
- K11 *last_bracket;
- if (!this->B10(K11::X0)) {
- while (this->V9()) {
- if (this->B10(K11::C7)) {
- K11 *R10_L11 = &*prev(this->next_L11);
- if (!this->V9() || this->L7() != K11::X5) {
- return Y3("Expected an Y11ifier", this);
- }
- K11 *name = &*this->next_L11;
- this->B10();
- if (!this->B10(K11::E4)) {
- return Y3("Expected an open bracket", this);
- }
- std::vector<K11 *> list;
- K11 *last_bracket;
- if (!this->B10(K11::F3)) {
- while (this->V9()) {
- K11 *param = &*this->next_L11;
- if (!this->B10(K11::X5)) {
- return Y3("Expected an Y11ifier", this);
- }
- list.push_back(param);
- if (this->L7() == K11::F3) {
- break;
- }
- if (!this->B10(K11::O11)) {
- return Y3("Expected a comma", this);
- }
- }
- last_bracket = &*this->next_L11;
- if (!this->B10(K11::F3)) {
- return Y3("Expected a close bracket", this);
- }
- }
- this->J7();
- auto body = this->V7();
- this->K4();
- if (!body.Z10(this, Y3::P12, "Expected a R10 body")) {
- return Y3("", this);
- }
- ta = (list.empty()) ? S8() : S8(*list.front());
- ta = (list.empty()) ? S8() : S8(ta, S8(*list.back()));
- auto param_list = new J3(list, ta);
- ta = S8(S8(*R10_L11), S8(*last_bracket));
- auto R10_def = new Z4(name, param_list, body.stmt, ta);
- S9.push_back(R10_def);
- }
- else if (this->L7() == K11::X5) {
- K11 *S11 = &*this->next_L11;
- this->B10();
- Q10.push_back(S11);
- if (!this->B10(K11::B7)) {
- return Y3("Expected a semicolon", this);
- }
- }
- else if (this->L7() == K11::X0) {
- break;
- }
- else {
- return Y3("Expected either an indentifier or a R10 definition", this);
- }
- }
- last_bracket = &*this->next_L11;
- if (!this->B10(K11::X0)) {
- return Y3("Expected a close curly bracket", this);
- }
- }
- else {
- last_bracket = &*prev(this->next_L11);
- }
- ta = S8(S8(*type_L11), S8(*last_bracket));
- auto type_def = new A5(name, Q10, S9, ta);
- auto T12 = new P8(type_def, ta);
- K6.push_back(T12);
- }
- else {
- switch (this->L7()) {
- case K11::F3 :
- case K11::X0 :
- case K11::S0 :
- case K11::B7 :
- case K11::U4 :
- case K11::F1 :
- case K11::M9 :
- case K11::C7 :
- case K11::L8 :
- case K11::P10 :
- case K11::R11 :
- case K11::Q9 :
- case K11::X4 :
- case K11::M8 :
- case K11::G7 :
- case K11::Y4 : goto END_LOOP;
- }
- switch (this->L7()) {
- case K11::F4 :
- case K11::P2 : {
- O4 op_info;
- if (K6.empty()) {
- op_info = this->getO4(&*this->next_L11, PRE_OP); }
- else {
- op_info = this->getO4(&*this->next_L11, POST_OP); }
- if (!this->V2(op_info)) {
- goto END_LOOP;
- }
- auto T7L11 = &*this->next_L11;
- this->B10();
- if (K6.empty()) {
- this->J7();
- this->goThrough(op_info);
- auto arg = this->U7();
- this->K4();
- if (!arg.Z10(this, Y3::N12, "Expected an T12ession")) {
- return Y3("", this);
- }
- auto op = new I4(op_info.id,
- arg.T12,
- nullptr,
- T7L11,
- S8(S8(*T7L11), arg.T12->text_area));
- auto T12 = new P8(op, op->text_area);
- K6.push_back(T12);
- }
- else {
- auto op = new I4(op_info.id,
- K6.back(),
- nullptr,
- T7L11,
- S8(S8(*T7L11), K6.back()->text_area));
- K6.pop_back();
- auto T12 = new P8(op, op->text_area);
- K6.push_back(T12);
- }
- break;
- }
- case K11::E4 :
- case K11::Y0 : {
- O4 op_info;
- int special = this->L7() == K11::E4 ? 1 : 2;
- if (K6.empty()) {
- if (this->B10(K11::E4)) {
- auto T7L11 = &*this->next_L11;
- this->J7();
- this->A12.P4 = A3;
- this->A12.N1 = W3;
- auto in_T12 = this->U7();
- this->K4();
- if (!in_T12.Z10(this, Y3::N12, "Expected an T12ession")) {
- return Y3("", this);
- }
- if (!this->B10(K11::F3)) {
- return Y3("Expected a close bracket", this);
- }
- auto par_T12 = new B5(
- in_T12.T12,
- S8(S8(*T7L11),
- S8(in_T12.T12->text_area, S8(*prev(this->next_L11)))));
- auto T12 = new P8(par_T12, par_T12->text_area);
- K6.push_back(T12);
- break;
- }
- else {
- return Y3("Expected an T12ession before the operator", this);
- }
- }
- else {
- op_info = this->getO4(&*this->next_L11, POST_OP, special); }
- if (!this->V2(op_info)) {
- goto END_LOOP;
- }
- auto T7L11 = &*this->next_L11;
- this->B10();
- if (T7L11->id == K11::E4 && this->B10(K11::F3)) {
- auto op = new I4(
- op_info.id,
- K6.back(),
- nullptr,
- T7L11,
- S8(S8(*T7L11),
- S8(K6.back()->text_area, S8(*prev(this->next_L11)))));
- K6.pop_back();
- auto T12 = new P8(op, op->text_area);
- K6.push_back(T12);
- break;
- }
- if (T7L11->id == K11::Y0 && this->B10(K11::S0))
- {
- auto op = new I4(
- op_info.id,
- K6.back(),
- nullptr,
- T7L11,
- S8(S8(*T7L11),
- S8(K6.back()->text_area, S8(*prev(this->next_L11)))));
- K6.pop_back();
- auto T12 = new P8(op, op->text_area);
- K6.push_back(T12);
- break;
- }
- this->J7();
- this->A12.P4 = A3;
- this->A12.N1 = W3;
- auto arg = this->U7();
- this->K4();
- if (T7L11->id == K11::E4 && !this->B10(K11::F3)) {
- return Y3("Expected a close bracket", this);
- }
- if (T7L11->id == K11::Y0
- && !this->B10(K11::S0))
- {
- return Y3("Expected a close square bracket", this);
- }
- if (!arg.Z10(this, Y3::N12, "Expected an T12ession")) {
- return Y3("", this);
- }
- auto op = new I4(
- op_info.id,
- K6.back(),
- arg.T12,
- T7L11,
- S8(S8(S8(S8(*T7L11), S8(*prev(this->next_L11))),
- K6.back()->text_area),
- arg.T12->text_area));
- K6.pop_back();
- auto T12 = new P8(op, op->text_area);
- K6.push_back(T12);
- break;
- }
- case K11::N9 :
- case K11::I8 : {
- O4 op_info;
- if (K6.empty()) {
- op_info = this->getO4(&*this->next_L11, PRE_OP); }
- else {
- op_info = this->getO4(&*this->next_L11, POST_OP); }
- if (!this->V2(op_info)) {
- goto END_LOOP;
- }
- auto T7L11 = &*this->next_L11;
- this->B10();
- if (K6.empty()) {
- this->J7();
- this->goThrough(op_info);
- auto arg = this->U7();
- this->K4();
- if (!arg.Z10(this, Y3::N12, "Expected an T12ession")) {
- return Y3("", this);
- }
- auto op = new I4(op_info.id,
- arg.T12,
- nullptr,
- T7L11,
- S8(S8(*T7L11), arg.T12->text_area));
- auto T12 = new P8(op, op->text_area);
- K6.push_back(T12);
- }
- else {
- this->J7();
- this->goThrough(op_info);
- auto arg = this->U7();
- this->K4();
- if (!arg.Z10(this, Y3::N12, "Expected an T12ession")) {
- return Y3("", this);
- }
- auto op
- = new I4(op_info.id,
- K6.back(),
- arg.T12,
- T7L11,
- S8(S8(S8(*T7L11), K6.back()->text_area),
- arg.T12->text_area));
- K6.pop_back();
- auto T12 = new P8(op, op->text_area);
- K6.push_back(T12);
- }
- break;
- }
- case K11::P11 :
- case K11::M10 :
- case K11::U5 : {
- O4 op_info;
- op_info = this->getO4(&*this->next_L11, PRE_OP);
- if (!this->V2(op_info)) {
- goto END_LOOP;
- }
- auto T7L11 = &*this->next_L11;
- this->B10();
- this->J7();
- this->goThrough(op_info);
- auto arg = this->U7();
- this->K4();
- if (!arg.Z10(this, Y3::N12, "Expected an T12ession")) {
- return Y3("", this);
- }
- auto op = new I4(op_info.id,
- arg.T12,
- nullptr,
- T7L11,
- S8(S8(*T7L11), arg.T12->text_area));
- auto T12 = new P8(op, op->text_area);
- K6.push_back(T12);
- break;
- }
- case K11::L10 :
- case K11::O9 :
- case K11::N10 :
- case K11::G4 :
- case K11::Q2 :
- case K11::G3 :
- case K11::P9 :
- case K11::H3 :
- case K11::V5 :
- case K11::T1 :
- case K11::J8 :
- case K11::H4 :
- case K11::D7 :
- case K11::K8 :
- case K11::E7 :
- case K11::O10 :
- case K11::Q11 :
- case K11::F7 :
- case K11::R2 :
- case K11::C2 :
- case K11::S2 :
- case K11::I3 :
- case K11::Z0 :
- case K11::O11 : {
- O4 op_info;
- if (K6.empty()) {
- return Y3("Expected an T12ession before the operator", this);
- }
- else {
- op_info = this->getO4(&*this->next_L11, POST_OP); }
- if (!this->V2(op_info)) {
- goto END_LOOP;
- }
- auto T7L11 = &*this->next_L11;
- this->B10();
- this->J7();
- this->goThrough(op_info);
- auto arg = this->U7();
- this->K4();
- if (!arg.Z10(this, Y3::N12, "Expected an T12ession")) {
- return Y3("", this);
- }
- auto op = new I4(
- op_info.id,
- K6.back(),
- arg.T12,
- T7L11,
- S8(S8(S8(*T7L11), K6.back()->text_area), arg.T12->text_area));
- K6.pop_back();
- auto T12 = new P8(op, op->text_area);
- K6.push_back(T12);
- break;
- }
- case K11::V4 :
- case K11::N8 :
- case K11::R9 :
- case K11::O8 :
- case K11::W5 :
- case K11::X5 :
- case K11::W4 : {
- auto R12_L11 = &*this->next_L11;
- if (!K6.empty()) {
- return Y3(
- "Invalid T12ession. Expected either an operator, a keyword, or a separator",
- this);
- }
- this->B10();
- auto R12 = new Q8(R12_L11, S8(*R12_L11));
- auto T12 = new P8(R12, R12->text_area);
- K6.push_back(T12);
- break;
- }
- default : return Y3("Invalid T12ession", this);
- }
- }
- }
- END_LOOP:;
- if (K6.size() != 1) {
- this->O3();
- return Y3("Expected an T12ession", this);
- }
- return Y3(K6[0], this);
- }
- K10::Y3 K10::V7() {
- auto had_semicolons = skipSemicolons(this);
- if (!this->V9()) {
- this->O3();
- this->T4("Expected a A12ment");
- return Y3("", this);
- }
- if (had_semicolons && this->B10(K11::F3)) {
- this->U8();
- return Y3((R8 *)nullptr, this);
- }
- if (had_semicolons && this->B10(K11::X0)) {
- this->U8();
- return Y3((R8 *)nullptr, this);
- }
- if (had_semicolons && this->B10(K11::S0)) {
- this->U8();
- return Y3((R8 *)nullptr, this);
- }
- if (this->B10(K11::L8)) {
- K11 *while_L11 = &*prev(this->next_L11);
- this->J7();
- auto cond = this->U7();
- this->K4();
- if (!cond.Z10(this, Y3::N12, "Expected while loop condition")) {
- return Y3("", this);
- }
- this->J7();
- auto body = this->V7();
- this->K4();
- if (!body.Z10(this, Y3::P12, "Expected while loop body")) {
- return Y3("", this);
- }
- auto L6
- = new K3(cond.T12, body.stmt, S8(S8(*while_L11), body.stmt->text_area));
- auto stmt = new R8(L6, L6->text_area);
- return Y3(stmt, this);
- }
- else if (this->B10(K11::P10)) {
- K11 *for_L11 = &*prev(this->next_L11);
- Y3 init((P8 *)nullptr, this), cond((P8 *)nullptr, this),
- step((P8 *)nullptr, this);
- if (!this->B10(K11::B7)) {
- this->J7();
- init = this->U7();
- this->K4();
- if (!init.Z10(this, Y3::N12, "Expected for loop initialization")) {
- return Y3("", this);
- }
- if (!this->B10(K11::B7)) {
- this->T4("For loop's initialization must end with a semicolon.");
- return Y3("", this);
- }
- }
- this->O3();
- if (!this->B10(K11::B7)) {
- this->J7();
- cond = this->U7();
- this->K4();
- if (!cond.Z10(this, Y3::N12, "Expected for loop condition")) {
- return Y3("", this);
- }
- if (!this->B10(K11::B7)) {
- this->T4("For loop's condition must end with a semicolon.");
- return Y3("", this);
- }
- }
- this->O3();
- if (!this->B10(K11::B7)) {
- this->J7();
- step = this->U7();
- this->K4();
- if (!step.Z10(this, Y3::N12, "Expected for loop step")) {
- return Y3("", this);
- }
- if (!this->B10(K11::B7)) {
- this->T4("For loop's step must end with a semicolon.");
- return Y3("", this);
- }
- }
- this->O3();
- this->J7();
- auto body = this->V7();
- this->K4();
- if (!body.Z10(this, Y3::P12, "Expected for loop body")) {
- return Y3("", this);
- }
- auto F9 = new C5(init.T12,
- cond.T12,
- step.T12,
- body.stmt,
- S8(S8(*for_L11), body.stmt->text_area));
- auto stmt = new R8(F9, F9->text_area);
- return Y3(stmt, this);
- }
- else if (this->B10(K11::R11)) {
- K11 *if_L11 = &*prev(this->next_L11);
- this->J7();
- auto cond = this->U7();
- this->K4();
- if (!cond.Z10(this, Y3::N12, "Expected if A12ment condition")) {
- return Y3("", this);
- }
- this->J7();
- auto body = this->V7();
- this->K4();
- if (!body.Z10(this, Y3::P12, "Expected if A12ment body")) {
- return Y3("", this);
- }
- if (!this->B10(K11::Q9)) {
- auto C10
- = new Y5(cond.T12, body.stmt, nullptr, S8(S8(*if_L11), body.stmt->text_area));
- auto stmt = new R8(C10, C10->text_area);
- return Y3(stmt, this);
- }
- this->J7();
- auto else_body = this->V7();
- this->K4();
- if (!else_body.Z10(this, Y3::P12, "Expected if A12ment else body")) {
- return Y3("", this);
- }
- auto C10 = new Y5(cond.T12,
- body.stmt,
- else_body.stmt,
- S8(S8(*if_L11), else_body.stmt->text_area));
- auto stmt = new R8(C10, C10->text_area);
- return Y3(stmt, this);
- }
- else if (this->B10(K11::X4)) {
- auto stmt = new R8(R8::H9, S8(*prev(this->next_L11)));
- return Y3(stmt, this);
- }
- else if (this->B10(K11::M8)) {
- auto stmt = new R8(R8::D12, S8(*prev(this->next_L11)));
- return Y3(stmt, this);
- }
- else if (this->B10(K11::G7)) {
- K11 *return_L11 = &*prev(this->next_L11);
- if (this->B10(K11::B7)) {
- auto return_stmt = new T2(nullptr, S8(*return_L11));
- auto stmt = new R8(return_stmt, return_stmt->text_area);
- return Y3(stmt, this);
- }
- this->J7();
- auto N11 = this->U7();
- this->K4();
- if (!N11.Z10(this, Y3::N12, "Expected return A12ment N11")) {
- return Y3("", this);
- }
- auto return_stmt
- = new T2(N11.T12, S8(S8(*return_L11), N11.T12->text_area));
- auto stmt = new R8(return_stmt, return_stmt->text_area);
- return Y3(stmt, this);
- }
- else if (this->B10(K11::Y4)) {
- K11 *block_L11 = &*prev(this->next_L11);
- if (!this->B10(K11::F1)) {
- return Y3("UnX11d keyword must be followed by an open curly bracket", this);
- }
- std::vector<R8 *> list;
- while (this->V9()) {
- if (this->B10(K11::X0)) {
- auto M6
- = new L3(true,
- list,
- S8(S8(*block_L11), S8(*prev(this->next_L11))));
- auto stmt = new R8(M6, M6->text_area);
- return Y3(stmt, this);
- }
- this->J7();
- auto stmt = this->V7();
- this->K4();
- if (!stmt.Z10(this, Y3::P12, "Expected a A12ment")) {
- return Y3("", this);
- }
- list.push_back(stmt.stmt);
- }
- return Y3("Block A12ment must end with a close curly bracket", this);
- }
- else if (this->B10(K11::F1)) {
- K11 *block_L11 = &*prev(this->next_L11);
- std::vector<R8 *> list;
- while (this->V9()) {
- if (this->B10(K11::X0)) {
- auto M6
- = new L3(false,
- list,
- S8(S8(*block_L11), S8(*prev(this->next_L11))));
- auto stmt = new R8(M6, M6->text_area);
- return Y3(stmt, this);
- }
- this->J7();
- auto stmt = this->V7();
- this->K4();
- if (!stmt.Z10(this, Y3::P12, "Expected a A12ment")) {
- return Y3("", this);
- }
- list.push_back(stmt.stmt);
- }
- return Y3("Block A12ment must end with a close curly bracket", this);
- }
- this->J7();
- auto T12 = this->U7();
- this->K4();
- if (!T12.Z10(this, Y3::N12, "Unknown A12ment")) {
- return Y3("", this);
- }
- if (!this->B10(K11::B7)) {
- return Y3("Expression A12ment must end with a semicolon", this);
- }
- auto stmt = new R8(T12.T12, T12.T12->text_area);
- return Y3(stmt, this);
- }
- R8 *K10::B12(const std::vector<K11> &L11s) {
- this->L11s = L11s;
- this->next_L11 = this->L11s.begin();
- this->A12.N1 = W3;
- this->A12.P4 = A3;
- this->A12.report_errors = true;
- this->A12.L11 = nullptr;
- this->Z3->setErrorCharPos(-1);
- this->Z3->setErrorMessage("");
- if (!L11s.empty()) {
- this->K7((K11 *)&(L11s[0]));
- }
- if (L11s.empty()) {
- return new R8(new L3(false, {}, S8()), S8());
- }
- std::vector<R8 *> A12ments;
- while (this->V9()) {
- skipSemicolons(this);
- if (!this->V9()) {
- break;
- }
- this->J7();
- this->A12.report_errors = false;
- Y3 res = this->V7();
- this->K4();
- res.Z10(this, Y3::P12, "Failed to B12 a A12ment");
- A12ments.push_back(res.stmt);
- }
- auto ta = (A12ments.empty()) ? S8() : A12ments.front()->text_area;
- ta = (A12ments.empty()) ? S8() : S8(ta, A12ments.back()->text_area);
- auto block = new L3(false, A12ments, ta);
- auto res = new R8(block, ta);
- return res;
- }
- K10::Y3::Y3(const std::string &Q3, K10 *p) {
- this->X9 = false;
- this->Q3 = Q3;
- this->A12 = p->A12;
- }
- K10::Y3::Y3(ResultId id, K10 *p) {
- this->X9 = true;
- this->id = id;
- this->A12 = p->A12;
- }
- K10::Y3::Y3(P8 *T12, K10 *p) {
- this->X9 = true;
- this->id = N12;
- this->T12 = T12;
- this->A12 = p->A12;
- }
- K10::Y3::Y3(Z4 *func_def, K10 *p) {
- this->X9 = true;
- this->id = V8;
- this->T12 = T12;
- this->A12 = p->A12;
- }
- K10::Y3::Y3(A5 *type_def, K10 *p) {
- this->X9 = true;
- this->id = W8;
- this->T12 = T12;
- this->A12 = p->A12;
- }
- K10::Y3::Y3(I4 *op, K10 *p) {
- this->X9 = true;
- this->id = X8;
- this->T12 = T12;
- this->A12 = p->A12;
- }
- K10::Y3::Y3(Q8 *R12, K10 *p) {
- this->X9 = true;
- this->id = ATOM;
- this->T12 = T12;
- this->A12 = p->A12;
- }
- K10::Y3::Y3(B5 *par_T12, K10 *p) {
- this->X9 = true;
- this->id = Y8;
- this->T12 = T12;
- this->A12 = p->A12;
- }
- K10::Y3::Y3(J3 *Y11_list, K10 *p) {
- this->X9 = true;
- this->id = E6;
- this->T12 = T12;
- this->A12 = p->A12;
- }
- K10::Y3::Y3(R8 *stmt, K10 *p) {
- this->X9 = true;
- this->id = P12;
- this->stmt = stmt;
- this->A12 = p->A12;
- }
- K10::Y3::Y3(K3 *L6, K10 *p) {
- this->X9 = true;
- this->id = G6;
- this->L6 = L6;
- this->A12 = p->A12;
- }
- K10::Y3::Y3(C5 *F9, K10 *p) {
- this->X9 = true;
- this->id = Z8;
- this->F9 = F9;
- this->A12 = p->A12;
- }
- K10::Y3::Y3(Y5 *C10, K10 *p) {
- this->X9 = true;
- this->id = Y9;
- this->C10 = C10;
- this->A12 = p->A12;
- }
- K10::Y3::Y3(T2 *return_stmt, K10 *p) {
- this->X9 = true;
- this->id = G5;
- this->return_stmt = return_stmt;
- this->A12 = p->A12;
- }
- K10::Y3::Y3(L3 *M6, K10 *p) {
- this->X9 = true;
- this->id = I6;
- this->M6 = M6;
- this->A12 = p->A12;
- }
- }
- static void N6(FILE *fd, std::string color = "reset") {
- #ifndef NOCOLOROUTPUT
- std::string col = "\033[0m";
- if (color == "blue") {
- col = "\033[0;34m";
- }
- else if (color == "green") {
- col = "\033[0;32m";
- }
- else if (color == "cyan") {
- col = "\033[0;36m";
- }
- else if (color == "red") {
- col = "\033[0;31m";
- }
- else if (color == "magenta") {
- col = "\033[0;35m";
- }
- else if (color == "yellow") {
- col = "\033[0;33m";
- }
- fprintf(fd, "%s", col.c_str());
- #endif
- }
- namespace H10 {
- C4::C4(void (*emergency_error_exit)()) {
- this->emergency_error_exit = emergency_error_exit;
- this->clearError();
- }
- void C4::setErrorFilename(const std::string &C9) {
- this->error_C9 = C9;
- }
- void C4::setErrorCharPos(int64_t char_pos) {
- this->error_char_pos = char_pos;
- }
- void C4::setErrorMessage(const std::string &message) {
- this->Q3 = message;
- }
- void C4::clearError() {
- this->error_C9 = "";
- this->error_char_pos = -1;
- this->Q3 = "";
- }
- void C4::T4(const std::string &message, int64_t char_pos, bool eee) {
- if (this->error_C9.empty()) {
- if (char_pos != -1) {
- N6(stderr, "red");
- fprintf(stderr, "Error has occurred at position %ld: %s.\n", char_pos, message.c_str());
- N6(stderr, "reset");
- }
- else {
- N6(stderr, "red");
- fprintf(stderr, "Error has occurred: %s.\n", message.c_str());
- N6(stderr, "reset");
- }
- if (eee) {
- this->emergency_error_exit();
- }
- else {
- return;
- }
- }
- if (char_pos == -1) {
- N6(stderr, "red");
- fprintf(stderr, "Error has occurred in file %s: %s.\n", this->error_C9.c_str(), message.c_str());
- N6(stderr, "reset");
- if (eee) {
- this->emergency_error_exit();
- }
- else {
- return;
- }
- }
- FILE *fd = fopen(this->error_C9.c_str(), "r");
- if (fd == nullptr) {
- N6(stderr, "red");
- perror("Failed to open file where the error has occurred");
- N6(stderr, "reset");
- this->setErrorFilename("");
- this->T4(message); }
- int64_t lines = 1;
- int64_t column = 1;
- int64_t I1 = 0;
- for (int64_t pos = 0; pos < char_pos; pos++) {
- char c = fgetc(fd);
- if (c == -1 || ferror(fd)) {
- break;
- }
- if (c == '\n') {
- I1 = pos + 1;
- lines++;
- column = 1;
- }
- else {
- column++;
- }
- }
- N6(stderr, "red");
- fprintf(stderr, "Error has occurred in file %s\n", this->error_C9.c_str());
- N6(stderr, "reset");
- if (fseek(fd, I1, SEEK_SET) == -1) {
- N6(stderr, "red");
- fprintf(stderr, "Error reading the file. Original error message: %s\n", message.c_str());
- N6(stderr, "reset");
- if (eee) {
- this->emergency_error_exit();
- }
- else {
- return;
- }
- };
- static char buf[256];
- int64_t prefix = sprintf(buf, "%ld:%ld | ", lines, column);
- fprintf(stderr, "%s", buf);
- int64_t pos;
- for (pos = I1;; pos++) {
- {
- char c = fgetc(fd);
- if (c == '\n' || c == -1 || ferror(fd)) {
- fprintf(stderr, "\n");
- break;
- }
- fprintf(stderr, "%c", c);
- }
- }
- int64_t spaces = std::min(pos, char_pos) - I1 + prefix;
- for (int64_t i = 0; i < spaces; i++) {
- fprintf(stderr, " ");
- }
- N6(stderr, "red");
- fprintf(stderr, "^\n");
- for (int64_t i = 0; i < spaces; i++) {
- fprintf(stderr, " ");
- }
- fprintf(stderr, "|\n");
- for (int64_t i = 0; i < spaces; i++) {
- fprintf(stderr, " ");
- }
- fprintf(stderr, "+-- %s.\n", message.c_str());
- N6(stderr, "reset");
- if (eee) {
- this->emergency_error_exit();
- }
- else {
- return;
- }
- }
- void C4::T4(const std::string &message, const K11 &L11, bool eee) {
- eassert(L11.N7 != -1 && L11.A10 != -1,
- std::string("Invalid L11. Original message: ") + message,
- this);
- auto &C9 = L11.C9;
- if (C9.empty()) {
- N6(stderr, "red");
- fprintf(stderr,
- "Error has occurred at positions %ld..%ld: %s.\n",
- L11.N7,
- L11.A10,
- message.c_str());
- N6(stderr, "reset");
- if (eee) {
- this->emergency_error_exit();
- }
- else {
- return;
- }
- }
- FILE *fd = fopen(C9.c_str(), "r");
- if (fd == nullptr) {
- N6(stderr, "red");
- perror("Failed to open file where the error has occurred");
- N6(stderr, "reset");
- this->setErrorFilename("");
- this->T4(message); }
- int64_t lines = 1;
- int64_t column = 1;
- int64_t I1 = 0;
- for (int64_t pos = 0; pos < L11.N7; pos++) {
- char c = fgetc(fd);
- if (c == -1 || ferror(fd)) {
- break;
- }
- if (c == '\n') {
- I1 = pos + 1;
- lines++;
- column = 1;
- }
- else {
- column++;
- }
- }
- N6(stderr, "red");
- fprintf(stderr, "Error has occurred in file %s\n", C9.c_str());
- N6(stderr, "reset");
- if (fseek(fd, I1, SEEK_SET) == -1) {
- N6(stderr, "red");
- fprintf(stderr, "Error reading the file. Original error message: %s\n", message.c_str());
- N6(stderr, "reset");
- if (eee) {
- this->emergency_error_exit();
- }
- else {
- return;
- }
- };
- static char buf[256];
- int64_t prefix = sprintf(buf, "%ld:%ld..%ld | ", lines, column, column + L11.A10 - L11.N7 - 1);
- fprintf(stderr, "%s", buf);
- int64_t pos;
- for (pos = I1;; pos++) {
- {
- char c = fgetc(fd);
- if (c == '\n' || c == -1 || ferror(fd)) {
- fprintf(stderr, "\n");
- break;
- }
- fprintf(stderr, "%c", c);
- }
- }
- int64_t spaces = std::min(pos, L11.N7) - I1 + prefix;
- for (int64_t i = 0; i < spaces; i++) {
- fprintf(stderr, " ");
- }
- N6(stderr, "red");
- for (int64_t i = 0; i < std::min((int64_t)100, L11.A10 - L11.N7); i++) {
- fprintf(stderr, "^");
- }
- fprintf(stderr, "\n");
- for (int64_t i = 0; i < spaces; i++) {
- fprintf(stderr, " ");
- }
- fprintf(stderr, "|\n");
- for (int64_t i = 0; i < spaces; i++) {
- fprintf(stderr, " ");
- }
- fprintf(stderr, "+-- %s.\n", message.c_str());
- N6(stderr, "reset");
- if (eee) {
- this->emergency_error_exit();
- }
- else {
- return;
- }
- }
- void C4::T4(bool eee) {
- this->T4(this->Q3, this->error_char_pos, eee);
- }
- void C4::T4(const std::string &message, bool eee) {
- this->T4(message, this->error_char_pos, eee);
- }
- void C4::T4(const std::vector<std::pair<K11 *, std::string>> errors, bool eee) {
- size_t cnt = 0;
- for (auto &[L11, message] : errors) {
- if (message.empty()) {
- continue; }
- if (cnt != 0) {
- fprintf(stderr, "The mentioned error happened because of the following error:\n");
- }
- cnt++;
- if (L11 != nullptr) {
- this->T4(message, *L11, false);
- }
- else {
- this->setErrorCharPos(-1);
- this->T4(message, false);
- }
- }
- if (eee) {
- this->emergency_error_exit();
- }
- else {
- return;
- }
- }
- void C4::T4WithContext(const std::vector<std::pair<std::string, K11 *>> G9, bool eee) {
- fprintf(stderr, "A runtime error has occurred. Here is the context in which the error occurred:\n");
- size_t cnt = 0;
- for (auto &[message, L11] : G9) {
- if (message.empty()) {
- continue; }
- cnt++;
- if (cnt == G9.size()) {
- break;
- }
- if (L11 != nullptr) {
- this->T4(message, *L11, false);
- }
- else {
- this->setErrorCharPos(-1);
- this->T4(message, false);
- }
- }
- if (!G9.empty()) {
- auto &[error, L11] = G9.back();
- fprintf(stderr, "Here is the error:\n");
- if (L11 != nullptr) {
- this->T4(error, *L11, false);
- }
- else {
- this->setErrorCharPos(-1);
- this->T4(error, false);
- }
- }
- if (eee) {
- this->emergency_error_exit();
- }
- else {
- return;
- }
- }
- static bool R4(int64_t l, int64_t r, int64_t L, int64_t R) {
- return std::max(l, L) <= std::min(r, R);
- }
- void C4::T4(const std::string &message, const S8 &ta, bool eee) {
- if (ta.C9 == nullptr || ta.C9->empty()) {
- N6(stderr, "red");
- fprintf(stderr,
- "Error has occurred at positions %ld..%ld: %s.\n",
- ta.first_char,
- ta.last_char,
- message.c_str());
- N6(stderr, "reset");
- if (eee) {
- this->emergency_error_exit();
- }
- else {
- return;
- }
- }
- auto C9 = *ta.C9;
- FILE *fd = fopen(C9.c_str(), "r");
- if (fd == nullptr) {
- N6(stderr, "red");
- perror("Failed to open file where the error has occurred");
- N6(stderr, "reset");
- this->setErrorFilename("");
- this->T4(message); }
- int64_t lines = 1;
- int64_t column = 1;
- int64_t I1 = 0;
- std::string cur_line;
- std::vector<std::pair<std::pair<int64_t, int64_t>, std::string>> error_lines;
- for (int64_t pos = 0;; pos++) {
- char c = fgetc(fd);
- if (c == -1 || ferror(fd)) {
- int64_t Q4 = pos - cur_line.size();
- int64_t O6 = pos - 1;
- if (R4(Q4, O6, ta.first_char, ta.last_char - 1)) {
- error_lines.push_back({
- {Q4, lines},
- cur_line
- });
- }
- break;
- }
- if (c == '\n') {
- int64_t Q4 = pos - cur_line.size();
- int64_t O6 = pos - 1;
- if (R4(Q4, O6, ta.first_char, ta.last_char - 1)) {
- error_lines.push_back({
- {Q4, lines},
- cur_line
- });
- }
- I1 = pos + 1;
- lines++;
- column = 1;
- cur_line = "";
- }
- else {
- column++;
- cur_line += c;
- }
- }
- N6(stderr, "red");
- fprintf(stderr, "Error has occurred in file %s\n", C9.c_str());
- N6(stderr, "reset");
- if (fseek(fd, I1, SEEK_SET) == -1) {
- N6(stderr, "red");
- fprintf(stderr, "Error reading the file. Original error message: %s\n", message.c_str());
- N6(stderr, "reset");
- if (eee) {
- this->emergency_error_exit();
- }
- else {
- return;
- }
- };
- if (error_lines.size() == 0) {
- N6(stderr, "red");
- fprintf(stderr, "at positions %ld..%ld", ta.first_char, ta.last_char);
- N6(stderr, "reset");
- if (eee) {
- this->emergency_error_exit();
- }
- else {
- return;
- }
- }
- if (error_lines.size() == 1) {
- static char buf[256];
- int64_t prefix = sprintf(buf,
- "%ld:%ld..%ld | ",
- error_lines[0].first.second,
- ta.first_char - error_lines[0].first.first + 1,
- ta.last_char - 1 - error_lines[0].first.first + 1);
- fprintf(stderr, "%s%s\n", buf, error_lines[0].second.c_str());
- int64_t spaces = prefix + ta.first_char - error_lines[0].first.first;
- for (int64_t i = 0; i < spaces; i++) {
- fprintf(stderr, " ");
- }
- N6(stderr, "red");
- for (int64_t i = 0; i < ta.last_char - ta.first_char; i++) {
- fprintf(stderr, "^");
- }
- fprintf(stderr, "\n");
- for (int64_t i = 0; i < spaces; i++) {
- fprintf(stderr, " ");
- }
- fprintf(stderr, "|\n");
- for (int64_t i = 0; i < spaces; i++) {
- fprintf(stderr, " ");
- }
- fprintf(stderr, "+-- %s.\n", message.c_str());
- N6(stderr, "reset");
- if (eee) {
- this->emergency_error_exit();
- }
- else {
- return;
- }
- }
- static char buf_first[256];
- int64_t prefix_first = sprintf(buf_first,
- "%ld:%ld..%ld",
- error_lines.front().first.second,
- ta.first_char - error_lines[0].first.first + 1,
- error_lines.front().second.size());
- static char buf_last[256];
- int64_t prefix_last = sprintf(buf_last,
- "%ld:%ld..%ld",
- error_lines.back().first.second,
- 1l,
- ta.last_char - 1 - error_lines.back().first.first + 1);
- static char buf_mid[256];
- int64_t biggest_mid
- = (error_lines.size() > 2) ? sprintf(buf_mid, "%ld:entire line", error_lines.back().first.second) : 0;
- int64_t prefix = std::max(std::max(prefix_first, prefix_last), biggest_mid);
- int64_t spaces = prefix + 3;
- for (int64_t i = 0; i < spaces + ta.first_char - error_lines.front().first.first; i++) {
- fprintf(stderr, " ");
- }
- N6(stderr, "red");
- for (int64_t i = 0; i < error_lines.front().second.size() - (ta.first_char - error_lines.front().first.first);
- i++)
- {
- fprintf(stderr, "v");
- }
- fprintf(stderr, " --- error message is in the last line");
- N6(stderr, "reset");
- fprintf(stderr, "\n");
- fprintf(stderr, "%s", buf_first);
- for (int64_t i = prefix - prefix_first; i > 0; i--) {
- fprintf(stderr, " ");
- }
- fprintf(stderr, " | ");
- fprintf(stderr, "%s\n", error_lines.front().second.c_str());
- for (int64_t i = 1; i < error_lines.size() - 1; i++) {
- int64_t prefix_mid = sprintf(buf_mid, "%ld:entire line", error_lines[i].first.second);
- fprintf(stderr, "%s", buf_mid);
- for (int64_t i = prefix - prefix_mid; i > 0; i--) {
- fprintf(stderr, " ");
- }
- fprintf(stderr, " | ");
- fprintf(stderr, "%s\n", error_lines[i].second.c_str());
- }
- fprintf(stderr, "%s", buf_last);
- for (int64_t i = prefix - prefix_last; i > 0; i--) {
- fprintf(stderr, " ");
- }
- fprintf(stderr, " | ");
- fprintf(stderr, "%s\n", error_lines.back().second.c_str());
- spaces = prefix + 3;
- for (int64_t i = 0; i < spaces; i++) {
- fprintf(stderr, " ");
- }
- N6(stderr, "red");
- for (int64_t i = 0; i < ta.last_char - error_lines.back().first.first; i++) {
- fprintf(stderr, "^");
- }
- fprintf(stderr, "\n");
- for (int64_t i = 0; i < spaces; i++) {
- fprintf(stderr, " ");
- }
- fprintf(stderr, "|\n");
- for (int64_t i = 0; i < spaces; i++) {
- fprintf(stderr, " ");
- }
- fprintf(stderr, "+-- %s.\n", message.c_str());
- N6(stderr, "reset");
- if (eee) {
- this->emergency_error_exit();
- }
- else {
- return;
- }
- }
- void __assert__(bool N11,
- const char *assertion,
- const std::string &message,
- C4 *Z3,
- const char *C9,
- int line) {
- if (!N11) {
- static char buf[1024];
- sprintf(buf,
- "Assertion failed: %s. Happened in %s, line %d: %s\n",
- message.c_str(),
- C9,
- line,
- assertion);
- Z3->T4(std::string(buf));
- }
- }
- }
- namespace H10 {
- Scope::Scope(Scope *prev, Scope *W10, bool can_access_prev) {
- B2();
- this->prev = prev;
- this->W10 = W10;
- this->can_access_prev = can_access_prev;
- this->is_function_call = false;
- }
- Scope::~Scope() {
- B2();
- this->prev = nullptr;
- this->W10 = nullptr;
- this->can_access_prev = false;
- this->variables.clear();
- this->M7.clear();
- }
- Scope *Scope::getPrev() {
- return this->prev;
- }
- Scope *Scope::getMaster() {
- return this->W10;
- }
- std::vector<J10 *> &Scope::getArguments() {
- return this->M7;
- }
- bool Scope::canAccessPrev() {
- return this->can_access_prev;
- }
- bool Scope::isFunctionCall() {
- return this->is_function_call;
- }
- void Scope::setCanAccessPrev(bool N11) {
- this->can_access_prev = N11;
- }
- void Scope::setIsFunctionCall(bool N11) {
- this->is_function_call = N11;
- }
- void Scope::L5(I10 id, J10 *obj, K9 *rt) {
- B2();
- this->variables[id] = obj;
- obj->Y2();
- }
- J10 *Scope::getVariable(I10 id, K9 *rt) {
- B2();
- Scope *s = this;
- while (s != nullptr) {
- auto it = s->variables.find(id);
- if (it != s->variables.end()) {
- return it->second;
- }
- if (s->can_access_prev) {
- s = s->prev;
- }
- else {
- if (s == s->W10) {
- break;
- }
- else {
- s = s->W10;
- }
- }
- }
- rt->T4("Failed to find variable " + rt->S12->R7(id), rt->R5().area);
- }
- void Scope::removeVariable(I10 id, K9 *rt) {
- this->variables.erase(id);
- }
- bool Scope::queryVariable(I10 id, K9 *rt) {
- B2();
- Scope *s = this;
- while (s != nullptr) {
- auto it = s->variables.find(id);
- if (it != s->variables.end()) {
- return true;
- }
- if (s->can_access_prev) {
- s = s->prev;
- }
- else {
- if (s == s->W10) {
- break;
- }
- else {
- s = s->W10;
- }
- }
- }
- return false;
- }
- }
- namespace H10 {
- std::string const D4::failed = "[INVALID NAMEID]";
- I10 D4::Z11(const std::string &str) {
- B2();
- auto it = this->Q12.find(str);
- if (it != this->Q12.end()) {
- return it->second;
- }
- auto new_id = (I10)this->Q12.size() + 1;
- this->Q12[str] = new_id;
- this->Q12_reversed[new_id] = str;
- return new_id;
- }
- std::string const &D4::R7(I10 id) {
- B2();
- auto it = this->Q12_reversed.find(id);
- if (it == this->Q12_reversed.end()) {
- return this->failed;
- }
- return it->second;
- }
- bool D4::check(I10 id) {
- B2();
- auto it = this->Q12_reversed.find(id);
- return it != this->Q12_reversed.end();
- }
- };
- #include <cstdint>
- namespace H10 {
- int64_t J10::total_V10s = 0;
- J10::J10(bool is_H8, G8 *H8, I12 *type, K9 *rt) {
- B2();
- this->is_H8 = is_H8;
- this->H8 = H8;
- this->type = type;
- this->gc_mark = !rt->getGC()->gc_mark;
- this->id = ++total_V10s;
- this->can_modify = true;
- this->single_use = false;
- rt->getGC()->C12(this);
- }
- J10::~J10() {
- B2();
- this->H8 = nullptr;
- this->type = nullptr;
- total_V10s--;
- }
- std::vector<J10 *> J10::getGCReachable() {
- B2();
- std::vector<J10 *> res;
- if (this->H8 != nullptr) {
- for (auto &elem : this->H8->getGCReachable()) {
- res.push_back(elem);
- }
- }
- if (this->type != nullptr) {
- for (auto &elem : this->type->getGCReachable()) {
- res.push_back(elem);
- }
- }
- return res;
- }
- std::string J10::userRepr(K9 *rt) {
- B2();
- if (this == nullptr) {
- return std::string("J10(nullptr)");
- }
- if (this->H8 == nullptr) {
- return this->type->userRepr(rt);
- }
- return this->H8->userRepr(rt);
- }
- void J10::assignTo(J10 *obj, K9 *rt) {
- B2();
- if (!this->can_modify) {
- rt->T4("Cannot assign to " + this->userRepr(rt), rt->R5().area);
- }
- auto id = this->id;
- *this = *obj;
- this->id = id;
- this->Y2();
- }
- void J10::assignToCopyOf(J10 *obj, K9 *rt) {
- B2();
- if (!this->can_modify) {
- rt->T4("Cannot assign to " + this->userRepr(rt), rt->R5().area);
- }
- auto id = this->id;
- *this = *rt->copy(obj);
- this->id = id;
- this->Y2();
- }
- void J10::spreadSingleUse() {
- B2();
- this->single_use = true;
- if (this->H8 != nullptr) {
- this->H8->spreadSingleUse();
- }
- }
- void J10::Y2() {
- B2();
- this->single_use = false;
- if (this->H8 != nullptr) {
- this->H8->Y2();
- }
- }
- std::ostream &operator<<(std::ostream &stream, J10 *obj) {
- B2();
- if (obj == nullptr) {
- stream << "{nullptr}";
- return stream;
- }
- stream << "{" << (void *)obj << ", ";
- stream << (obj->is_H8 ? "I" : "T");
- stream << (obj->gc_mark ? "1" : "0");
- stream << (obj->gc_mark ? "W" : "R");
- stream << ", ins: " << obj->H8 << ", type: " << obj->type << "}";
- return stream;
- }
- }
- namespace H10 {
- int64_t G8::total_H8s = 0;
- J10 *H10::G8::selectField(I10 id, K9 *rt) {
- B2();
- rt->T4(this->userRepr(rt) + "doesn't have S11 " + rt->S12->R7(id), rt->R5().area);
- }
- bool G8::hasField(I10 id, K9 *rt) {
- B2();
- return false;
- }
- void G8::addField(I10 id, J10 *obj, K9 *rt) {
- B2();
- }
- G8::G8(K9 *rt, size_t bytes) {
- B2();
- this->gc_mark = !rt->getGC()->gc_mark;
- this->id = ++total_H8s;
- rt->getGC()->C12(this, bytes);
- }
- std::vector<J10 *> G8::getGCReachable() {
- B2();
- return {};
- }
- void G8::spreadSingleUse() {
- B2();
- }
- void G8::Y2() {
- B2();
- }
- };
- namespace H10 {
- O1::O1() {
- B2();
- this->M5 = 0;
- this->prev_M5 = NUM_TRACKED_INIT;
- this->B3 = 0;
- this->prev_B3 = SIZEOF_TRACKED_INIT;
- this->D10 = 0;
- }
- void O1::V1(J10 *V10) {
- B2();
- this->M5++;
- this->B3 += sizeof(J10);
- this->D10++;
- }
- void O1::V1(G8 *H8, size_t bytes) {
- B2();
- this->M5++;
- this->B3 += bytes;
- this->D10++;
- }
- void O1::V1(I12 *type) {
- B2();
- this->M5++;
- this->B3 += sizeof(I12); this->D10++;
- }
- void O1::G1(J10 *V10) {
- B2();
- this->M5--;
- this->B3 -= sizeof(J10);
- }
- void O1::G1(G8 *H8) {
- B2();
- this->M5--;
- this->B3 -= H8->getSize();
- }
- void O1::G1(I12 *type) {
- B2();
- this->M5--;
- this->B3 -= sizeof(I12);
- }
- void O1::P0(K9 *rt) {
- B2();
- this->prev_M5 = rt->getGC()->P1.size() + rt->getGC()->M2.size()
- + rt->getGC()->A4.size();
- this->prev_B3 = 0;
- for (auto &[obj, _] : rt->getGC()->M2) {
- this->prev_B3 += sizeof(obj);
- }
- for (auto &[ins, _] : rt->getGC()->P1) {
- this->prev_B3 += ins->getSize();
- }
- for (auto &[type, _] : rt->getGC()->A4) {
- this->prev_B3 += sizeof(type);
- }
- this->M5 = this->prev_M5;
- this->B3 = this->prev_B3;
- }
- void O1::F2(K9 *rt) {
- B2();
- this->L2(rt);
- }
- void O1::L2(K9 *rt) {
- B2();
- if (this->B3 >= MIN_CYCLE_SIZE
- && ((this->prev_M5 < this->M5 / NUM_TRACKED_K12)
- || (this->prev_B3 < this->B3 / SIZEOF_TRACKED_K12)
- || (this->D10 >= OPS_MOD)))
- {
- this->D10 %= OPS_MOD;
- rt->getGC()->runCycle(rt);
- }
- }
- GC::GC(P6 *gc_strategy) {
- B2();
- this->gc_strategy = gc_strategy;
- this->gc_mark = 1;
- this->enabled = true;
- }
- GC::~GC() {
- B2();
- for (auto &[obj, _] : this->M2) {
- delete (obj);
- }
- for (auto &[ins, _] : this->P1) {
- delete (ins);
- }
- for (auto &[type, _] : this->A4) {
- delete type;
- }
- }
- void GC::C12(J10 *V10) {
- B2();
- if (this->M2.find(V10) != this->M2.end()) {
- return;
- }
- this->M2[V10] = true;
- this->gc_strategy->V1(V10);
- }
- void GC::C12(G8 *H8, size_t bytes) {
- B2();
- if (this->P1.find(H8) != this->P1.end()) {
- return;
- }
- this->P1[H8] = true;
- this->gc_strategy->V1(H8, bytes);
- }
- void GC::C12(I12 *type) {
- B2();
- if (this->A4.find(type) != this->A4.end()) {
- return;
- }
- this->A4[type] = true;
- this->gc_strategy->V1(type);
- }
- void GC::E10(J10 *V10) {
- B2();
- auto it = this->M2.find(V10);
- if (it == this->M2.end()) {
- return;
- }
- this->M2.erase(V10);
- }
- void GC::E10(G8 *H8) {
- B2();
- auto it = this->P1.find(H8);
- if (it == this->P1.end()) {
- return;
- }
- this->P1.erase(H8);
- }
- void GC::E10(I12 *type) {
- B2();
- auto it = this->A4.find(type);
- if (it == this->A4.end()) {
- return;
- }
- this->A4.erase(type);
- }
- void GC::hold(J10 *V10) {
- B2();
- ++this->held_V10s[V10];
- }
- void GC::release(J10 *V10) {
- B2();
- if (--this->held_V10s[V10] <= 0) {
- this->held_V10s.erase(V10);
- }
- }
- void GC::ping(K9 *rt) {
- B2();
- this->gc_strategy->F2(rt);
- }
- static void mark(G8 *ins, K9 *rt);
- static void mark(I12 *type, K9 *rt);
- static void mark(J10 *obj, K9 *rt) {
- B2();
- if (obj == nullptr) {
- return;
- }
- if (obj->gc_mark == rt->getGC()->gc_mark) {
- return;
- }
- obj->gc_mark = rt->getGC()->gc_mark;
- for (auto &o : obj->getGCReachable()) {
- mark(o, rt);
- }
- mark(obj->H8, rt);
- mark(obj->type, rt);
- }
- static void mark(G8 *ins, K9 *rt) {
- B2();
- if (ins == nullptr) {
- return;
- }
- if (ins->gc_mark == rt->getGC()->gc_mark) {
- return;
- }
- ins->gc_mark = rt->getGC()->gc_mark;
- for (auto &o : ins->getGCReachable()) {
- mark(o, rt);
- }
- }
- static void mark(I12 *type, K9 *rt) {
- B2();
- if (type == nullptr) {
- return;
- }
- if (type->gc_mark == rt->getGC()->gc_mark) {
- return;
- }
- type->gc_mark = rt->getGC()->gc_mark;
- for (auto &o : type->getGCReachable()) {
- mark(o, rt);
- }
- }
- void GC::runCycle(K9 *rt) {
- B2();
- if (!this->enabled) {
- return;
- }
- auto X11 = rt->E9();
- while (X11 != nullptr) {
- for (auto &[_, obj] : X11->variables) {
- mark(obj, rt);
- }
- for (auto &obj : X11->M7) {
- mark(obj, rt);
- }
- X11 = X11->prev;
- }
- for (auto &[obj, _] : this->held_V10s) {
- mark(obj, rt);
- }
- for (auto &[_, obj] : rt->globals) {
- mark(obj, rt);
- }
- std::vector<J10 *> deleted_V10s;
- for (auto &[obj, _] : this->M2) {
- if (obj->gc_mark != this->gc_mark) {
- deleted_V10s.push_back(obj);
- }
- }
- for (auto &obj : deleted_V10s) {
- this->M2.erase(obj);
- delete (obj);
- }
- std::vector<G8 *> deleted_H8s;
- for (auto &[ins, _] : this->P1) {
- if (ins->gc_mark != this->gc_mark) {
- deleted_H8s.push_back(ins);
- }
- }
- for (auto &ins : deleted_H8s) {
- this->P1.erase(ins);
- delete (ins);
- }
- std::vector<I12 *> deleted_types;
- for (auto &[type, _] : this->A4) {
- if (type->gc_mark != this->gc_mark) {
- deleted_types.push_back(type);
- }
- }
- for (auto &type : deleted_types) {
- this->A4.erase(type);
- delete type;
- }
- this->gc_mark = !this->gc_mark;
- this->gc_strategy->P0(rt);
- }
- void GC::enable() {
- B2();
- this->enabled = true;
- }
- void GC::disable() {
- B2();
- this->enabled = false;
- }
- }
- namespace H10 {
- K9::K9(P6 *gc_strategy, C4 *Z3, D4 *S12)
- : S12(S12) {
- B2();
- this->X11 = new Scope(nullptr, nullptr, false);
- this->X11->W10 = this->X11;
- this->gc = new GC(gc_strategy);
- this->gc->rt = this;
- this->Z3 = Z3;
- this->S5();
- this->E3.function = new Z9::M4(this);
- this->E3.nothing = new Z9::K5(this);
- this->E3.boolean = new Z9::I5(this);
- this->E3.integer = new Z9::J5(this);
- this->E3.real = new Z9::D9(this);
- this->E3.character = new Z9::V3(this);
- this->E3.string = new Z9::J6(this);
- this->E3.array = new Z9::Q7(this);
- auto nothing_obj = this->make(this->E3.nothing, K9::TYPE_OBJECT);
- nothing_obj->can_modify = false;
- this->X11->L5(this->S12->Z11("Nothing"), nothing_obj, this);
- this->registerI12J10(this->E3.nothing, nothing_obj);
- auto function_obj = this->make(this->E3.function, K9::TYPE_OBJECT);
- function_obj->can_modify = false;
- this->X11->L5(this->S12->Z11("Function"), function_obj, this);
- this->registerI12J10(this->E3.function, function_obj);
- auto boolean_obj = this->make(this->E3.boolean, K9::TYPE_OBJECT);
- boolean_obj->can_modify = false;
- this->X11->L5(this->S12->Z11("Boolean"), boolean_obj, this);
- this->registerI12J10(this->E3.boolean, boolean_obj);
- auto integer_obj = this->make(this->E3.integer, K9::TYPE_OBJECT);
- integer_obj->can_modify = false;
- this->X11->L5(this->S12->Z11("Integer"), integer_obj, this);
- this->registerI12J10(this->E3.integer, integer_obj);
- auto real_obj = this->make(this->E3.real, K9::TYPE_OBJECT);
- real_obj->can_modify = false;
- this->X11->L5(this->S12->Z11("Real"), real_obj, this);
- this->registerI12J10(this->E3.real, real_obj);
- auto character_obj = this->make(this->E3.character, K9::TYPE_OBJECT);
- character_obj->can_modify = false;
- this->X11->L5(this->S12->Z11("P7"), character_obj, this);
- this->registerI12J10(this->E3.character, character_obj);
- auto string_obj = this->make(this->E3.string, K9::TYPE_OBJECT);
- string_obj->can_modify = false;
- this->X11->L5(this->S12->Z11("String"), string_obj, this);
- this->registerI12J10(this->E3.string, string_obj);
- auto array_obj = this->make(this->E3.array, K9::TYPE_OBJECT);
- array_obj->can_modify = false;
- this->X11->L5(this->S12->Z11("Array"), array_obj, this);
- this->registerI12J10(this->E3.array, array_obj);
- Z9::installBooleanMethods(this->E3.boolean, this);
- Z9::installP7Methods(this->E3.character, this);
- Z9::installFunctionMethods(this->E3.function, this);
- Z9::installIntegerMethods(this->E3.integer, this);
- Z9::installRealMethods(this->E3.real, this);
- Z9::installNothingMethods(this->E3.nothing, this);
- Z9::installStringMethods(this->E3.string, this);
- Z9::installArrayMethods(this->E3.array, this);
- Z9::installZ9Functions(this);
- this->protected_nothing = this->make(this->E3.nothing, K9::INSTANCE_OBJECT);
- this->protected_nothing->can_modify = false;
- this->gc->hold(this->protected_nothing);
- this->protected_nothing->Y2();
- this->protected_true = this->make(this->E3.boolean, K9::INSTANCE_OBJECT);
- Z9::getBooleanValue(this->protected_true, this) = true;
- this->protected_true->can_modify = false;
- this->gc->hold(this->protected_true);
- this->protected_true->Y2();
- this->protected_false = this->make(this->E3.boolean, K9::INSTANCE_OBJECT);
- Z9::getBooleanValue(this->protected_false, this) = false;
- this->protected_false->can_modify = false;
- this->gc->hold(this->protected_false);
- this->protected_true->Y2();
- }
- bool K9::checkGlobal(I10 id) {
- auto it = this->globals.find(id);
- return it != this->globals.end();
- }
- J10 *K9::getGlobal(I10 id) {
- B2();
- auto it = this->globals.find(id);
- if (it == this->globals.end()) {
- this->T4("Global not found: " + this->S12->R7(id), this->R5().area);
- }
- return it->second;
- }
- void K9::setGlobal(I10 id, J10 *obj) {
- B2();
- this->globals[id] = obj;
- }
- void K9::removeGlobal(I10 id) {
- B2();
- this->globals.erase(id);
- }
- void K9::registerI12J10(I12 *type, J10 *obj) {
- B2();
- this->registered_type_V10s[type] = obj;
- }
- J10 *K9::getI12J10(I12 *type) {
- B2();
- auto it = this->registered_type_V10s.find(type);
- if (it != this->registered_type_V10s.end()) {
- return it->second;
- }
- return this->protected_nothing;
- }
- J10 *K9::S1() {
- return this->protected_nothing;
- }
- J10 *K9::R1(bool val) {
- B2();
- return val ? this->protected_true : this->protected_false;
- }
- void K9::T3(bool can_access_prev_X11) {
- B2();
- auto X11 = new Scope(this->X11, this->X11->W10, can_access_prev_X11);
- this->X11 = X11;
- }
- void K9::S3() {
- B2();
- auto X11 = this->X11->prev;
- delete this->X11;
- this->X11 = X11;
- }
- J10 *K9::make(I12 *type, J10Options V10_opt) {
- B2();
- if (type == nullptr) {
- this->T4("Failed to make an V10 of nullptr type", this->R5().area);
- }
- J10 *obj = nullptr;
- if (V10_opt == K9::INSTANCE_OBJECT) {
- obj = type->create(this);
- }
- else {
- obj = new J10(false, nullptr, type, this);
- }
- if (obj == nullptr) {
- this->T4("Failed to make an V10 of type " + type->userRepr(this), this->R5().area);
- }
- obj->spreadSingleUse();
- return obj;
- }
- J10 *K9::copy(J10 *obj) {
- B2();
- if (!this->D3(obj)) {
- this->T4("Failed to copy non type V10 " + obj->userRepr(this), this->R5().area);
- }
- if (obj->single_use) {
- return obj;
- }
- auto res = obj->type->copy(obj, this);
- return res;
- }
- J10 *K9::H5(I4::D6 id, J10 *obj, bool I0) {
- B2();
- this->U0(obj, K9::SUB0_CTX);
- T0 op;
- switch (id) {
- case I4::U2 :
- op = obj->type->W6;
- if (op == nullptr) {
- this->T4(obj->userRepr(this) + " doesn't support that operator", this->R5().area);
- }
- return op(obj, this, I0);
- case I4::U1 :
- op = obj->type->X6;
- if (op == nullptr) {
- this->T4(obj->userRepr(this) + " doesn't support that operator", this->R5().area);
- }
- return op(obj, this, I0);
- case I4::M3 :
- op = obj->type->Y7;
- if (op == nullptr) {
- this->T4(obj->userRepr(this) + " doesn't support that operator", this->R5().area);
- }
- return op(obj, this, I0);
- case I4::D2 :
- op = obj->type->Z7;
- if (op == nullptr) {
- this->T4(obj->userRepr(this) + " doesn't support that operator", this->R5().area);
- }
- return op(obj, this, I0);
- case I4::T8 :
- op = obj->type->O5;
- if (op == nullptr) {
- this->T4(obj->userRepr(this) + " doesn't support that operator", this->R5().area);
- }
- return op(obj, this, I0);
- case I4::H7 :
- op = obj->type->P5;
- if (op == nullptr) {
- this->T4(obj->userRepr(this) + " doesn't support that operator", this->R5().area);
- }
- return op(obj, this, I0);
- case I4::NOT :
- op = obj->type->B11;
- if (op == nullptr) {
- this->T4(obj->userRepr(this) + " doesn't support that operator", this->R5().area);
- }
- return op(obj, this, I0);
- case I4::T9 :
- op = obj->type->Y6;
- if (op == nullptr) {
- this->T4(obj->userRepr(this) + " doesn't support that operator", this->R5().area);
- }
- return op(obj, this, I0);
- default : this->T4(obj->userRepr(this) + " doesn't support that operator", this->R5().area);
- }
- }
- J10 *K9::H5(I4::D6 id, J10 *obj, J10 *arg, bool I0) {
- B2();
- this->U0(obj, K9::SUB0_CTX);
- this->U0(arg, K9::SUB1_CTX);
- R0 op;
- switch (id) {
- case I4::K12 :
- op = obj->type->F10;
- if (op == nullptr) {
- this->T4("Left argument " + obj->userRepr(this) + " doesn't support that operator", this->R5().area);
- }
- return op(obj, arg, this, I0);
- case I4::DIV :
- op = obj->type->C11;
- if (op == nullptr) {
- this->T4("Left argument " + obj->userRepr(this) + " doesn't support that operator", this->R5().area);
- }
- return op(obj, arg, this, I0);
- case I4::REM :
- op = obj->type->D11;
- if (op == nullptr) {
- this->T4("Left argument " + obj->userRepr(this) + " doesn't support that operator", this->R5().area);
- }
- return op(obj, arg, this, I0);
- case I4::D5 :
- op = obj->type->A8;
- if (op == nullptr) {
- this->T4("Left argument " + obj->userRepr(this) + " doesn't support that operator", this->R5().area);
- }
- return op(obj, arg, this, I0);
- case I4::Z5 :
- op = obj->type->B8;
- if (op == nullptr) {
- this->T4("Left argument " + obj->userRepr(this) + " doesn't support that operator", this->R5().area);
- }
- return op(obj, arg, this, I0);
- case I4::L12 :
- op = obj->type->E11;
- if (op == nullptr) {
- this->T4("Left argument " + obj->userRepr(this) + " doesn't support that operator", this->R5().area);
- }
- return op(obj, arg, this, I0);
- case I4::U11 :
- op = obj->type->F11;
- if (op == nullptr) {
- this->T4("Left argument " + obj->userRepr(this) + " doesn't support that operator", this->R5().area);
- }
- return op(obj, arg, this, I0);
- case I4::M12 :
- op = obj->type->E12;
- if (op == nullptr) {
- this->T4("Left argument " + obj->userRepr(this) + " doesn't support that operator", this->R5().area);
- }
- return op(obj, arg, this, I0);
- case I4::A6 :
- op = obj->type->G11;
- if (op == nullptr) {
- this->T4("Left argument " + obj->userRepr(this) + " doesn't support that operator", this->R5().area);
- }
- return op(obj, arg, this, I0);
- case I4::U9 :
- op = obj->type->F12;
- if (op == nullptr) {
- this->T4("Left argument " + obj->userRepr(this) + " doesn't support that operator", this->R5().area);
- }
- return op(obj, arg, this, I0);
- case I4::N3 :
- op = obj->type->H11;
- if (op == nullptr) {
- this->T4("Left argument " + obj->userRepr(this) + " doesn't support that operator", this->R5().area);
- }
- return op(obj, arg, this, I0);
- case I4::V11 :
- op = obj->type->G12;
- if (op == nullptr) {
- this->T4("Left argument " + obj->userRepr(this) + " doesn't support that operator", this->R5().area);
- }
- return op(obj, arg, this, I0);
- case I4::I7 :
- op = obj->type->I11;
- if (op == nullptr) {
- this->T4("Left argument " + obj->userRepr(this) + " doesn't support that operator", this->R5().area);
- }
- return op(obj, arg, this, I0);
- case I4::S10 :
- op = obj->type->C8;
- if (op == nullptr) {
- this->T4("Left argument " + obj->userRepr(this) + " doesn't support that operator", this->R5().area);
- }
- return op(obj, arg, this, I0);
- case I4::T10 :
- op = obj->type->D8;
- if (op == nullptr) {
- this->T4("Left argument " + obj->userRepr(this) + " doesn't support that operator", this->R5().area);
- }
- return op(obj, arg, this, I0);
- case I4::W11 :
- op = obj->type->I9;
- if (op == nullptr) {
- this->T4("Left argument " + obj->userRepr(this) + " doesn't support that operator", this->R5().area);
- }
- return op(obj, arg, this, I0);
- case I4::AND :
- op = obj->type->J11;
- if (op == nullptr) {
- this->T4("Left argument " + obj->userRepr(this) + " doesn't support that operator", this->R5().area);
- }
- return op(obj, arg, this, I0);
- case I4::OR :
- op = obj->type->H12;
- if (op == nullptr) {
- this->T4("Left argument " + obj->userRepr(this) + " doesn't support that operator", this->R5().area);
- }
- return op(obj, arg, this, I0);
- default : this->T4("Left argument " + obj->userRepr(this) + " doesn't support that operator", this->R5().area);
- }
- }
- J10 *K9::H5(I4::D6 id, J10 *obj, const std::vector<J10 *> &args, bool I0) {
- B2();
- this->U0(obj, K9::SUB1_CTX);
- if (id == I4::J12) {
- auto op = obj->type->G10;
- if (op == nullptr) {
- this->T4("Left argument " + obj->userRepr(this) + " doesn't support that operator", this->R5().area);
- }
- return op(obj, args, this, I0);
- }
- else if (id == I4::T11) {
- auto op = obj->type->J9;
- if (op == nullptr) {
- this->T4("Left argument " + obj->userRepr(this) + " doesn't support that operator", this->R5().area);
- }
- return op(obj, args, this, I0);
- }
- else {
- this->T4("Left argument " + obj->userRepr(this) + " doesn't support that operator", this->R5().area);
- }
- }
- J10 *K9::O7(I10 id, J10 *obj, const std::vector<J10 *> &args, bool I0) {
- B2();
- auto R10 = obj->type->E8(id, this);
- return this->H5(I4::J12, R10, args, I0);
- }
- void K9::S5() {
- B2();
- this->error_contexts.push_back({});
- }
- void K9::T5() {
- B2();
- this->error_contexts.pop_back();
- }
- K9::ErrorContext &K9::R5() {
- B2();
- return this->error_contexts.back();
- }
- void K9::T4(const std::string &message, const S8 &ta) {
- B2();
- S8 prev;
- for (auto c : this->error_contexts) {
- if (c.area.first_char < c.area.last_char) {
- if (c.area.first_char == prev.first_char && c.area.last_char == prev.last_char) {
- continue;
- }
- if (c.area.first_char == ta.first_char && c.area.last_char == ta.last_char) {
- continue;
- }
- this->Z3->T4("Error occurred here", c.area, false);
- prev = c.area;
- }
- }
- this->Z3->T4(message, ta);
- }
- J10 *K9::execute(P8 *node, bool I0) {
- B2();
- if (node == nullptr) {
- this->T4("Failed to execute nullptr AST node", this->R5().area);
- }
- switch (node->id) {
- case P8::FUNCTION_DEFINITION : {
- return this->execute(node->func_def, I0);
- }
- case P8::W8INITION : {
- return this->execute(node->type_def, I0);
- }
- case P8::X8 : {
- return this->execute(node->op, I0);
- }
- case P8::ATOM : {
- return this->execute(node->R12, I0);
- }
- case P8::PARENTHESES_N12ESSION : {
- return this->execute(node->par_T12, I0);
- }
- default : this->T4("Failed to execute unknown AST node", this->R5().area);
- }
- }
- J10 *K9::execute(Z4 *node, bool I0) {
- B2();
- if (node == nullptr) {
- this->T4("Failed to execute unknown AST node", this->R5().area);
- }
- this->S5();
- this->R5().area = node->text_area;
- auto func = Z9::C0(false, nullptr, node, this);
- if (node->name != nullptr) {
- this->X11->W10->L5(node->name->Y10, func, this);
- }
- this->T5();
- this->W2();
- return func;
- }
- J10 *K9::execute(A5 *node, bool I0) {
- B2();
- if (node == nullptr) {
- this->T4("Failed to execute unknown AST node", this->R5().area);
- }
- this->S5();
- this->R5().area = node->text_area;
- auto type = new Z9::RecordI12(this);
- type->Y10 = node->name->Y10;
- for (auto f : node->Q10) {
- type->H8_Q10.push_back(this->S12->Z11(f->Q12));
- }
- for (auto R10 : node->S9) {
- this->S5();
- this->R5().area = R10->text_area;
- auto f = Z9::C0(false, nullptr, R10, this);
- type->S7(R10->name->Y10, f);
- this->T5();
- }
- auto res = this->make(type, K9::TYPE_OBJECT);
- this->X11->W10->L5(type->Y10, res, this);
- this->T5();
- this->W2();
- return res;
- }
- static std::vector<J10 *> getList(P8 *T12, K9 *rt) {
- B2();
- std::vector<J10 *> res;
- while (T12 != nullptr) {
- if (T12->id == P8::X8 && T12->op->id == I4::O11) {
- auto r = rt->execute(T12->op->first, true);
- if (rt->Q0()) {
- res.push_back(r);
- }
- else {
- rt->S5();
- rt->R5().area = T12->op->first->text_area;
- res.push_back(rt->copy(r));
- rt->T5();
- }
- rt->getGC()->hold(res.back());
- T12 = T12->op->second;
- }
- else {
- auto r = rt->execute(T12, true);
- if (rt->Q0()) {
- res.push_back(r);
- }
- else {
- rt->S5();
- rt->R5().area = T12->text_area;
- res.push_back(rt->copy(r));
- rt->T5();
- }
- rt->getGC()->hold(res.back());
- break;
- }
- }
- return res;
- }
- static void getList_addToContext(P8 *T12, K9 *rt) {
- B2();
- while (T12 != nullptr) {
- if (T12->id == P8::X8 && T12->op->id == I4::O11) {
- rt->R5().sub_areas.push_back(T12->op->first->text_area);
- T12 = T12->op->second;
- }
- else {
- rt->R5().sub_areas.push_back(T12->text_area);
- break;
- }
- }
- }
- J10 *K9::execute(I4 *node, bool I0) {
- B2();
- if (node == nullptr) {
- this->T4("Failed to execute unknown AST node", this->R5().area);
- }
- this->S5();
- this->R5().area = node->text_area;
- if (node->id == I4::U10) {
- if (node->first->id == P8::ATOM && node->first->R12->id == Q8::X5) {
- if (!this->X11->queryVariable(node->first->R12->Y11->Y10, this)) {
- this->X11->L5(node->first->R12->Y11->Y10, Z9::H0(this), this);
- }
- }
- }
- else if (node->id == I4::O11) {
- auto res = this->execute(node->first, I0);
- this->gc->hold(res);
- auto T12 = node->second;
- while (T12 != nullptr) {
- if (T12->id == P8::X8 && T12->op->id == I4::O11) {
- auto r = this->execute(T12->op->first, false);
- T12 = T12->op->second;
- }
- else {
- auto r = this->execute(T12, false);
- break;
- }
- }
- this->T5();
- this->gc->release(res);
- return res;
- }
- else if (node->id == I4::J12 || node->id == I4::T11) {
- if (node->id == I4::J12 && node->first->id == P8::X8 && node->first->op->id == I4::DOT) {
- auto X10 = this->execute(node->first->op->first, true);
- this->gc->hold(X10);
- J10 *selected = nullptr;
- auto dot = node->first->op;
- if (dot->second == nullptr || dot->second->id != P8::ATOM || dot->second->R12->id != Q8::X5) {
- this->T4("Selector is illegal", dot->second->text_area);
- }
- I10 B9 = dot->second->R12->Y11->Y10;
- if (!this->Q1(X10, nullptr)) {
- this->T4(X10->userRepr(this) + " must be an H8 V10", dot->first->text_area);
- }
- if (X10->H8->hasField(B9, this)) {
- selected = X10->H8->selectField(B9, this);
- }
- else if (X10->type->A7(B9)) {
- selected = X10->type->E8(B9, this);
- }
- else {
- this->T4("Invalid B9", dot->second->text_area);
- }
- std::vector<J10 *> args;
- auto list = getList(node->second, this);
- args.reserve(1 + list.size());
- args.push_back(X10);
- for (auto r : list) {
- args.push_back(r);
- }
- this->S5();
- this->R5().area = node->text_area;
- this->R5().sub_areas.push_back(dot->text_area); getList_addToContext(node->second, this);
- auto res = this->H5(node->id, selected, args, I0);
- this->T5();
- this->W2();
- this->T5();
- for (auto &item : list) {
- this->gc->release(item);
- }
- this->gc->release(X10);
- return res;
- }
- else {
- J10 *self = this->execute(node->first, true);
- this->gc->hold(self);
- std::vector<J10 *> args;
- auto list = getList(node->second, this);
- args.reserve(list.size());
- for (auto r : list) {
- args.push_back(r);
- }
- this->S5();
- this->R5().area = node->text_area;
- this->R5().sub_areas.push_back(node->first->text_area); getList_addToContext(node->second, this);
- auto res = this->H5(node->id, self, args, I0);
- this->T5();
- this->W2();
- this->T5();
- for (auto &item : list) {
- this->gc->release(item);
- }
- this->gc->release(self);
- return res;
- }
- }
- J10 *self = this->execute(node->first, true);
- this->gc->hold(self);
- J10 *other = nullptr;
- switch (node->id) {
- case I4::DOT : {
- if (node->second == nullptr || node->second->id != P8::ATOM || node->second->R12->id != Q8::X5) {
- this->T4("Selector is illegal", node->second->text_area);
- }
- I10 B9 = node->second->R12->Y11->Y10;
- if (!Q1(self)) {
- this->T4(self->userRepr(this) + " must be an H8 V10", node->first->text_area);
- }
- if (self->H8->hasField(B9, this)) {
- auto res = self->H8->selectField(B9, this);
- this->W2();
- this->T5();
- this->gc->release(self);
- return res;
- }
- else if (self->type->A7(B9)) {
- auto res = self->type->E8(B9, this);
- this->W2();
- this->T5();
- this->gc->release(self);
- return res;
- }
- else {
- this->T4("Invalid B9", node->second->text_area);
- }
- }
- case I4::AT : {
- this->W2();
- this->N0();
- this->T5();
- this->gc->release(self);
- return self;
- }
- case I4::U10 : {
- other = this->execute(node->second, true);
- if (this->Q0()) {
- self->assignTo(other, this);
- }
- else {
- self->assignToCopyOf(other, this);
- }
- this->W2();
- this->T5();
- this->gc->release(self);
- return self;
- }
- case I4::E5 : {
- other = this->execute(node->second, true);
- this->R5().sub_areas.push_back(node->first->text_area);
- this->R5().sub_areas.push_back(node->second->text_area);
- self->assignToCopyOf(this->H5(I4::L12, self, other, true), this);
- this->W2();
- this->T5();
- this->gc->release(self);
- return self;
- }
- case I4::J4 : {
- other = this->execute(node->second, true);
- this->R5().sub_areas.push_back(node->first->text_area);
- this->R5().sub_areas.push_back(node->second->text_area);
- self->assignToCopyOf(this->H5(I4::U11, self, other, true), this);
- this->W2();
- this->T5();
- this->gc->release(self);
- return self;
- }
- case I4::F5 : {
- other = this->execute(node->second, true);
- this->R5().sub_areas.push_back(node->first->text_area);
- this->R5().sub_areas.push_back(node->second->text_area);
- self->assignToCopyOf(this->H5(I4::K12, self, other, true), this);
- this->W2();
- this->T5();
- this->gc->release(self);
- return self;
- }
- case I4::B6 : {
- other = this->execute(node->second, true);
- this->R5().sub_areas.push_back(node->first->text_area);
- this->R5().sub_areas.push_back(node->second->text_area);
- self->assignToCopyOf(this->H5(I4::DIV, self, other, true), this);
- this->W2();
- this->T5();
- this->gc->release(self);
- return self;
- }
- case I4::C6 : {
- other = this->execute(node->second, true);
- this->R5().sub_areas.push_back(node->first->text_area);
- this->R5().sub_areas.push_back(node->second->text_area);
- self->assignToCopyOf(this->H5(I4::REM, self, other, true), this);
- this->W2();
- this->T5();
- this->gc->release(self);
- return self;
- }
- }
- switch (node->id) {
- case I4::U2 :
- case I4::U1 :
- case I4::M3 :
- case I4::D2 :
- case I4::T8 :
- case I4::H7 :
- case I4::NOT :
- case I4::T9 :
- this->R5().sub_areas.push_back(node->first->text_area);
- auto res = this->H5(node->id, self, I0);
- this->W2();
- this->T5();
- this->gc->release(self);
- return res;
- }
- auto arg = this->execute(node->second, true);
- this->R5().sub_areas.push_back(node->first->text_area);
- this->R5().sub_areas.push_back(node->second->text_area);
- auto res = this->H5(node->id, self, arg, I0);
- this->W2();
- this->T5();
- this->gc->release(self);
- return res;
- }
- J10 *K9::execute(Q8 *node, bool I0) {
- B2();
- if (node == nullptr) {
- this->T4("Failed to execute unknown AST node", this->R5().area);
- }
- this->S5();
- this->R5().area = node->text_area;
- Z6<I10, J10 *>::point_iterator it;
- switch (node->id) {
- case Q8::BOOLEAN : {
- if (!I0) {
- this->W2();
- this->T5();
- return nullptr;
- }
- if (node->lit_obj != nullptr) {
- this->W2();
- this->T5();
- return node->lit_obj;
- }
- it = this->readonly_literals.find(node->L11->Y10);
- if (it != this->readonly_literals.end()) {
- this->W2();
- this->T5();
- return it->second;
- }
- auto lit = Z9::F0(node->bool_N11, this);
- this->gc->hold(lit);
- lit->can_modify = false;
- this->readonly_literals[node->L11->Y10] = lit;
- lit->Y2();
- this->W2();
- this->T5();
- return node->lit_obj = lit;
- }
- case Q8::CHARACTER : {
- if (!I0) {
- this->W2();
- this->T5();
- return nullptr;
- }
- if (node->lit_obj != nullptr) {
- this->W2();
- this->T5();
- return node->lit_obj;
- }
- it = this->readonly_literals.find(node->L11->Y10);
- if (it != this->readonly_literals.end()) {
- this->W2();
- this->T5();
- return node->lit_obj = it->second;
- ;
- }
- auto lit = Z9::B0(node->char_N11, this);
- this->gc->hold(lit);
- lit->can_modify = false;
- this->readonly_literals[node->L11->Y10] = lit;
- lit->Y2();
- this->W2();
- this->T5();
- return node->lit_obj = lit;
- }
- case Q8::INTEGER : {
- if (!I0) {
- this->W2();
- this->T5();
- return nullptr;
- }
- if (node->lit_obj != nullptr) {
- this->W2();
- this->T5();
- return node->lit_obj;
- }
- it = this->readonly_literals.find(node->L11->Y10);
- if (it != this->readonly_literals.end()) {
- this->W2();
- this->T5();
- return node->lit_obj = it->second;
- ;
- }
- auto lit = Z9::G0(node->int_N11, this);
- this->gc->hold(lit);
- lit->can_modify = false;
- this->readonly_literals[node->L11->Y10] = lit;
- lit->Y2();
- this->W2();
- this->T5();
- return node->lit_obj = lit;
- }
- case Q8::REAL : {
- if (!I0) {
- this->W2();
- this->T5();
- return nullptr;
- }
- if (node->lit_obj != nullptr) {
- this->W2();
- this->T5();
- return node->lit_obj;
- }
- it = this->readonly_literals.find(node->L11->Y10);
- if (it != this->readonly_literals.end()) {
- this->W2();
- this->T5();
- return node->lit_obj = it->second;
- }
- auto lit = Z9::makeL4J10(node->real_N11, this);
- this->gc->hold(lit);
- lit->can_modify = false;
- this->readonly_literals[node->L11->Y10] = lit;
- lit->Y2();
- this->W2();
- this->T5();
- return node->lit_obj = lit;
- }
- case Q8::STRING : {
- if (!I0) {
- this->W2();
- this->T5();
- return nullptr;
- }
- if (node->lit_obj != nullptr) {
- this->W2();
- this->T5();
- return node->lit_obj;
- }
- it = this->readonly_literals.find(node->L11->Y10);
- if (it != this->readonly_literals.end()) {
- this->W2();
- this->T5();
- return node->lit_obj = it->second;
- ;
- }
- auto lit = Z9::J0(node->string_N11, this);
- this->gc->hold(lit);
- lit->can_modify = false;
- this->readonly_literals[node->L11->Y10] = lit;
- lit->Y2();
- this->W2();
- this->T5();
- return node->lit_obj = lit;
- }
- case Q8::NOTHING : {
- if (!I0) {
- this->W2();
- this->T5();
- return nullptr;
- }
- if (node->lit_obj != nullptr) {
- this->W2();
- this->T5();
- return node->lit_obj;
- }
- it = this->readonly_literals.find(node->L11->Y10);
- if (it != this->readonly_literals.end()) {
- this->W2();
- this->T5();
- return node->lit_obj = it->second;
- ;
- }
- auto lit = Z9::H0(this);
- this->gc->hold(lit);
- lit->can_modify = false;
- this->readonly_literals[node->L11->Y10] = lit;
- lit->Y2();
- this->W2();
- this->T5();
- return node->lit_obj = lit;
- }
- case Q8::X5 : {
- this->W2();
- auto res = this->X11->getVariable(node->L11->Y10, this);
- this->T5();
- return res;
- }
- default : this->T4("Unknown R12", this->R5().area);
- }
- }
- J10 *K9::execute(B5 *node, bool I0) {
- B2();
- if (node == nullptr) {
- this->T4("Failed to execute unknown AST node", this->R5().area);
- }
- return this->execute(node->T12, I0);
- }
- J10 *K9::execute(R8 *node, bool I0) {
- B2();
- if (node == nullptr) {
- this->T4("Failed to execute unknown AST node", this->R5().area);
- }
- this->gc->ping(this);
- switch (node->id) {
- case R8::WHILE : {
- return this->execute(node->L6, I0);
- }
- case R8::FOR : {
- return this->execute(node->F9, I0);
- }
- case R8::IF : {
- return this->execute(node->C10, I0);
- }
- case R8::H9 : {
- this->W2();
- this->A1();
- return this->protected_nothing;
- }
- case R8::D12 : {
- this->W2();
- this->W1();
- return this->protected_nothing;
- }
- case R8::A11 : {
- return this->execute(node->return_stmt, I0);
- }
- case R8::BLOCK : {
- return this->execute(node->M6, I0);
- }
- case R8::N12 : {
- return this->execute(node->T12, I0);
- }
- default : {
- this->T4("Unknown node", node->text_area);
- }
- }
- }
- J10 *K9::execute(K3 *node, bool I0) {
- B2();
- if (node == nullptr) {
- this->T4("Failed to execute unknown AST node", this->R5().area);
- }
- this->S5();
- while (true) {
- this->R5().area = node->text_area;
- this->T3();
- if (node->cond != nullptr) {
- this->R5().area = node->cond->text_area;
- auto cond = this->execute(node->cond, true);
- if (!Z9::getBooleanValue(cond, this)) {
- this->S3();
- break;
- }
- }
- if (node->body != nullptr) {
- this->R5().area = node->body->text_area;
- auto body = this->execute(node->body, I0);
- if (this->H2()) {
- this->S3();
- break;
- }
- else if (this->H1()) {
- this->S3();
- continue;
- }
- else if (this->X1()) {
- if (this->Q0()) {
- this->W2();
- this->K1();
- this->S3();
- this->T5();
- return body;
- }
- this->W2();
- this->K1();
- this->S3();
- this->T5();
- return (I0) ? this->copy(body) : nullptr;
- };
- }
- this->S3();
- }
- this->W2();
- this->T5();
- return this->protected_nothing;
- }
- J10 *K9::execute(C5 *node, bool I0) {
- B2();
- if (node == nullptr) {
- this->T4("Failed to execute unknown AST node", this->R5().area);
- }
- this->T3();
- if (node->init != nullptr) {
- this->execute(node->init, false);
- }
- this->S5();
- bool first_cycle = true;
- while (true) {
- if (!first_cycle) {
- if (node->step != nullptr) {
- this->R5().area = node->step->text_area;
- this->execute(node->step, false);
- }
- }
- if (first_cycle) {
- first_cycle = false;
- }
- this->R5().area = node->text_area;
- this->T3();
- if (node->cond != nullptr) {
- this->R5().area = node->cond->text_area;
- auto cond = this->execute(node->cond, true);
- if (!Z9::getBooleanValue(cond, this)) {
- this->S3();
- break;
- }
- }
- if (node->body != nullptr) {
- this->R5().area = node->body->text_area;
- auto body = this->execute(node->body, I0);
- if (this->H2()) {
- this->S3();
- break;
- }
- else if (this->H1()) {
- this->S3();
- continue;
- }
- else if (this->X1()) {
- if (this->Q0()) {
- this->W2();
- this->K1();
- this->S3();
- this->S3();
- this->T5();
- return body;
- }
- this->W2();
- this->K1();
- this->S3();
- this->S3();
- this->T5();
- return (I0) ? this->copy(body) : nullptr;
- };
- }
- this->S3();
- }
- this->W2();
- this->T5();
- this->S3();
- return this->protected_nothing;
- }
- J10 *K9::execute(Y5 *node, bool I0) {
- B2();
- if (node == nullptr) {
- this->T4("Failed to execute unknown AST node", this->R5().area);
- }
- this->S5();
- this->R5().area = node->cond->text_area;
- auto cond = this->execute(node->cond, true);
- if (Z9::getBooleanValue(cond, this)) {
- this->T5();
- return this->execute(node->body, I0);
- }
- else if (node->else_body != nullptr) {
- this->T5();
- return this->execute(node->else_body, I0);
- }
- this->W2();
- this->T5();
- return this->protected_nothing;
- }
- J10 *K9::execute(T2 *node, bool I0) {
- B2();
- if (node == nullptr) {
- this->T4("Failed to execute unknown AST node", this->R5().area);
- }
- this->S5();
- this->R5().area = node->text_area;
- if (node->N11 == nullptr) {
- this->W2();
- this->K1();
- this->T5();
- return this->S1();
- }
- auto res = this->execute(node->N11, I0);
- if (this->Q0()) {
- this->W2();
- this->K1();
- this->T5();
- return res;
- }
- this->W2();
- this->K1();
- this->T5();
- return (I0) ? this->copy(res) : nullptr;
- }
- J10 *K9::execute(L3 *node, bool I0) {
- B2();
- if (node == nullptr) {
- this->T4("Failed to execute unknown AST node", this->R5().area);
- }
- this->S5();
- this->R5().area = node->text_area;
- if (!node->is_unX11d) {
- this->T3(true);
- }
- J10 *res = nullptr;
- for (auto stmt : node->list) {
- if (stmt == nullptr) {
- continue;
- }
- res = this->execute(stmt, I0);
- if (!this->X2()) {
- if (!node->is_unX11d) {
- this->S3();
- }
- this->T5();
- return res;
- }
- }
- if (!node->is_unX11d) {
- this->S3();
- }
- this->W2();
- this->T5();
- return (res != nullptr) ? res : this->protected_nothing;
- }
- bool K9::D3(J10 *obj) {
- B2();
- return obj != nullptr && obj->type != nullptr;
- }
- bool K9::B4(J10 *obj, I12 *type) {
- B2();
- if (type == nullptr) {
- return obj != nullptr && obj->type != nullptr && obj->H8 == nullptr;
- }
- return obj != nullptr && obj->type == type && obj->H8 == nullptr;
- }
- bool K9::Q1(J10 *obj, I12 *type) {
- B2();
- if (type == nullptr) {
- return obj != nullptr && obj->type != nullptr && obj->H8 != nullptr;
- }
- return obj != nullptr && obj->type == type && obj->H8 != nullptr;
- }
- bool K9::F8(J10 *obj, I12 *type) {
- B2();
- return obj != nullptr && obj->type == type;
- }
- S8 &K9::getS8(ContextId ctx_id) {
- if (ctx_id == K9::AREA_CTX) {
- return this->R5().area;
- }
- return this->R5().sub_areas[(int)ctx_id];
- }
- void K9::U0(J10 *obj, K9::ContextId ctx_id) {
- B2();
- if (!this->D3(obj)) {
- this->T4("Not a valid V10: " + obj->userRepr(this), this->getS8(ctx_id));
- }
- }
- void K9::D1(J10 *obj, I12 *type, K9::ContextId ctx_id) {
- B2();
- if (!this->B4(obj, type)) {
- if (type == nullptr) {
- this->T4("Not a type V10: " + obj->userRepr(this), this->getS8(ctx_id));
- }
- else {
- this->T4("Not a type V10 of type " + type->userRepr(this) + ": " + obj->userRepr(this), this->getS8(ctx_id));
- }
- }
- }
- void K9::M0(J10 *obj, I12 *type, K9::ContextId ctx_id) {
- B2();
- if (!this->Q1(obj, type)) {
- if (type == nullptr) {
- this->T4("Not an H8 V10: " + obj->userRepr(this), this->getS8(ctx_id));
- }
- else {
- this->T4("Not an H8 V10 of type " + type->userRepr(this) + ": " + obj->userRepr(this),
- this->getS8(ctx_id));
- }
- }
- }
- void K9::O2(J10 *obj, I12 *type, K9::ContextId ctx_id) {
- B2();
- if (!this->F8(obj, type)) {
- this->T4(obj->userRepr(this) + " is not of type " + type->userRepr(this), this->getS8(ctx_id));
- }
- }
- void K9::K0(const std::vector<J10 *> &args, int64_t amount, K9::ContextId ctx_id) {
- B2();
- if (args.size() < amount) {
- this->T4("Expected at least " + std::to_string(amount) + " M7, got " + std::to_string(args.size()),
- this->getS8(ctx_id));
- }
- }
- void K9::D0(const std::vector<J10 *> &args, int64_t amount, K9::ContextId ctx_id) {
- B2();
- if (args.size() != amount) {
- this->T4("Expected exactly " + std::to_string(amount) + " M7, got " + std::to_string(args.size()),
- this->getS8(ctx_id));
- }
- }
- void K9::E0(const std::vector<J10 *> &args, int64_t amount, K9::ContextId ctx_id) {
- B2();
- if (args.size() < amount + 1) {
- this->T4("Expected at least " + std::to_string(amount) + " M7, got " + std::to_string((int64_t)args.size() - 1),
- this->getS8(ctx_id));
- }
- }
- void K9::A0(const std::vector<J10 *> &args, int64_t amount, K9::ContextId ctx_id) {
- B2();
- if (args.size() != amount + 1) {
- this->T4("Expected exactly " + std::to_string(amount) + " M7, got " + std::to_string((int64_t)args.size() - 1),
- this->getS8(ctx_id));
- }
- }
- void K9::A2(J10 *obj, I10 id, K9::ContextId ctx_id) {
- B2();
- this->U0(obj, ctx_id);
- if (!obj->type->A7(id)) {
- this->T4(obj->userRepr(this) + " doesn't have R10 " + this->S12->R7(id), this->getS8(ctx_id));
- }
- }
- GC *K9::getGC() {
- return this->gc;
- }
- C4 *K9::getC4() {
- return this->Z3;
- }
- Scope *K9::E9() {
- return this->X11;
- }
- void K9::W2() {
- this->N2 = C3::U12;
- }
- void K9::A1() {
- this->N2 |= C3::H9;
- }
- void K9::W1() {
- this->N2 |= C3::D12;
- }
- void K9::K1() {
- this->N2 |= C3::A11;
- }
- void K9::N0() {
- this->N2 |= C3::N5;
- }
- bool K9::X2() {
- return this->N2 == C3::U12;
- }
- bool K9::H1() {
- return this->N2 & C3::H9;
- }
- bool K9::H2() {
- return this->N2 & C3::D12;
- }
- bool K9::X1() {
- return this->N2 & C3::A11;
- }
- bool K9::Q0() {
- return this->N2 & C3::N5;
- }
- namespace N4 {
- I10 Q6(K9 *rt) {
- B2();
- return rt->S12->Z11("__make__");
- }
- I10 R6(K9 *rt) {
- B2();
- return rt->S12->Z11("__copy__");
- }
- I10 S6(K9 *rt) {
- B2();
- return rt->S12->Z11("__bool__");
- }
- I10 T6(K9 *rt) {
- B2();
- return rt->S12->Z11("__char__");
- }
- I10 W7(K9 *rt) {
- B2();
- return rt->S12->Z11("__int__");
- }
- I10 mm__real__(K9 *rt) {
- B2();
- return rt->S12->Z11("__real__");
- }
- I10 S4(K9 *rt) {
- B2();
- return rt->S12->Z11("__string__");
- }
- I10 U6(K9 *rt) {
- B2();
- return rt->S12->Z11("__repr__");
- }
- I10 V6(K9 *rt) {
- B2();
- return rt->S12->Z11("__read__");
- }
- I10 mm__get_iterator__(K9 *rt) {
- B2();
- return rt->S12->Z11("__get_iterator__");
- }
- I10 mm__deref_iterator__(K9 *rt) {
- B2();
- return rt->S12->Z11("__deref_iterator__");
- }
- I10 mm__next_iterator__(K9 *rt) {
- B2();
- return rt->S12->Z11("__next_iterator__");
- }
- I10 mm__is_last_iterator__(K9 *rt) {
- B2();
- return rt->S12->Z11("__is_last_iterator__");
- }
- }
- }
- #include <string>
- #include <vector>
- namespace H10 {
- int64_t I12::total_types = 0;
- I12::I12(K9 *rt) {
- B2();
- this->id = ++I12::total_types;
- W6 = X6 = Y7 = Z7 = O5 = P5 = B11 = Y6 = nullptr;
- F10 = C11 = D11 = A8 = B8 = E11 = F11 = E12 = G11 = F12 = H11 = G12
- = I11 = C8 = D8 = I9 = J11 = H12 = nullptr;
- G10 = J9 = nullptr;
- this->gc_mark = !rt->getGC()->gc_mark;
- rt->getGC()->C12(this);
- }
- I12::~I12() {
- B2();
- this->id = -1;
- W6 = X6 = Y7 = Z7 = O5 = P5 = B11 = Y6 = nullptr;
- F10 = C11 = D11 = A8 = B8 = E11 = F11 = E12 = G11 = F12 = H11 = G12
- = I11 = C8 = D8 = I9 = J11 = H12 = nullptr;
- G10 = J9 = nullptr;
- }
- void I12::S7(I10 id, J10 *R10) {
- B2();
- this->S9[id] = R10;
- }
- J10 *I12::E8(I10 id, K9 *rt) {
- B2();
- auto it = this->S9.find(id);
- if (it != this->S9.end()) {
- rt->U0(it->second);
- return it->second;
- }
- rt->T4(this->userRepr(rt) + " doesn't have R10 " + rt->S12->R7(id), rt->R5().area);
- }
- bool I12::A7(I10 id) {
- B2();
- auto it = this->S9.find(id);
- return it != this->S9.end();
- }
- std::vector<J10 *> I12::getGCReachable() {
- B2();
- std::vector<J10 *> res;
- for (auto &elem : this->S9) {
- res.push_back(elem.second);
- }
- return res;
- }
- };
- #include <unordered_map>
- #include <vector>
- #include <algorithm>
- #include <iostream>
- namespace H10::Profiler {
- std::unordered_map<const char *, int> captures;
- void capture(const char *name) {
- captures[name]++;
- }
- void printResult() {
- std::vector<std::pair<int, const char *>> res;
- for (auto [name, num]: captures) res.push_back({num, name});
- std::sort(res.begin(), res.end(), std::less<std::pair<int, const char*>>());
- for (auto [num, name]: res) {
- std::cout << num << ": " << name << "\n";
- }
- }
- }
- #include <cstdlib>
- #include <dlfcn.h>
- #include <filesystem>
- #include <unistd.h>
- namespace H10::Z9 {
- static J10 *CF_make(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->D0(args, 1);
- auto arg = args[0];
- rt->D1(arg, nullptr, K9::SUB1_CTX);
- auto res = rt->make(arg->type, K9::INSTANCE_OBJECT);
- if (rt->D3(res) && res->type->A7(N4::Q6(rt))) {
- return rt->O7(N4::Q6(rt), res, {res}, true);
- }
- return res;
- }
- static J10 *CF_copy(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->D0(args, 1);
- auto arg = args[0];
- rt->U0(arg, K9::SUB1_CTX);
- if (arg->type->A7(N4::R6(rt))) {
- return rt->O7(N4::R6(rt), arg, {arg}, true);
- }
- return rt->copy(args[0]);
- }
- static J10 *CF_bool(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->D0(args, 1);
- auto arg = args[0];
- rt->U0(arg, K9::SUB1_CTX);
- rt->A2(arg, N4::S6(rt), K9::SUB1_CTX);
- return rt->O7(N4::S6(rt), arg, {arg}, I0);
- }
- static J10 *CF_char(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->D0(args, 1);
- auto arg = args[0];
- rt->U0(arg, K9::SUB1_CTX);
- rt->A2(arg, N4::T6(rt), K9::SUB1_CTX);
- return rt->O7(N4::T6(rt), arg, {arg}, I0);
- }
- static J10 *CF_int(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->D0(args, 1);
- auto arg = args[0];
- rt->U0(arg, K9::SUB1_CTX);
- rt->A2(arg, N4::W7(rt), K9::SUB1_CTX);
- return rt->O7(N4::W7(rt), arg, {arg}, I0);
- }
- static J10 *CF_real(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->D0(args, 1);
- auto arg = args[0];
- rt->U0(arg, K9::SUB1_CTX);
- rt->A2(arg, N4::mm__real__(rt), K9::SUB1_CTX);
- return rt->O7(N4::mm__real__(rt), arg, {arg}, I0);
- }
- static J10 *CF_string(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->D0(args, 1);
- auto arg = args[0];
- rt->U0(arg, K9::SUB1_CTX);
- rt->A2(arg, N4::S4(rt), K9::SUB1_CTX);
- return rt->O7(N4::S4(rt), arg, {arg}, I0);
- }
- static J10 *CF_printraw(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- int64_t index = 0;
- for (auto arg : args) {
- index++;
- rt->U0(arg, (K9::ContextId)index);
- if (rt->Q1(arg, rt->E3.string)) {
- std::cout << L1(arg);
- continue;
- }
- rt->A2(arg, N4::S4(rt), (K9::ContextId)index);
- auto &ta = rt->R5().sub_areas[index];
- rt->S5();
- rt->R5().area = ta;
- rt->R5().sub_areas = {ta, ta};
- auto res = rt->O7(N4::S4(rt), arg, {arg}, true);
- CF_printraw({res}, rt, false);
- rt->T5();
- }
- return rt->S1();
- }
- static J10 *CF_print(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- bool f = false;
- int64_t index = 0;
- for (auto arg : args) {
- index++;
- if (f) {
- std::cout << " ";
- }
- f = true;
- auto &ata = rt->R5().area;
- auto &fta = rt->R5().sub_areas[0];
- auto &ita = rt->R5().sub_areas[index];
- rt->S5();
- rt->R5().area = ata;
- rt->R5().sub_areas = {fta, ita};
- CF_printraw({arg}, rt, false);
- rt->T5();
- }
- return rt->S1();
- }
- static J10 *CF_printf(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->K0(args, 1);
- auto fmt = args[0];
- rt->M0(fmt, rt->E3.string);
- auto fmtstr = L1(fmt);
- std::string res;
- auto it = fmtstr.begin();
- while (it != fmtstr.end()) {
- if (*it == '@') {
- if (next(it) == fmtstr.end()) {
- res += *it;
- it++;
- break;
- }
- else {
- if (*next(it) == '@') {
- res += "@";
- it++;
- it++;
- continue;
- }
- else {
- if (*next(it) == '{') {
- it++;
- it++;
- int64_t pos = 0;
- while (true) {
- if (it == fmtstr.end()) {
- rt->T4("Invalid string format: expected a valid @{..} construct",
- rt->getS8(K9::AREA_CTX));
- }
- else if ('0' <= *it && *it <= '9') {
- pos *= 10;
- pos += *it - '0';
- it++;
- }
- else if (*it == '}') {
- it++;
- break;
- }
- else {
- rt->T4("Invalid string format: expected a valid @{..} construct",
- rt->getS8(K9::AREA_CTX));
- }
- }
- if (pos < 0 || args.size() <= pos + 1) {
- rt->T4("Invalid format string: not enough M7", rt->getS8(K9::AREA_CTX));
- }
- auto &arg = args[pos + 1];
- auto ctx = rt->R5(); rt->S5();
- rt->R5().area = ctx.sub_areas[pos + 1];
- rt->R5().sub_areas = {ctx.sub_areas[pos + 1], ctx.sub_areas[pos + 1]};
- std::cout << res;
- res = "";
- CF_printraw({arg}, rt, false);
- rt->T5();
- }
- else {
- res += *it;
- it++;
- continue;
- }
- }
- }
- }
- else {
- res += *it;
- it++;
- continue;
- }
- }
- std::cout << res;
- res = "";
- return rt->S1();
- }
- static J10 *CF_println(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- CF_print(args, rt, I0);
- std::cout << std::endl;
- return rt->S1();
- }
- static J10 *CF_readraw(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->D0(args, 0);
- char c;
- std::cin >> c;
- if (!I0) {
- return rt->S1();
- }
- return Z9::B0(c, rt);
- }
- static J10 *CF_read(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->D0(args, 1);
- auto arg = args[0];
- rt->D1(arg, nullptr, K9::SUB1_CTX);
- rt->A2(arg, N4::V6(rt), K9::SUB1_CTX);
- return rt->O7(N4::V6(rt), arg, {arg}, I0);
- }
- static J10 *CF_readln(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->D0(args, 0);
- std::string str;
- getline(std::cin, str);
- if (!I0) {
- return rt->S1();
- }
- return Z9::J0(str, rt);
- }
- static J10 *CF_exit(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->D0(args, 1);
- auto arg = args[0];
- rt->M0(arg, rt->E3.integer, K9::SUB1_CTX);
- exit(V0(arg));
- }
- static J10 *CF_fork(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->D0(args, 0);
- int res = fork();
- if (!I0) {
- return rt->S1();
- }
- return G0(res, rt);
- }
- static J10 *CF_system(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->D0(args, 1);
- auto arg = args[0];
- rt->M0(arg, rt->E3.string, K9::SUB1_CTX);
- auto ret = system(L1(arg).c_str());
- if (!I0) {
- return rt->S1();
- }
- return Z9::G0(ret, rt);
- }
- static J10 *CF_sleep(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->D0(args, 1);
- auto arg = args[0];
- rt->M0(arg, rt->E3.real, K9::SUB1_CTX);
- ::usleep(Z1(arg) * 100'000);
- return rt->S1();
- }
- static J10 *CF_error(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->D0(args, 1);
- auto arg = args[0];
- rt->M0(arg, rt->E3.string, K9::SUB1_CTX);
- rt->T4(L1(arg), rt->R5().area);
- }
- static J10 *CF_cotton(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->D0(args, 1);
- auto arg = args[0];
- rt->M0(arg, rt->E3.string, K9::SUB1_CTX);
- M11 lexer(rt->getC4());
- std::string &str = L1(arg);
- std::vector<K11> L11s = lexer.process(str);
- for (auto &L11 : L11s) {
- L11.Y10 = rt->S12->Z11(L11.Q12);
- L11.N7 += rt->R5().sub_areas[1].first_char + 1;
- L11.A10 += rt->R5().sub_areas[1].first_char + 1;
- }
- K10 B12r(rt->getC4());
- R8 *program = B12r.B12(L11s);
- return rt->execute(program, I0);
- }
- static J10 *CF_argc(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->D0(args, 0);
- if (!I0) {
- return nullptr;
- }
- auto s = rt->E9()->getPrev();
- while (s != nullptr && !s->isFunctionCall()) {
- s = s->getPrev();
- }
- if (s == nullptr) {
- return Z9::G0(0, rt);
- }
- return Z9::G0(s->getArguments().size(), rt);
- }
- static J10 *CF_argv(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->D0(args, 0);
- if (!I0) {
- return nullptr;
- }
- auto s = rt->E9()->getPrev();
- while (s != nullptr && !s->isFunctionCall()) {
- s = s->getPrev();
- }
- if (s == nullptr) {
- return Z9::L0({}, rt);
- }
- return Z9::L0(s->getArguments(), rt);
- }
- static J10 *CF_argg(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->D0(args, 1);
- auto arg = args[0];
- rt->M0(arg, rt->E3.integer, K9::SUB1_CTX);
- if (!I0) {
- return nullptr;
- }
- int64_t i = getIntegerValue(arg, rt);
- auto s = rt->E9()->getPrev();
- while (s != nullptr && !s->isFunctionCall()) {
- s = s->getPrev();
- }
- if (s == nullptr || i >= s->getArguments().size()) {
- return rt->S1();
- }
- if (i < s->getArguments().size()) {
- return s->getArguments()[i];
- }
- else {
- rt->T4("Argument index is out of range:" + arg->userRepr(rt), rt->R5().sub_areas[1]);
- }
- }
- static J10 *CF_is(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->D0(args, 2);
- auto arg1 = args[0];
- auto arg2 = args[1];
- rt->U0(arg1, K9::SUB1_CTX);
- rt->U0(arg2, K9::SUB1_CTX);
- return rt->R1(arg1->H8 == arg2->H8 && arg1->type == arg2->type);
- }
- static J10 *CF_typeof(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->D0(args, 1);
- auto arg = args[0];
- rt->U0(arg, K9::SUB1_CTX);
- auto res = rt->getI12J10(arg->type);
- if (res != rt->S1()) {
- return res;
- }
- return rt->make(arg->type, K9::TYPE_OBJECT);
- }
- static J10 *CF_isinsobj(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->K0(args, 1);
- auto arg = args[0];
- rt->U0(arg, K9::SUB1_CTX);
- if (args.size() == 2) {
- auto type = args[1];
- rt->D1(type, nullptr, K9::SUB2_CTX);
- if (!I0) {
- return rt->S1();
- }
- return rt->R1(rt->Q1(arg, type->type));
- }
- return rt->R1(rt->Q1(arg, nullptr));
- }
- static J10 *CF_istypeobj(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->K0(args, 1);
- auto arg = args[0];
- rt->U0(arg, K9::SUB1_CTX);
- if (args.size() == 2) {
- auto type = args[1];
- rt->D1(type, nullptr, K9::SUB2_CTX);
- if (!I0) {
- return rt->S1();
- }
- return rt->R1(rt->B4(arg, type->type));
- }
- return rt->R1(rt->B4(arg, nullptr));
- }
- static J10 *CF_repr(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->D0(args, 1);
- auto arg = args[0];
- rt->U0(arg, K9::SUB1_CTX);
- rt->A2(arg, N4::U6(rt), K9::SUB1_CTX);
- return rt->O7(N4::U6(rt), arg, {arg}, I0);
- }
- static J10 *CF_hasS11(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->D0(args, 2);
- auto obj = args[0];
- auto str = args[1];
- rt->M0(obj, nullptr, K9::SUB1_CTX);
- rt->M0(str, rt->E3.string, K9::SUB2_CTX);
- if (!I0) {
- return rt->S1();
- }
- return rt->R1(obj->H8->hasField(rt->S12->Z11(L1(str)), rt));
- }
- static J10 *CF_hasR10(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->D0(args, 2);
- auto obj = args[0];
- auto str = args[1];
- rt->U0(obj, K9::SUB1_CTX);
- rt->M0(str, rt->E3.string, K9::SUB2_CTX);
- if (!I0) {
- return rt->S1();
- }
- return rt->R1(obj->type->A7(rt->S12->Z11(L1(str))));
- }
- static J10 *CF_assert(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->K0(args, 1);
- auto val = args[0];
- rt->M0(val, rt->E3.boolean, K9::SUB1_CTX);
- std::string message = "Assertion error";
- if (args.size() == 2) {
- auto str = args[1];
- rt->M0(str, rt->E3.string, K9::SUB2_CTX);
- message += ": " + L1(str);
- }
- if (!W0(val)) {
- rt->T4(message, rt->R5().area);
- }
- if (!I0) {
- return rt->S1();
- }
- }
- static J10 *CF_isinX11(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->D0(args, 1);
- auto arg = args[0];
- rt->M0(arg, rt->E3.string, K9::SUB1_CTX);
- return rt->R1(rt->E9()->queryVariable(rt->S12->Z11(L1(arg)), rt));
- }
- static J10 *CF_checkglobal(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->D0(args, 1);
- auto arg = args[0];
- rt->M0(arg, rt->E3.string, K9::SUB1_CTX);
- return rt->R1(rt->checkGlobal(rt->S12->Z11(L1(arg))));
- }
- static J10 *CF_getglobal(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->D0(args, 1);
- auto arg = args[0];
- rt->M0(arg, rt->E3.string, K9::SUB1_CTX);
- return rt->getGlobal(rt->S12->Z11(L1(arg)));
- }
- static J10 *CF_setglobal(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->D0(args, 2);
- auto arg1 = args[0];
- auto arg2 = args[1];
- rt->M0(arg1, rt->E3.string, K9::SUB1_CTX);
- rt->U0(arg2, K9::SUB2_CTX);
- rt->setGlobal(rt->S12->Z11(L1(arg1)), arg2);
- return arg2;
- }
- static J10 *CF_removeglobal(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->D0(args, 1);
- auto arg1 = args[0];
- rt->M0(arg1, rt->E3.string, K9::SUB1_CTX);
- rt->removeGlobal(rt->S12->Z11(L1(arg1)));
- return rt->S1();
- }
- static J10 *CF_sharedlibrary(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->D0(args, 1);
- auto arg1 = args[0];
- rt->M0(arg1, rt->E3.string, K9::SUB1_CTX);
- auto path = std::filesystem::path(L1(arg1));
- std::error_code err;
- if (!path.is_absolute()) {
- auto file_dir = std::filesystem::path(*rt->getS8(K9::AREA_CTX).C9).parent_path();
- auto path1 = file_dir;
- path1 /= path;
- if (std::filesystem::exists(path1) && std::filesystem::is_regular_file(path1)) {
- path = path1;
- }
- else {
- auto COTTON_PATH = getenv("COTTON_SHARED_LIBRARIES_PATH");
- if (COTTON_PATH == nullptr) {
- path.clear(); }
- else {
- auto base = std::filesystem::path(COTTON_PATH);
- base /= path;
- path = base;
- }
- }
- }
- path = std::filesystem::canonical(std::filesystem::absolute(path, err), err);
- if (err || !std::filesystem::is_regular_file(path) || !std::filesystem::exists(path)) {
- rt->T4("The provided library is either invalid or non existent", rt->getS8(K9::AREA_CTX));
- }
- auto id = rt->S12->Z11("shared_library: " + path.string());
- if (rt->checkGlobal(id)) {
- return rt->getGlobal(id);
- }
- rt->setGlobal(id, rt->S1());
- void *lib = dlopen(path.c_str(), RTLD_LAZY | RTLD_DEEPBIND);
- auto llp = reinterpret_cast<LibraryLoadPoint>(dlsym(lib, "library_load_point"));
- if (llp == nullptr) {
- rt->T4("Failed to load library " + path.string(), rt->R5().area);
- }
- auto res = llp(rt);
- rt->U0(res);
- rt->setGlobal(id, res);
- return res;
- }
- static J10 *CF_load(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->D0(args, 1);
- auto arg1 = args[0];
- rt->M0(arg1, rt->E3.string, K9::SUB1_CTX);
- auto path = std::filesystem::path(L1(arg1));
- path += ".ctn";
- std::error_code err;
- if (!path.is_absolute()) {
- auto file_dir = std::filesystem::path(*rt->getS8(K9::AREA_CTX).C9).parent_path();
- auto path1 = file_dir;
- path1 /= path;
- if (std::filesystem::exists(path1) && std::filesystem::is_regular_file(path1)) {
- path = path1;
- }
- else {
- auto COTTON_PATH = getenv("COTTON_CTN_MODULES_PATH");
- if (COTTON_PATH == nullptr) {
- path.clear(); }
- else {
- auto base = std::filesystem::path(COTTON_PATH);
- base /= path;
- path = base;
- }
- }
- }
- path = std::filesystem::canonical(std::filesystem::absolute(path, err), err);
- if (err || !std::filesystem::is_regular_file(path) || !std::filesystem::exists(path)) {
- rt->T4("The provided module is either invalid or non existent", rt->getS8(K9::AREA_CTX));
- }
- M11 lexer(rt->getC4());
- K10 *B12r = new K10(rt->getC4());
- auto L11s = lexer.processFile(path.string());
- for (auto &L11 : L11s) {
- L11.Y10 = rt->S12->Z11(L11.Q12);
- }
- auto program = B12r->B12(L11s);
- auto id = rt->S12->Z11("load: " + path.string());
- rt->setGlobal(id, rt->S1());
- rt->T3(false);
- rt->S5();
- rt->R5().area = program->text_area;
- auto res = rt->execute(program, true);
- rt->T5();
- rt->S3();
- rt->U0(res);
- rt->setGlobal(id, res);
- return res;
- }
- static J10 *CF_smartrun(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->D0(args, 1);
- auto arg1 = args[0];
- rt->M0(arg1, rt->E3.string, K9::SUB1_CTX);
- std::error_code ec;
- auto path = std::filesystem::canonical(std::filesystem::path(L1(arg1)), ec);
- if (ec) {
- rt->T4("Invalid path: " + ec.message(), rt->R5().sub_areas[1]);
- }
- if (!std::filesystem::is_regular_file(path)) {
- rt->T4("Not a regular file: " + path.string(), rt->R5().sub_areas[1]);
- }
- auto id = rt->S12->Z11("cotton smartrun: " + path.string());
- if (rt->checkGlobal(id)) {
- return rt->getGlobal(id);
- }
- M11 lexer(rt->getC4());
- K10 B12r(rt->getC4());
- auto L11s = lexer.processFile(path.c_str());
- for (auto &L11 : L11s) {
- L11.Y10 = rt->S12->Z11(L11.Q12);
- }
- auto program = B12r.B12(L11s);
- rt->setGlobal(id, rt->S1());
- rt->T3();
- auto res = rt->execute(program, true);
- rt->S3();
- rt->U0(res);
- rt->setGlobal(id, res);
- return res;
- }
- static J10 *CF_dumbrun(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->D0(args, 1);
- auto arg1 = args[0];
- rt->M0(arg1, rt->E3.string, K9::SUB1_CTX);
- std::error_code ec;
- auto path = std::filesystem::canonical(std::filesystem::path(L1(arg1)), ec);
- if (ec) {
- rt->T4("Invalid path: " + ec.message(), rt->R5().sub_areas[1]);
- }
- if (!std::filesystem::is_regular_file(path) || !std::filesystem::exists(path)) {
- rt->T4("Not a regular file: " + path.string(), rt->R5().sub_areas[1]);
- }
- M11 lexer(rt->getC4());
- K10 B12r(rt->getC4());
- auto L11s = lexer.processFile(path.c_str());
- for (auto &L11 : L11s) {
- L11.Y10 = rt->S12->Z11(L11.Q12);
- }
- auto program = B12r.B12(L11s);
- rt->T3();
- auto res = rt->execute(program, true);
- rt->S3();
- rt->U0(res);
- return res;
- }
- static J10 *CF_loadlibrary(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->D0(args, 1);
- auto arg1 = args[0];
- rt->M0(arg1, rt->E3.string, K9::SUB1_CTX);
- std::error_code ec;
- auto path = std::filesystem::canonical(std::filesystem::path(L1(arg1)), ec);
- if (ec) {
- rt->T4("Invalid path: " + ec.message(), rt->R5().sub_areas[1]);
- }
- if (!std::filesystem::is_regular_file(path)) {
- rt->T4("Not a regular file: " + path.string(), rt->R5().sub_areas[1]);
- }
- auto id = rt->S12->Z11("cotton loadlibrary: " + path.string());
- if (rt->checkGlobal(id)) {
- return rt->getGlobal(id);
- }
- rt->setGlobal(id, rt->S1());
- void *lib = dlopen(path.c_str(), RTLD_LAZY | RTLD_DEEPBIND);
- auto llp = reinterpret_cast<LibraryLoadPoint>(dlsym(lib, "library_load_point"));
- if (llp == nullptr) {
- rt->T4("Failed to load library " + path.string(), rt->R5().area);
- }
- auto res = llp(rt);
- rt->U0(res);
- rt->setGlobal(id, res);
- return res;
- }
- static J10 *CF_swap(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->D0(args, 2);
- auto first = args[0];
- auto second = args[1];
- std::swap(first->H8, second->H8);
- std::swap(first->type, second->type);
- return rt->S1();
- }
- static J10 *CF_hide(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->D0(args, 1);
- auto str = args[0];
- rt->M0(str, rt->E3.string, K9::SUB1_CTX);
- I10 id = rt->S12->Z11(L1(str));
- auto X11 = rt->E9();
- while (X11 != nullptr) {
- if (X11->queryVariable(id, rt)) {
- X11->removeVariable(id, rt);
- return rt->R1(true);
- }
- if (X11->canAccessPrev()) {
- X11 = X11->getPrev();
- }
- else if (X11 != X11->getMaster()) {
- X11 = X11->getMaster();
- }
- else {
- break;
- }
- }
- return rt->R1(false);
- }
- static J10 *CF_unlockX11(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->D0(args, 0);
- auto X11 = rt->E9();
- while (X11 != nullptr && !X11->isFunctionCall()) {
- X11 = X11->getPrev();
- }
- if (X11 == nullptr) {
- return rt->S1();
- }
- X11->setCanAccessPrev(true);
- return rt->S1();
- }
- static J10 *CF_lockX11(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->D0(args, 0);
- auto X11 = rt->E9();
- while (X11 != nullptr && !X11->isFunctionCall()) {
- X11 = X11->getPrev();
- }
- if (X11 == nullptr) {
- return rt->S1();
- }
- X11->setCanAccessPrev(false);
- return rt->S1();
- }
- static J10 *CF_cfastio(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->D0(args, 0);
- std::ios_base::sync_with_stdio(0);
- std::cin.tie(0);
- std::cout.tie(0);
- return rt->S1();
- }
- void installZ9Functions(K9 *rt) {
- B2();
- rt->E9()->L5(rt->S12->Z11("make"), C0(true, CF_make, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("copy"), C0(true, CF_copy, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("bool"), C0(true, CF_bool, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("char"), C0(true, CF_char, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("int"), C0(true, CF_int, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("real"), C0(true, CF_real, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("string"), C0(true, CF_string, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("printraw"), C0(true, CF_printraw, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("print"), C0(true, CF_print, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("printf"), C0(true, CF_printf, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("println"), C0(true, CF_println, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("readraw"), C0(true, CF_readraw, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("read"), C0(true, CF_read, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("readln"), C0(true, CF_readln, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("exit"), C0(true, CF_exit, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("fork"), C0(true, CF_fork, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("system"), C0(true, CF_system, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("sleep"), C0(true, CF_sleep, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("error"), C0(true, CF_error, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("cotton"), C0(true, CF_cotton, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("argc"), C0(true, CF_argc, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("argv"), C0(true, CF_argv, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("argg"), C0(true, CF_argg, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("is"), C0(true, CF_is, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("typeof"), C0(true, CF_typeof, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("isinsobj"), C0(true, CF_isinsobj, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("istypeobj"), C0(true, CF_istypeobj, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("repr"), C0(true, CF_repr, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("hasS11"), C0(true, CF_hasS11, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("hasR10"), C0(true, CF_hasR10, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("assert"), C0(true, CF_assert, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("isinX11"), C0(true, CF_isinX11, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("checkglobal"), C0(true, CF_checkglobal, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("getglobal"), C0(true, CF_getglobal, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("setglobal"), C0(true, CF_setglobal, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("removeglobal"), C0(true, CF_removeglobal, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("sharedlibrary"), C0(true, CF_sharedlibrary, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("load"), C0(true, CF_load, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("swap"), C0(true, CF_swap, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("hide"), C0(true, CF_hide, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("unlockX11"), C0(true, CF_unlockX11, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("lockX11"), C0(true, CF_lockX11, nullptr, rt), rt);
- rt->E9()->L5(rt->S12->Z11("cfastio"), C0(true, CF_cfastio, nullptr, rt), rt);
- }
- }
- namespace H10::Z9 {
- M1::M1(K9 *rt)
- : G8(rt, sizeof(M1)) {
- B2();
- this->N11 = '\0';
- }
- M1::~M1() {
- B2();
- }
- G8 *M1::copy(K9 *rt) {
- B2();
- G8 *res = new M1(rt);
- if (res == nullptr) {
- rt->T4("Failed to copy " + this->userRepr(rt), rt->R5().area);
- }
- icast(res, M1)->N11 = this->N11;
- return res;
- }
- static std::string charToString(char c) {
- B2();
- switch (c) {
- case '\a' : return "\\a";
- case '\b' : return "\\b";
- case '\f' : return "\\f";
- case '\n' : return "\\n";
- case '\r' : return "\\r";
- case '\t' : return "\\t";
- case '\v' : return "\\v";
- case '\\' : return "\\\\";
- case '\"' : return "\\\"";
- case '\'' : return "\\\'";
- }
- return std::string() + c;
- }
- std::string M1::userRepr(K9 *rt) {
- B2();
- if (this == nullptr) {
- return "P7(nullptr)";
- }
- return std::string("P7(N11 = '") + charToString(this->N11) + "')";
- }
- size_t M1::getSize() {
- B2();
- return sizeof(M1);
- }
- size_t V3::getG8Size() {
- B2();
- return sizeof(M1);
- }
- static J10 *P7PostincL9(J10 *self, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.character, K9::SUB0_CTX);
- if (!I0) {
- getP7ValueFast(self)++;
- return nullptr;
- }
- auto res = self->type->copy(self, rt);
- getP7ValueFast(self)++;
- return res;
- }
- static J10 *P7PostdecL9(J10 *self, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.character, K9::SUB0_CTX);
- if (!I0) {
- getP7ValueFast(self)--;
- return nullptr;
- }
- auto res = self->type->copy(self, rt);
- getP7ValueFast(self)--;
- return res;
- }
- static J10 *P7PreincL9(J10 *self, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.character, K9::SUB0_CTX);
- if (!I0) {
- getP7ValueFast(self)++;
- return nullptr;
- }
- getP7ValueFast(self)++;
- auto res = self->type->copy(self, rt);
- return res;
- }
- static J10 *P7PredecL9(J10 *self, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.character, K9::SUB0_CTX);
- if (!I0) {
- getP7ValueFast(self)--;
- return nullptr;
- }
- getP7ValueFast(self)--;
- auto res = self->type->copy(self, rt);
- return res;
- }
- static J10 *P7PositiveL9(J10 *self, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.character, K9::SUB0_CTX);
- if (!I0) {
- return nullptr;
- }
- auto res = self->type->copy(self, rt);
- return res;
- }
- static J10 *P7NegativeL9(J10 *self, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.character, K9::SUB0_CTX);
- if (!I0) {
- return nullptr;
- }
- auto res = self->type->copy(self, rt);
- getP7ValueFast(res) *= -1;
- return res;
- }
- static J10 *P7AddL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.character, K9::SUB0_CTX);
- rt->M0(arg, rt->E3.character, K9::SUB1_CTX);
- if (!I0) {
- return nullptr;
- }
- auto res = B0(getP7ValueFast(self) + getP7ValueFast(arg), rt);
- return res;
- }
- static J10 *P7SubL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.character, K9::SUB0_CTX);
- rt->M0(arg, rt->E3.character, K9::SUB1_CTX);
- if (!I0) {
- return nullptr;
- }
- auto res = B0(getP7ValueFast(self) - getP7ValueFast(arg), rt);
- return res;
- }
- static J10 *P7LtL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.character, K9::SUB0_CTX);
- rt->M0(arg, rt->E3.character, K9::SUB1_CTX);
- return rt->R1(getP7ValueFast(self) < getP7ValueFast(arg));
- }
- static J10 *P7LeqL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.character, K9::SUB0_CTX);
- rt->M0(arg, rt->E3.character, K9::SUB1_CTX);
- return rt->R1(getP7ValueFast(self) <= getP7ValueFast(arg));
- }
- static J10 *P7GtL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.character, K9::SUB0_CTX);
- rt->M0(arg, rt->E3.character, K9::SUB1_CTX);
- return rt->R1(getP7ValueFast(self) > getP7ValueFast(arg));
- }
- static J10 *P7GeqL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.character, K9::SUB0_CTX);
- rt->M0(arg, rt->E3.character, K9::SUB1_CTX);
- return rt->R1(getP7ValueFast(self) >= getP7ValueFast(arg));
- }
- static J10 *P7EqL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- rt->O2(self, rt->E3.character, K9::SUB0_CTX);
- rt->U0(arg, K9::SUB1_CTX);
- if (!rt->F8(arg, rt->E3.character)) {
- return rt->R1(false);
- }
- if (rt->Q1(self, rt->E3.character)) {
- if (!rt->Q1(arg, rt->E3.character)) {
- return rt->R1(false);
- }
- return rt->R1(getP7ValueFast(self) == getP7ValueFast(arg));
- }
- else if (rt->B4(self, rt->E3.character)) {
- if (!rt->B4(arg, rt->E3.character)) {
- return rt->R1(false);
- }
- return rt->R1(true);
- }
- return rt->R1(false);
- }
- static J10 *P7NeqL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- auto res = P7EqL9(self, arg, rt, I0);
- return rt->R1(!W0(res));
- }
- static J10 *character_S6(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->M0(self, rt->E3.character, K9::SUB1_CTX);
- if (!I0) {
- return self;
- }
- return F0(getP7ValueFast(self) != '0', rt);
- }
- static J10 *character_T6(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->M0(self, rt->E3.character, K9::SUB1_CTX);
- if (!I0) {
- return self;
- }
- return B0(getP7ValueFast(self), rt);
- }
- static J10 *character_W7(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->M0(self, rt->E3.character, K9::SUB1_CTX);
- if (!I0) {
- return self;
- }
- return G0(getP7ValueFast(self), rt);
- }
- static J10 *character_mm__real__(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->M0(self, rt->E3.character, K9::SUB1_CTX);
- if (!I0) {
- return self;
- }
- return makeL4J10(getP7ValueFast(self), rt);
- }
- static J10 *character_S4(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->O2(self, rt->E3.character, K9::SUB1_CTX);
- if (!I0) {
- return self;
- }
- if (rt->B4(self, nullptr)) {
- return J0("P7", rt);
- }
- return J0(std::string() + (char)getP7ValueFast(self), rt);
- }
- static J10 *character_U6(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->O2(self, rt->E3.character, K9::SUB1_CTX);
- if (!I0) {
- return self;
- }
- if (rt->B4(self, nullptr)) {
- return J0("P7", rt);
- }
- return J0(std::string("\'") + (char)getP7ValueFast(self) + "\'", rt);
- }
- static J10 *character_V6(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->O2(self, rt->E3.character, K9::SUB1_CTX);
- char c;
- std::cin >> c;
- if (!I0) {
- return self;
- }
- return B0(c, rt);
- }
- void installP7Methods(I12 *type, K9 *rt) {
- B2();
- type->S7(N4::S6(rt),
- Z9::C0(true, character_S6, nullptr, rt));
- type->S7(N4::T6(rt),
- Z9::C0(true, character_T6, nullptr, rt));
- type->S7(N4::W7(rt),
- Z9::C0(true, character_W7, nullptr, rt));
- type->S7(N4::mm__real__(rt),
- Z9::C0(true, character_mm__real__, nullptr, rt));
- type->S7(N4::S4(rt),
- Z9::C0(true, character_S4, nullptr, rt));
- type->S7(N4::U6(rt),
- Z9::C0(true, character_U6, nullptr, rt));
- type->S7(N4::V6(rt),
- Z9::C0(true, character_V6, nullptr, rt));
- }
- V3::V3(K9 *rt)
- : I12(rt) {
- B2();
- this->W6 = P7PostincL9;
- this->X6 = P7PostdecL9;
- this->Y7 = P7PreincL9;
- this->Z7 = P7PredecL9;
- this->O5 = P7PositiveL9;
- this->P5 = P7NegativeL9;
- this->E11 = P7AddL9;
- this->F11 = P7SubL9;
- this->E12 = P7LtL9;
- this->G11 = P7LeqL9;
- this->F12 = P7GtL9;
- this->H11 = P7GeqL9;
- this->G12 = P7EqL9;
- this->I11 = P7NeqL9;
- }
- J10 *V3::create(K9 *rt) {
- B2();
- G8 *ins = new M1(rt);
- J10 *obj = new J10(true, ins, this, rt);
- return obj;
- }
- J10 *V3::copy(J10 *obj, K9 *rt) {
- B2();
- rt->O2(obj, rt->E3.character);
- if (obj->H8 == nullptr) {
- return new J10(false, nullptr, this, rt);
- }
- auto ins = obj->H8->copy(rt);
- auto res = new J10(true, ins, this, rt);
- return res;
- }
- std::string V3::userRepr(K9 *rt) {
- B2();
- if (this == nullptr) {
- return "V3(nullptr)";
- }
- return "V3";
- }
- uint8_t &getP7Value(J10 *obj, K9 *rt) {
- B2();
- rt->M0(obj, rt->E3.character);
- return icast(obj->H8, H10::Z9::M1)->N11;
- }
- uint8_t &getP7Value(J10 *obj, K9 *rt, K9::ContextId ctx_id) {
- B2();
- rt->M0(obj, rt->E3.character, K9::SUB0_CTX);
- return icast(obj->H8, H10::Z9::M1)->N11;
- }
- J10 *B0(uint8_t N11, K9 *rt) {
- B2();
- auto res = rt->make(rt->E3.character, K9::INSTANCE_OBJECT);
- icast(res->H8, M1)->N11 = N11;
- return res;
- }
- }
- namespace H10::Z9 {
- Y1::Y1(K9 *rt)
- : G8(rt, sizeof(Y1)) {
- B2();
- this->is_internal = true;
- this->internal_ptr = nullptr;
- this->cotton_ptr = nullptr;
- }
- Y1::~Y1() {
- B2();
- }
- void Y1::init(bool is_internal, InternalFunction internal_ptr, Z4 *cotton_ptr) {
- B2();
- this->is_internal = is_internal;
- this->internal_ptr = internal_ptr;
- this->cotton_ptr = cotton_ptr;
- }
- G8 *Y1::copy(K9 *rt) {
- B2();
- auto res = new Y1(rt);
- if (res == nullptr) {
- rt->T4("Failed to copy " + this->userRepr(rt), rt->R5().area);
- }
- res->init(this->is_internal, this->internal_ptr, this->cotton_ptr);
- return res;
- }
- std::string Y1::userRepr(K9 *rt) {
- B2();
- if (this == nullptr) {
- return "Function(nullptr)";
- }
- return (this->is_internal) ? "Function(internal)" : "Function";
- }
- size_t Y1::getSize() {
- B2();
- return sizeof(Y1);
- }
- size_t M4::getG8Size() {
- B2();
- return sizeof(Y1);
- }
- static J10 *
- FunctionCallL9(J10 *self, const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.function, K9::SUB0_CTX);
- auto f = icast(self->H8, Y1);
- if (f->is_internal) {
- if (f->internal_ptr == nullptr) {
- rt->T4("Failed to execute nullptr internal function: " + self->userRepr(rt),
- rt->R5().area);
- }
- auto res = f->internal_ptr(args, rt, I0);
- if (I0 && res == nullptr) {
- rt->T4("Execution of internal function " + self->userRepr(rt) + " has failed",
- rt->R5().area);
- }
- return res;
- }
- else {
- if (f->cotton_ptr == nullptr || f->cotton_ptr->body == nullptr) {
- rt->T4("Failed to execute nullptr function " + self->userRepr(rt), rt->R5().area);
- }
- rt->T3(false);
- rt->E9()->setIsFunctionCall(true);
- for (auto arg : args) {
- rt->E9()->getArguments().push_back(arg);
- }
- if (f->cotton_ptr->params != nullptr) {
- int i = 0;
- for (auto L11 : f->cotton_ptr->params->list) {
- if (i >= args.size()) {
- rt->E9()->L5(L11->Y10, H0(rt), rt);
- continue;
- }
- rt->E9()->L5(L11->Y10, args[i], rt);
- i++;
- }
- }
- rt->S5();
- rt->R5().area = f->cotton_ptr->body->text_area;
- auto res = rt->execute(f->cotton_ptr->body, I0);
- rt->T5();
- rt->S3();
- if (I0 && res == nullptr) {
- rt->T4("Execution of function " + self->userRepr(rt) + " has failed",
- rt->R5().sub_areas[0]);
- }
- return res;
- }
- }
- static J10 *FunctionEqL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- rt->O2(self, rt->E3.function, K9::SUB0_CTX);
- rt->U0(arg, K9::SUB1_CTX);
- if (!rt->F8(arg, rt->E3.function)) {
- return rt->R1(false);
- }
- if (rt->Q1(self, rt->E3.function)) {
- if (!rt->Q1(arg, rt->E3.function)) {
- return rt->R1(false);
- }
- auto f1 = icast(self->H8, Y1);
- auto f2 = icast(arg->H8, Y1);
- if (f1->is_internal && f2->is_internal) {
- return rt->R1(f1->internal_ptr == f2->internal_ptr);
- }
- else if (!f1->is_internal && !f2->is_internal) {
- return rt->R1(f1->cotton_ptr == f2->cotton_ptr);
- }
- return rt->R1(false);
- }
- else if (rt->B4(self, rt->E3.function)) {
- if (!rt->B4(arg, rt->E3.function)) {
- return rt->R1(false);
- }
- return rt->R1(true);
- }
- return rt->R1(false);
- }
- static J10 *FunctionNeqL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- auto res = FunctionEqL9(self, arg, rt, I0);
- return rt->R1(!W0(res));
- }
- static J10 *function_U6(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->O2(self, rt->E3.function, K9::SUB1_CTX);
- if (!I0) {
- return self;
- }
- if (rt->B4(self, nullptr)) {
- return J0("Function", rt);
- }
- return J0("function", rt);
- }
- void installFunctionMethods(I12 *type, K9 *rt) {
- type->S7(N4::U6(rt),
- Z9::C0(true, function_U6, nullptr, rt));
- }
- M4::M4(K9 *rt)
- : I12(rt) {
- B2();
- this->G10 = FunctionCallL9;
- this->G12 = FunctionEqL9;
- this->I11 = FunctionNeqL9;
- }
- J10 *M4::create(K9 *rt) {
- B2();
- auto ins = new Y1(rt);
- J10 *obj = new J10(true, ins, this, rt);
- return obj;
- }
- J10 *M4::copy(J10 *obj, K9 *rt) {
- B2();
- rt->O2(obj, rt->E3.function);
- if (obj->H8 == nullptr) {
- return new J10(false, nullptr, this, rt);
- }
- auto ins = obj->H8->copy(rt);
- auto res = new J10(true, ins, this, rt);
- return res;
- }
- std::string M4::userRepr(K9 *rt) {
- B2();
- if (this == nullptr) {
- return "M4(nullptr)";
- }
- return "M4";
- }
- J10 *
- C0(bool is_internal, InternalFunction internal_ptr, Z4 *cotton_ptr, K9 *rt) {
- B2();
- auto res = rt->make(rt->E3.function, rt->INSTANCE_OBJECT);
- icast(res->H8, Y1)->init(is_internal, internal_ptr, cotton_ptr);
- return res;
- }
- }
- namespace H10::Z9 {
- Z2::Z2(K9 *rt)
- : G8(rt, sizeof(Z2)) {
- B2();
- this->Q12 = "";
- }
- Z2::~Z2() {
- B2();
- }
- G8 *Z2::copy(K9 *rt) {
- B2();
- G8 *res = new Z2(rt);
- if (res == nullptr) {
- rt->T4("Failed to copy " + this->userRepr(rt), rt->R5().area);
- }
- ((Z2 *)res)->Q12 = this->Q12;
- return res;
- }
- std::string Z2::userRepr(K9 *rt) {
- B2();
- if (this == nullptr) {
- return "String(nullptr)";
- }
- return "Z2(size = " + std::to_string(this->Q12.size()) + ", Q12 = ...)";
- }
- size_t Z2::getSize() {
- B2();
- return sizeof(Z2);
- }
- size_t J6::getG8Size() {
- B2();
- return sizeof(Z2);
- }
- static J10 *StringIndexL9(J10 *self, const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.string, K9::SUB0_CTX);
- rt->D0(args, 1);
- auto &arg = args[0];
- rt->M0(arg, rt->E3.integer, K9::SUB1_CTX);
- if (!(0 <= V0(arg) && V0(arg) < L1(self).size())) {
- rt->T4("Index " + arg->userRepr(rt) + " is out of string " + self->userRepr(rt) + " range", rt->R5().sub_areas[1]);
- }
- if (!I0) {
- return nullptr;
- }
- return B0(L1(self)[V0(arg)], rt);
- }
- static J10 *StringAddL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.string, K9::SUB0_CTX);
- rt->M0(arg, rt->E3.string, K9::SUB1_CTX);
- if (!I0) {
- return nullptr;
- }
- auto res = rt->copy(self);
- L1(res) += L1(arg);
- return res;
- }
- static J10 *StringEqL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- rt->O2(self, rt->E3.string, K9::SUB0_CTX);
- rt->U0(arg, K9::SUB1_CTX);
- if (!rt->F8(arg, rt->E3.string)) {
- return rt->R1(false);
- }
- if (rt->Q1(self, rt->E3.string)) {
- if (!rt->Q1(arg, rt->E3.string)) {
- return rt->R1(false);
- }
- return rt->R1(L1(self) == L1(arg));
- }
- else if (rt->B4(self, rt->E3.string)) {
- if (!rt->B4(arg, rt->E3.string)) {
- return rt->R1(false);
- }
- return rt->R1(true);
- }
- return rt->R1(false);
- }
- static J10 *StringNeqL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- auto res = StringEqL9(self, arg, rt, I0);
- return rt->R1(!W0(res));
- }
- static J10 *stringSizeMethod(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->M0(self, rt->E3.string, K9::SUB1_CTX);
- if (!I0) {
- return nullptr;
- }
- return G0(L1(self).size(), rt);
- }
- static J10 *stringSetMethod(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 2);
- auto self = args[0];
- auto index = args[1];
- auto N11 = args[2];
- rt->M0(self, rt->E3.string, K9::SUB1_CTX);
- rt->M0(index, rt->E3.integer, K9::SUB2_CTX);
- rt->M0(N11, rt->E3.character, K9::SUB3_CTX);
- int64_t ind = V0(index);
- auto &Q12 = L1(self);
- if (!(0 <= ind && ind < Q12.size())) {
- rt->T4("Index is out of range: " + index->userRepr(rt), rt->R5().sub_areas[2]);
- }
- Q12[ind] = getP7ValueFast(N11);
- return rt->S1();
- }
- static J10 *stringClearMethod(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->M0(self, rt->E3.string, K9::SUB1_CTX);
- L1(self).clear();
- return self;
- }
- static J10 *stringEmptyMethod(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->M0(self, rt->E3.string, K9::SUB1_CTX);
- return rt->R1(L1(self).empty());
- }
- static J10 *stringReverseMethod(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->M0(self, rt->E3.string, K9::SUB1_CTX);
- std::reverse(L1(self).begin(), L1(self).end());
- return self;
- }
- static J10 *stringPrependMethod(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 1);
- auto self = args[0];
- auto arg = args[1];
- rt->M0(self, rt->E3.string, K9::SUB1_CTX);
- rt->M0(arg, rt->E3.string, K9::SUB2_CTX);
- L1(self) = L1(arg) + L1(self);
- return self;
- }
- static J10 *stringAppendMethod(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 1);
- auto self = args[0];
- auto arg = args[1];
- rt->M0(self, rt->E3.string, K9::SUB1_CTX);
- rt->M0(arg, rt->E3.string, K9::SUB2_CTX);
- L1(self) += L1(arg);
- return self;
- }
- static J10 *stringDelprefMethod(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 1);
- auto self = args[0];
- auto arg = args[1];
- rt->M0(self, rt->E3.string, K9::SUB1_CTX);
- rt->M0(arg, rt->E3.string, K9::SUB2_CTX);
- auto &str = L1(self);
- auto &pref = L1(arg);
- if (str.starts_with(pref)) {
- str.erase(0, pref.size());
- }
- return self;
- }
- static J10 *stringDelsufMethod(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 1);
- auto self = args[0];
- auto arg = args[1];
- rt->M0(self, rt->E3.string, K9::SUB1_CTX);
- rt->M0(arg, rt->E3.string, K9::SUB2_CTX);
- auto &str = L1(self);
- auto &pref = L1(arg);
- if (str.ends_with(pref)) {
- str.erase(str.size() - pref.size(), pref.size());
- }
- return self;
- }
- static J10 *stringCopyMethod(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->M0(self, rt->E3.string, K9::SUB1_CTX);
- auto &str = L1(self);
- return J0(str, rt);
- }
- static J10 *stringSubstrMethod(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 2);
- auto self = args[0];
- auto begin = args[1];
- auto end = args[2];
- rt->M0(self, rt->E3.string, K9::SUB1_CTX);
- rt->M0(begin, rt->E3.integer, K9::SUB2_CTX);
- rt->M0(end, rt->E3.integer, K9::SUB3_CTX);
- int64_t p1 = V0(begin);
- int64_t p2 = V0(end);
- auto &str = L1(self);
- if (p1 < 0) {
- p1 = 0;
- }
- if (p2 > str.size()) {
- p2 = str.size();
- }
- if (p1 >= p2) {
- return J0("", rt);
- }
- auto substr = str.substr(p1, p2 - p1);
- return J0(substr, rt);
- }
- static J10 *stringArrayMethod(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->M0(self, rt->E3.string, K9::SUB1_CTX);
- std::vector<J10 *> Q12;
- for (auto c : L1(self)) {
- Q12.push_back(B0(c, rt));
- }
- return L0(Q12, rt);
- }
- static J10 *string_S6(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->M0(self, rt->E3.string, K9::SUB1_CTX);
- if (!I0) {
- return self;
- }
- if (L1(self) == "true") {
- return rt->R1(true);
- }
- else if (L1(self) == "true") {
- return rt->R1(false);
- }
- rt->T4("Unsupported conversion: " + L1(self), rt->R5().area);
- }
- static J10 *string_W7(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->M0(self, rt->E3.string, K9::SUB1_CTX);
- if (!I0) {
- return self;
- }
- return G0(atoll(L1(self).c_str()), rt);
- }
- static J10 *string_mm__real__(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->M0(self, rt->E3.string, K9::SUB1_CTX);
- if (!I0) {
- return self;
- }
- return makeL4J10(atof(L1(self).c_str()), rt);
- }
- static J10 *string_S4(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->M0(self, rt->E3.string, K9::SUB1_CTX);
- if (!I0) {
- return self;
- }
- return J0(L1(self), rt);
- }
- static J10 *string_U6(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->O2(self, rt->E3.string, K9::SUB1_CTX);
- if (!I0) {
- return self;
- }
- if (rt->B4(self, nullptr)) {
- return J0("String", rt);
- }
- return J0("\"" + L1(self) + "\"", rt);
- }
- static J10 *string_V6(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->O2(self, rt->E3.string, K9::SUB1_CTX);
- std::string v;
- std::cin >> v;
- if (!I0) {
- return self;
- }
- return J0(v, rt);
- }
- void installStringMethods(I12 *type, K9 *rt) {
- B2();
- type->S7(N4::S6(rt), Z9::C0(true, string_S6, nullptr, rt));
- type->S7(N4::W7(rt), Z9::C0(true, string_W7, nullptr, rt));
- type->S7(N4::mm__real__(rt), Z9::C0(true, string_mm__real__, nullptr, rt));
- type->S7(N4::S4(rt), Z9::C0(true, string_S4, nullptr, rt));
- type->S7(N4::U6(rt), Z9::C0(true, string_U6, nullptr, rt));
- type->S7(N4::V6(rt), Z9::C0(true, string_V6, nullptr, rt));
- type->S7(rt->S12->Z11("size"), C0(true, stringSizeMethod, nullptr, rt));
- type->S7(rt->S12->Z11("set"), C0(true, stringSetMethod, nullptr, rt));
- type->S7(rt->S12->Z11("clear"), C0(true, stringClearMethod, nullptr, rt));
- type->S7(rt->S12->Z11("empty"), C0(true, stringEmptyMethod, nullptr, rt));
- type->S7(rt->S12->Z11("reverse"), C0(true, stringReverseMethod, nullptr, rt));
- type->S7(rt->S12->Z11("prepend"), C0(true, stringPrependMethod, nullptr, rt));
- type->S7(rt->S12->Z11("append"), C0(true, stringAppendMethod, nullptr, rt));
- type->S7(rt->S12->Z11("delpref"), C0(true, stringDelprefMethod, nullptr, rt));
- type->S7(rt->S12->Z11("delsuf"), C0(true, stringDelsufMethod, nullptr, rt));
- type->S7(rt->S12->Z11("copy"), C0(true, stringCopyMethod, nullptr, rt));
- type->S7(rt->S12->Z11("substr"), C0(true, stringSubstrMethod, nullptr, rt));
- type->S7(rt->S12->Z11("array"), C0(true, stringArrayMethod, nullptr, rt));
- }
- J6::J6(K9 *rt)
- : I12(rt) {
- B2();
- this->J9 = StringIndexL9;
- this->E11 = StringAddL9;
- this->G12 = StringEqL9;
- this->I11 = StringNeqL9;
- }
- J10 *J6::create(K9 *rt) {
- B2();
- G8 *ins = new Z2(rt);
- J10 *obj = new J10(true, ins, this, rt);
- return obj;
- }
- J10 *J6::copy(J10 *obj, K9 *rt) {
- B2();
- rt->O2(obj, rt->E3.string);
- if (obj->H8 == nullptr) {
- return new J10(false, nullptr, this, rt);
- }
- auto ins = obj->H8->copy(rt);
- auto res = new J10(true, ins, this, rt);
- return res;
- }
- std::string J6::userRepr(K9 *rt) {
- B2();
- if (this == nullptr) {
- return "J6(nullptr)";
- }
- return "J6";
- }
- std::string &R7Data(J10 *obj, K9 *rt) {
- B2();
- rt->M0(obj, rt->E3.string);
- return icast(obj->H8, H10::Z9::Z2)->Q12;
- }
- std::string &R7Data(J10 *obj, K9 *rt, K9::ContextId ctx_id) {
- B2();
- rt->M0(obj, rt->E3.string, K9::SUB0_CTX);
- return icast(obj->H8, H10::Z9::Z2)->Q12;
- }
- J10 *J0(const std::string &N11, K9 *rt) {
- B2();
- auto res = rt->make(rt->E3.string, K9::INSTANCE_OBJECT);
- L1(res) = N11;
- return res;
- }
- }
- namespace H10::Z9 {
- K2::K2(K9 *rt)
- : G8(rt, sizeof(K2)) {
- B2();
- }
- K2::~K2() {
- B2();
- }
- G8 *K2::copy(K9 *rt) {
- B2();
- G8 *res = new K2(rt);
- if (res == nullptr) {
- rt->T4("Failed to copy " + this->userRepr(rt), rt->R5().area);
- }
- return res;
- }
- size_t K2::getSize() {
- B2();
- return sizeof(K2);
- }
- size_t K5::getG8Size() {
- B2();
- return sizeof(K2);
- }
- std::string K2::userRepr(K9 *rt) {
- B2();
- if (this == nullptr) {
- return "Nothing(nullptr)";
- }
- return "Nothing";
- }
- static J10 *NothingEqL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- rt->O2(self, rt->E3.nothing, K9::SUB0_CTX);
- rt->U0(arg, K9::SUB1_CTX);
- if (!rt->F8(arg, rt->E3.nothing)) {
- return rt->R1(false);
- }
- return rt->R1(true);
- }
- static J10 *NothingNeqL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- auto res = NothingEqL9(self, arg, rt, I0);
- return rt->R1(!W0(res));
- }
- static J10 *nothing_U6(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->O2(self, rt->E3.nothing, K9::SUB1_CTX);
- if (!I0) {
- return self;
- }
- if (rt->B4(self, nullptr)) {
- return J0("Nothing", rt);
- }
- return J0("nothing", rt);
- }
- void installNothingMethods(I12 *type, K9 *rt) {
- B2();
- type->S7(N4::U6(rt),
- Z9::C0(true, nothing_U6, nullptr, rt));
- }
- K5::K5(K9 *rt)
- : I12(rt) {
- B2();
- this->G12 = NothingEqL9;
- this->I11 = NothingNeqL9;
- }
- J10 *K5::create(K9 *rt) {
- B2();
- G8 *ins = new K2(rt);
- J10 *obj = new J10(true, ins, this, rt);
- return obj;
- }
- std::string K5::userRepr(K9 *rt) {
- B2();
- if (this == nullptr) {
- return "K5(nullptr)";
- }
- return "K5";
- }
- J10 *K5::copy(J10 *obj, K9 *rt) {
- B2();
- rt->O2(obj, rt->E3.nothing);
- if (obj->H8 == nullptr) {
- return new J10(false, nullptr, this, rt);
- }
- auto ins = obj->H8->copy(rt);
- auto res = new J10(true, ins, this, rt);
- return res;
- }
- J10 *H0(K9 *rt) {
- B2();
- auto res = rt->make(rt->E3.nothing, rt->INSTANCE_OBJECT);
- return res;
- }
- }
- namespace H10::Z9 {
- L4::L4(K9 *rt)
- : G8(rt, sizeof(L4)) {
- B2();
- this->N11 = 0;
- }
- L4::~L4() {
- B2();
- }
- G8 *L4::copy(K9 *rt) {
- B2();
- G8 *res = new L4(rt);
- if (res == nullptr) {
- rt->T4("Failed to copy " + this->userRepr(rt), rt->R5().area);
- }
- icast(res, L4)->N11 = this->N11;
- return res;
- }
- std::string L4::userRepr(K9 *rt) {
- B2();
- if (this == nullptr) {
- return "Real(nullptr)";
- }
- return "Real(N11 = " + std::to_string(this->N11) + ")";
- }
- size_t L4::getSize() {
- B2();
- return sizeof(L4);
- }
- size_t D9::getG8Size() {
- B2();
- return sizeof(L4);
- }
- static J10 *RealPositiveL9(J10 *self, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.real, K9::SUB0_CTX);
- if (!I0) {
- return nullptr;
- }
- auto res = self->type->copy(self, rt);
- return res;
- }
- static J10 *RealNegativeL9(J10 *self, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.real, K9::SUB0_CTX);
- if (!I0) {
- return nullptr;
- }
- auto res = self->type->copy(self, rt);
- Z1(res) *= -1;
- return res;
- }
- static J10 *RealMultL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.real, K9::SUB0_CTX);
- rt->M0(arg, rt->E3.real, K9::SUB1_CTX);
- if (!I0) {
- return nullptr;
- }
- auto res = makeL4J10(Z1(self) * Z1(arg), rt);
- return res;
- }
- static J10 *RealDivL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.real, K9::SUB0_CTX);
- rt->M0(arg, rt->E3.real, K9::SUB1_CTX);
- if (!I0) {
- return nullptr;
- }
- auto res = makeL4J10(Z1(self) / Z1(arg), rt);
- return res;
- }
- static J10 *RealAddL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.real, K9::SUB0_CTX);
- rt->M0(arg, rt->E3.real, K9::SUB1_CTX);
- if (!I0) {
- return nullptr;
- }
- auto res = makeL4J10(Z1(self) + Z1(arg), rt);
- return res;
- }
- static J10 *RealSubL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.real, K9::SUB0_CTX);
- rt->M0(arg, rt->E3.real, K9::SUB1_CTX);
- if (!I0) {
- return nullptr;
- }
- auto res = makeL4J10(Z1(self) - Z1(arg), rt);
- return res;
- }
- static J10 *RealLtL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.real, K9::SUB0_CTX);
- rt->M0(arg, rt->E3.real, K9::SUB1_CTX);
- return rt->R1(Z1(self) < Z1(arg));
- }
- static J10 *RealLeqL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.real, K9::SUB0_CTX);
- rt->M0(arg, rt->E3.real, K9::SUB1_CTX);
- return rt->R1(Z1(self) <= Z1(arg));
- }
- static J10 *RealGtL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.real, K9::SUB0_CTX);
- rt->M0(arg, rt->E3.real, K9::SUB1_CTX);
- return rt->R1(Z1(self) > Z1(arg));
- }
- static J10 *RealGeqL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.real, K9::SUB0_CTX);
- rt->M0(arg, rt->E3.real, K9::SUB1_CTX);
- return rt->R1(Z1(self) >= Z1(arg));
- }
- static J10 *RealEqL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- rt->O2(self, rt->E3.real, K9::SUB0_CTX);
- rt->U0(arg, K9::SUB1_CTX);
- if (!rt->F8(arg, rt->E3.real)) {
- return rt->R1(false);
- }
- if (rt->Q1(self, rt->E3.real)) {
- if (!rt->Q1(arg, rt->E3.real)) {
- return rt->R1(false);
- }
- return rt->R1(Z1(self) == Z1(arg));
- }
- else if (rt->B4(self, rt->E3.real)) {
- if (!rt->B4(arg, rt->E3.real)) {
- return rt->R1(false);
- }
- return rt->R1(true);
- }
- return rt->R1(false);
- }
- static J10 *RealNeqL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- auto res = RealEqL9(self, arg, rt, I0);
- return rt->R1(!W0(res));
- }
- static J10 *real_S6(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->M0(self, rt->E3.real, K9::SUB1_CTX);
- if (!I0) {
- return self;
- }
- return rt->R1(Z1(self));
- }
- static J10 *real_T6(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->M0(self, rt->E3.real, K9::SUB1_CTX);
- if (!I0) {
- return self;
- }
- return B0(Z1(self), rt);
- }
- static J10 *real_W7(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->M0(self, rt->E3.real, K9::SUB1_CTX);
- if (!I0) {
- return self;
- }
- return G0(Z1(self), rt);
- }
- static J10 *real_mm__real__(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->M0(self, rt->E3.real, K9::SUB1_CTX);
- if (!I0) {
- return self;
- }
- return makeL4J10(Z1(self), rt);
- }
- static J10 *real_S4(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->M0(self, rt->E3.real, K9::SUB1_CTX);
- if (!I0) {
- return self;
- }
- return J0(std::to_string(Z1(self)), rt);
- }
- static J10 *real_U6(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->O2(self, rt->E3.real, K9::SUB1_CTX);
- if (!I0) {
- return self;
- }
- if (rt->B4(self, nullptr)) {
- return J0("Real", rt);
- }
- return J0(std::to_string(Z1(self)), rt);
- }
- static J10 *real_V6(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->O2(self, rt->E3.real, K9::SUB1_CTX);
- double v;
- std::cin >> v;
- if (!I0) {
- return self;
- }
- return makeL4J10(v, rt);
- }
- void installRealMethods(I12 *type, K9 *rt) {
- B2();
- type->S7(N4::S6(rt),
- Z9::C0(true, real_S6, nullptr, rt));
- type->S7(N4::T6(rt),
- Z9::C0(true, real_T6, nullptr, rt));
- type->S7(N4::W7(rt),
- Z9::C0(true, real_W7, nullptr, rt));
- type->S7(N4::mm__real__(rt),
- Z9::C0(true, real_mm__real__, nullptr, rt));
- type->S7(N4::S4(rt),
- Z9::C0(true, real_S4, nullptr, rt));
- type->S7(N4::U6(rt),
- Z9::C0(true, real_U6, nullptr, rt));
- type->S7(N4::V6(rt),
- Z9::C0(true, real_V6, nullptr, rt));
- }
- D9::D9(K9 *rt)
- : I12(rt) {
- B2();
- this->O5 = RealPositiveL9;
- this->P5 = RealNegativeL9;
- this->F10 = RealMultL9;
- this->C11 = RealDivL9;
- this->E11 = RealAddL9;
- this->F11 = RealSubL9;
- this->E12 = RealLtL9;
- this->G11 = RealLeqL9;
- this->F12 = RealGtL9;
- this->H11 = RealGeqL9;
- this->G12 = RealEqL9;
- this->I11 = RealNeqL9;
- }
- J10 *D9::create(K9 *rt) {
- B2();
- G8 *ins = new L4(rt);
- J10 *obj = new J10(true, ins, this, rt);
- return obj;
- }
- J10 *D9::copy(J10 *obj, K9 *rt) {
- B2();
- rt->O2(obj, rt->E3.real);
- if (obj->H8 == nullptr) {
- return new J10(false, nullptr, this, rt);
- }
- auto ins = obj->H8->copy(rt);
- auto res = new J10(true, ins, this, rt);
- return res;
- }
- std::string D9::userRepr(K9 *rt) {
- B2();
- if (this == nullptr) {
- return "D9(nullptr)";
- }
- return "D9";
- }
- double &getRealValue(J10 *obj, K9 *rt) {
- B2();
- rt->M0(obj, rt->E3.real);
- return icast(obj->H8, H10::Z9::L4)->N11;
- }
- double &getRealValue(J10 *obj, K9 *rt, K9::ContextId ctx_id) {
- B2();
- rt->M0(obj, rt->E3.real, K9::SUB0_CTX);
- return icast(obj->H8, H10::Z9::L4)->N11;
- }
- J10 *makeL4J10(double N11, K9 *rt) {
- B2();
- auto res = rt->make(rt->E3.real, K9::INSTANCE_OBJECT);
- icast(res->H8, L4)->N11 = N11;
- return res;
- }
- }
- namespace H10::Z9 {
- RecordG8::RecordG8(K9 *rt)
- : G8(rt, sizeof(RecordG8)) {
- B2();
- }
- RecordG8::~RecordG8() {
- B2();
- }
- J10 *RecordG8::selectField(I10 id, K9 *rt) {
- B2();
- auto it = this->Q10.find(id);
- if (it != this->Q10.end()) {
- return it->second;
- }
- rt->T4(this->userRepr(rt) + "doesn't have S11 " + rt->S12->R7(id), rt->R5().area);
- }
- bool RecordG8::hasField(I10 id, K9 *rt) {
- B2();
- return this->Q10.find(id) != this->Q10.end();
- }
- void RecordG8::addField(I10 id, J10 *obj, K9 *rt) {
- B2();
- this->Q10[id] = obj;
- }
- G8 *RecordG8::copy(K9 *rt) {
- B2();
- return this; }
- size_t RecordG8::getSize() {
- B2();
- return sizeof(RecordG8);
- }
- size_t RecordI12::getG8Size() {
- B2();
- return sizeof(RecordG8);
- }
- std::string RecordG8::userRepr(K9 *rt) {
- B2();
- if (this == nullptr) {
- return "Record(nullptr)";
- }
- return rt->S12->R7(this->Y10);
- }
- std::vector<J10 *> RecordG8::getGCReachable() {
- B2();
- std::vector<J10 *> res;
- for (auto S11 : this->Q10) {
- res.push_back(S11.second);
- }
- return res;
- }
- RecordI12::RecordI12(K9 *rt)
- : I12(rt) {
- B2();
- }
- J10 *RecordI12::create(K9 *rt) {
- B2();
- auto ins = new RecordG8(rt);
- ins->Y10 = this->Y10;
- for (auto f : this->H8_Q10) {
- ins->addField(f, H0(rt), rt);
- }
- J10 *obj = new J10(true, ins, this, rt);
- return obj;
- }
- std::string RecordI12::userRepr(K9 *rt) {
- B2();
- if (this == nullptr) {
- return "nullptr";
- }
- return rt->S12->R7(this->Y10);
- }
- J10 *RecordI12::copy(J10 *obj, K9 *rt) {
- B2();
- rt->U0(obj);
- if (obj->H8 == nullptr) {
- return new J10(false, nullptr, this, rt);
- }
- auto ins = obj->H8->copy(rt);
- auto res = new J10(true, ins, this, rt);
- return res;
- }
- J10 *makeRecordG8J10(K9 *rt) {
- B2();
- auto res = rt->make(rt->E3.nothing, rt->INSTANCE_OBJECT);
- return res;
- }
- RecordI12 *makeRecordI12(I10 Y10, K9 *rt) {
- B2();
- auto res = new RecordI12(rt);
- res->Y10 = Y10;
- return res;
- }
- }
- namespace H10::Z9 {
- I2::I2(K9 *rt)
- : G8(rt, sizeof(I2)) {
- B2();
- this->N11 = false;
- }
- I2::~I2() {
- B2();
- }
- G8 *I2::copy(K9 *rt) {
- B2();
- G8 *res = new I2(rt);
- if (res == nullptr) {
- rt->T4("Failed to copy " + this->userRepr(rt), rt->R5().area);
- }
- icast(res, I2)->N11 = this->N11;
- return res;
- }
- std::string I2::userRepr(K9 *rt) {
- B2();
- if (this == nullptr) {
- return "Boolean(nullptr)";
- }
- return std::string("Boolean(N11 = ") + (this->N11 ? "true" : "false") + ")";
- }
- size_t I2::getSize() {
- B2();
- return sizeof(I2);
- }
- size_t I5::getG8Size() {
- B2();
- return sizeof(I2);
- }
- static J10 *BooleanNotL9(J10 *self, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.boolean, K9::SUB0_CTX);
- return (!W0(self)) ? rt->R1(true) : rt->R1(false);
- }
- static J10 *BooleanEqL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- rt->O2(self, rt->E3.boolean, K9::SUB0_CTX);
- rt->U0(arg, K9::SUB1_CTX);
- if (!rt->F8(arg, rt->E3.boolean)) {
- return rt->R1(false);
- }
- if (rt->Q1(self, rt->E3.boolean)) {
- if (!rt->Q1(arg, rt->E3.boolean)) {
- return rt->R1(false);
- }
- return rt->R1(W0(self) == W0(arg));
- }
- else if (rt->B4(self, rt->E3.boolean)) {
- if (!rt->B4(arg, rt->E3.boolean)) {
- return rt->R1(false);
- }
- return rt->R1(true);
- }
- return rt->R1(false);
- }
- static J10 *BooleanNeqL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- auto res = BooleanEqL9(self, arg, rt, I0);
- return (!getBooleanValue(res, rt)) ? rt->R1(true) : rt->R1(false);
- }
- static J10 *BooleanAndL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.boolean, K9::SUB0_CTX);
- rt->M0(arg, rt->E3.boolean, K9::SUB1_CTX);
- return rt->R1(W0(self) && W0(arg));
- }
- static J10 *BooleanOrL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.boolean, K9::SUB0_CTX);
- rt->M0(arg, rt->E3.boolean, K9::SUB1_CTX);
- return rt->R1(W0(self) || W0(arg));
- }
- static J10 *boolean_S6(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->M0(self, rt->E3.boolean, K9::SUB1_CTX);
- if (!I0) {
- return self;
- }
- if (rt->B4(self, nullptr)) {
- return rt->R1(false);
- }
- return self;
- }
- static J10 *boolean_T6(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->M0(self, rt->E3.boolean, K9::SUB1_CTX);
- if (!I0) {
- return self;
- }
- return B0('0' + W0(self), rt);
- }
- static J10 *boolean_W7(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->M0(self, rt->E3.boolean, K9::SUB1_CTX);
- if (!I0) {
- return self;
- }
- return G0(W0(self), rt);
- }
- static J10 *boolean_mm__real__(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->M0(self, rt->E3.boolean, K9::SUB1_CTX);
- if (!I0) {
- return self;
- }
- return makeL4J10(W0(self), rt);
- }
- static J10 *boolean_S4(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->O2(self, rt->E3.boolean, K9::SUB1_CTX);
- if (!I0) {
- return self;
- }
- if (rt->B4(self, nullptr)) {
- return J0("Boolean", rt);
- }
- return J0(W0(self) ? "true" : "false", rt);
- }
- static J10 *boolean_U6(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->O2(self, rt->E3.boolean, K9::SUB1_CTX);
- if (!I0) {
- return self;
- }
- if (rt->B4(self, nullptr)) {
- return J0("Boolean", rt);
- }
- return J0(W0(self) ? "true" : "false", rt);
- }
- static J10 *boolean_V6(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->O2(self, rt->E3.boolean, K9::SUB1_CTX);
- std::string s;
- std::cin >> s;
- if (!I0) {
- return self;
- }
- if (s == "true") {
- return rt->R1(true);
- }
- else if (s == "false") {
- return rt->R1(false);
- }
- rt->T4("Not a Boolean: " + s, rt->R5().area);
- }
- void installBooleanMethods(I12 *type, K9 *rt) {
- B2();
- type->S7(N4::S6(rt),
- Z9::C0(true, boolean_S6, nullptr, rt));
- type->S7(N4::T6(rt),
- Z9::C0(true, boolean_T6, nullptr, rt));
- type->S7(N4::W7(rt),
- Z9::C0(true, boolean_W7, nullptr, rt));
- type->S7(N4::mm__real__(rt),
- Z9::C0(true, boolean_mm__real__, nullptr, rt));
- type->S7(N4::S4(rt),
- Z9::C0(true, boolean_S4, nullptr, rt));
- type->S7(N4::U6(rt),
- Z9::C0(true, boolean_U6, nullptr, rt));
- type->S7(N4::V6(rt),
- Z9::C0(true, boolean_V6, nullptr, rt));
- }
- I5::I5(K9 *rt)
- : I12(rt) {
- B2();
- this->B11 = BooleanNotL9;
- this->G12 = BooleanEqL9;
- this->I11 = BooleanNeqL9;
- this->J11 = BooleanAndL9;
- this->H12 = BooleanOrL9;
- }
- J10 *I5::create(K9 *rt) {
- B2();
- G8 *ins = new I2(rt);
- J10 *obj = new J10(true, ins, this, rt);
- return obj;
- }
- J10 *I5::copy(J10 *obj, K9 *rt) {
- B2();
- rt->O2(obj, rt->E3.boolean);
- if (obj->H8 == nullptr) {
- return new J10(false, nullptr, this, rt);
- }
- auto ins = obj->H8->copy(rt);
- auto res = new J10(true, ins, this, rt);
- return res;
- }
- std::string I5::userRepr(K9 *rt) {
- B2();
- if (this == nullptr) {
- return "I5(nullptr)";
- }
- return "I5";
- }
- bool &getBooleanValue(J10 *obj, K9 *rt) {
- B2();
- rt->M0(obj, rt->E3.boolean);
- return icast(obj->H8, H10::Z9::I2)->N11;
- }
- bool &getBooleanValue(J10 *obj, K9 *rt, K9::ContextId ctx_id) {
- B2();
- rt->M0(obj, rt->E3.boolean, K9::SUB0_CTX);
- return icast(obj->H8, H10::Z9::I2)->N11;
- }
- J10 *F0(bool N11, K9 *rt) {
- B2();
- auto res = rt->make(rt->E3.boolean, K9::INSTANCE_OBJECT);
- icast(res->H8, I2)->N11 = N11;
- return res;
- }
- }
- namespace H10::Z9 {
- J2::J2(K9 *rt)
- : G8(rt, sizeof(J2)) {
- B2();
- this->N11 = 0;
- }
- J2::~J2() {
- B2();
- }
- G8 *J2::copy(K9 *rt) {
- B2();
- G8 *res = new J2(rt);
- if (res == nullptr) {
- rt->T4("Failed to copy " + this->userRepr(rt), rt->R5().area);
- }
- icast(res, J2)->N11 = this->N11;
- return res;
- }
- std::string J2::userRepr(K9 *rt) {
- B2();
- if (this == nullptr) {
- return "Integer(nullptr)";
- }
- return "Integer(N11 = " + std::to_string(this->N11) + ")";
- }
- size_t J2::getSize() {
- B2();
- return sizeof(J2);
- }
- size_t J5::getG8Size() {
- B2();
- return sizeof(J2);
- }
- static J10 *IntegerPostincL9(J10 *self, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.integer, K9::SUB0_CTX);
- if (!I0) {
- V0(self)++;
- return nullptr;
- }
- auto res = self->type->copy(self, rt);
- V0(self)++;
- return res;
- }
- static J10 *IntegerPostdecL9(J10 *self, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.integer, K9::SUB0_CTX);
- if (!I0) {
- V0(self)--;
- return nullptr;
- }
- auto res = self->type->copy(self, rt);
- V0(self)--;
- return res;
- }
- static J10 *IntegerPreincL9(J10 *self, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.integer, K9::SUB0_CTX);
- if (!I0) {
- V0(self)++;
- return nullptr;
- }
- V0(self)++;
- auto res = self->type->copy(self, rt);
- return res;
- }
- static J10 *IntegerPredecL9(J10 *self, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.integer, K9::SUB0_CTX);
- if (!I0) {
- V0(self)--;
- return nullptr;
- }
- V0(self)--;
- auto res = self->type->copy(self, rt);
- return res;
- }
- static J10 *IntegerPositiveL9(J10 *self, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.integer, K9::SUB0_CTX);
- if (!I0) {
- return nullptr;
- }
- auto res = self->type->copy(self, rt);
- return res;
- }
- static J10 *IntegerNegativeL9(J10 *self, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.integer, K9::SUB0_CTX);
- if (!I0) {
- return nullptr;
- }
- auto res = self->type->copy(self, rt);
- V0(res) *= -1;
- return res;
- }
- static J10 *IntegerInverseL9(J10 *self, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.integer, K9::SUB0_CTX);
- if (!I0) {
- return nullptr;
- }
- auto res = self->type->copy(self, rt);
- V0(res) = ~V0(res);
- return res;
- }
- static J10 *IntegerMultL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.integer, K9::SUB0_CTX);
- rt->M0(arg, rt->E3.integer, K9::SUB1_CTX);
- if (!I0) {
- return nullptr;
- }
- auto res = G0(V0(self) * V0(arg), rt);
- return res;
- }
- static J10 *IntegerDivL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.integer, K9::SUB0_CTX);
- rt->M0(arg, rt->E3.integer, K9::SUB1_CTX);
- if (!I0) {
- return nullptr;
- }
- auto res = G0(V0(self) / V0(arg), rt);
- return res;
- }
- static J10 *IntegerRemL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.integer, K9::SUB0_CTX);
- rt->M0(arg, rt->E3.integer, K9::SUB1_CTX);
- if (!I0) {
- return nullptr;
- }
- auto res = G0(V0(self) % V0(arg), rt);
- return res;
- }
- static J10 *IntegerRshiftL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.integer, K9::SUB0_CTX);
- rt->M0(arg, rt->E3.integer, K9::SUB1_CTX);
- if (!I0) {
- return nullptr;
- }
- auto res = G0(V0(self) >> V0(arg), rt);
- return res;
- }
- static J10 *IntegerLshiftL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.integer, K9::SUB0_CTX);
- rt->M0(arg, rt->E3.integer, K9::SUB1_CTX);
- if (!I0) {
- return nullptr;
- }
- auto res = G0(V0(self) << V0(arg), rt);
- return res;
- }
- static J10 *IntegerAddL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.integer, K9::SUB0_CTX);
- rt->M0(arg, rt->E3.integer, K9::SUB1_CTX);
- if (!I0) {
- return nullptr;
- }
- auto res = G0(V0(self) + V0(arg), rt);
- return res;
- }
- static J10 *IntegerSubL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.integer, K9::SUB0_CTX);
- rt->M0(arg, rt->E3.integer, K9::SUB1_CTX);
- if (!I0) {
- return nullptr;
- }
- auto res = G0(V0(self) - V0(arg), rt);
- return res;
- }
- static J10 *IntegerLtL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.integer, K9::SUB0_CTX);
- rt->M0(arg, rt->E3.integer, K9::SUB1_CTX);
- return rt->R1(V0(self) < V0(arg));
- }
- static J10 *IntegerLeqL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.integer, K9::SUB0_CTX);
- rt->M0(arg, rt->E3.integer, K9::SUB1_CTX);
- return rt->R1(V0(self) <= V0(arg));
- }
- static J10 *IntegerGtL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.integer, K9::SUB0_CTX);
- rt->M0(arg, rt->E3.integer, K9::SUB1_CTX);
- return rt->R1(V0(self) > V0(arg));
- }
- static J10 *IntegerGeqL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.integer, K9::SUB0_CTX);
- rt->M0(arg, rt->E3.integer, K9::SUB1_CTX);
- return rt->R1(V0(self) >= V0(arg));
- }
- static J10 *IntegerEqL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- rt->O2(self, rt->E3.integer, K9::SUB0_CTX);
- rt->U0(arg, K9::SUB1_CTX);
- if (!rt->F8(arg, rt->E3.integer)) {
- return rt->R1(false);
- }
- if (rt->Q1(self, rt->E3.integer)) {
- if (!rt->Q1(arg, rt->E3.integer)) {
- return rt->R1(false);
- }
- return rt->R1(V0(self) == V0(arg));
- }
- else if (rt->B4(self, rt->E3.integer)) {
- if (!rt->B4(arg, rt->E3.integer)) {
- return rt->R1(false);
- }
- return rt->R1(true);
- }
- return rt->R1(false);
- }
- static J10 *IntegerNeqL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- auto res = IntegerEqL9(self, arg, rt, I0);
- return rt->R1(!W0(res));
- }
- static J10 *IntegerBitandL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.integer, K9::SUB0_CTX);
- rt->M0(arg, rt->E3.integer, K9::SUB1_CTX);
- if (!I0) {
- return nullptr;
- }
- auto res = G0(V0(self) & V0(arg), rt);
- return res;
- }
- static J10 *IntegerBitxorL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.integer, K9::SUB0_CTX);
- rt->M0(arg, rt->E3.integer, K9::SUB1_CTX);
- if (!I0) {
- return nullptr;
- }
- auto res = G0(V0(self) ^ V0(arg), rt);
- return res;
- }
- static J10 *IntegerBitorL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.integer, K9::SUB0_CTX);
- rt->M0(arg, rt->E3.integer, K9::SUB1_CTX);
- if (!I0) {
- return nullptr;
- }
- auto res = G0(V0(self) | V0(arg), rt);
- return res;
- }
- static J10 *integer_S6(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->M0(self, rt->E3.integer, K9::SUB1_CTX);
- if (!I0) {
- return self;
- }
- return rt->R1(V0(self));
- }
- static J10 *integer_T6(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->M0(self, rt->E3.integer, K9::SUB1_CTX);
- if (!I0) {
- return self;
- }
- return B0(V0(self), rt);
- }
- static J10 *integer_W7(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->M0(self, rt->E3.integer, K9::SUB1_CTX);
- if (!I0) {
- return self;
- }
- return G0(V0(self), rt);
- }
- static J10 *integer_mm__real__(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->M0(self, rt->E3.integer, K9::SUB1_CTX);
- if (!I0) {
- return self;
- }
- return makeL4J10(V0(self), rt);
- }
- static J10 *integer_S4(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->M0(self, rt->E3.integer, K9::SUB1_CTX);
- if (!I0) {
- return self;
- }
- return J0(std::to_string(V0(self)), rt);
- }
- static J10 *integer_U6(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->O2(self, rt->E3.integer, K9::SUB1_CTX);
- if (!I0) {
- return self;
- }
- if (rt->B4(self, nullptr)) {
- return J0("Integer", rt);
- }
- return J0(std::to_string(V0(self)), rt);
- }
- static J10 *integer_V6(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->O2(self, rt->E3.integer, K9::SUB1_CTX);
- int64_t v;
- std::cin >> v;
- if (!I0) {
- return self;
- }
- return G0(v, rt);
- }
- void installIntegerMethods(I12 *type, K9 *rt) {
- B2();
- type->S7(N4::S6(rt),
- Z9::C0(true, integer_S6, nullptr, rt));
- type->S7(N4::T6(rt),
- Z9::C0(true, integer_T6, nullptr, rt));
- type->S7(N4::W7(rt),
- Z9::C0(true, integer_W7, nullptr, rt));
- type->S7(N4::mm__real__(rt),
- Z9::C0(true, integer_mm__real__, nullptr, rt));
- type->S7(N4::S4(rt),
- Z9::C0(true, integer_S4, nullptr, rt));
- type->S7(N4::U6(rt),
- Z9::C0(true, integer_U6, nullptr, rt));
- type->S7(N4::V6(rt),
- Z9::C0(true, integer_V6, nullptr, rt));
- }
- J5::J5(K9 *rt)
- : I12(rt) {
- B2();
- this->W6 = IntegerPostincL9;
- this->X6 = IntegerPostdecL9;
- this->Y7 = IntegerPreincL9;
- this->Z7 = IntegerPredecL9;
- this->O5 = IntegerPositiveL9;
- this->P5 = IntegerNegativeL9;
- this->Y6 = IntegerInverseL9;
- this->F10 = IntegerMultL9;
- this->C11 = IntegerDivL9;
- this->D11 = IntegerRemL9;
- this->A8 = IntegerRshiftL9;
- this->B8 = IntegerLshiftL9;
- this->E11 = IntegerAddL9;
- this->F11 = IntegerSubL9;
- this->E12 = IntegerLtL9;
- this->G11 = IntegerLeqL9;
- this->F12 = IntegerGtL9;
- this->H11 = IntegerGeqL9;
- this->G12 = IntegerEqL9;
- this->I11 = IntegerNeqL9;
- this->C8 = IntegerBitandL9;
- this->D8 = IntegerBitxorL9;
- this->I9 = IntegerBitorL9;
- }
- J10 *J5::create(K9 *rt) {
- B2();
- G8 *ins = new J2(rt);
- J10 *obj = new J10(true, ins, this, rt);
- return obj;
- }
- J10 *J5::copy(J10 *obj, K9 *rt) {
- B2();
- rt->O2(obj, rt->E3.integer);
- if (obj->H8 == nullptr) {
- return new J10(false, nullptr, this, rt);
- }
- auto ins = obj->H8->copy(rt);
- auto res = new J10(true, ins, this, rt);
- return res;
- }
- std::string J5::userRepr(K9 *rt) {
- B2();
- if (this == nullptr) {
- return "J5(nullptr)";
- }
- return "J5";
- }
- int64_t &getIntegerValue(J10 *obj, K9 *rt) {
- B2();
- rt->M0(obj, rt->E3.integer);
- return icast(obj->H8, H10::Z9::J2)->N11;
- }
- int64_t &getIntegerValue(J10 *obj, K9 *rt, K9::ContextId ctx_id) {
- B2();
- rt->M0(obj, rt->E3.integer, K9::SUB0_CTX);
- return icast(obj->H8, H10::Z9::J2)->N11;
- }
- J10 *G0(int64_t N11, K9 *rt) {
- B2();
- auto res = rt->make(rt->E3.integer, K9::INSTANCE_OBJECT);
- icast(res->H8, J2)->N11 = N11;
- return res;
- }
- }
- namespace H10::Z9 {
- U3::U3(K9 *rt)
- : G8(rt, sizeof(U3)) {
- B2();
- this->Q12 = {};
- }
- U3::~U3() {
- B2();
- }
- G8 *U3::copy(K9 *rt) {
- B2();
- G8 *res = new U3(rt);
- if (res == nullptr) {
- rt->T4("Failed to copy " + this->userRepr(rt), rt->R5().area);
- }
- for (auto obj : this->Q12) {
- ((U3 *)res)->Q12.push_back(rt->copy(obj));
- }
- return res;
- }
- std::string U3::userRepr(K9 *rt) {
- B2();
- if (this == nullptr) {
- return "Array(nullptr)";
- }
- return "Array(size = " + std::to_string(this->Q12.size()) + ", Q12 = ...)";
- }
- size_t U3::getSize() {
- B2();
- return sizeof(U3);
- }
- std::vector<J10 *> U3::getGCReachable() {
- B2();
- auto res = G8::getGCReachable();
- for (auto obj : this->Q12) {
- res.push_back(obj);
- }
- return res;
- }
- void U3::spreadSingleUse() {
- B2();
- for (auto obj : this->Q12) {
- obj->spreadSingleUse();
- }
- }
- void U3::Y2() {
- B2();
- for (auto obj : this->Q12) {
- obj->Y2();
- }
- }
- size_t Q7::getG8Size() {
- B2();
- return sizeof(U3);
- }
- static J10 *ArrayIndexL9(J10 *self, const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->M0(self, rt->E3.array, K9::SUB0_CTX);
- rt->D0(args, 1);
- auto &arg = args[0];
- rt->M0(arg, rt->E3.integer, K9::SUB1_CTX);
- if (!(0 <= V0(arg) && V0(arg) < getArrayDataFast(self).size())) {
- rt->T4("Index " + arg->userRepr(rt) + " is out of array " + self->userRepr(rt) + " range", rt->R5().sub_areas[1]);
- }
- return getArrayDataFast(self)[V0(arg)];
- }
- static J10 *ArrayEqL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- rt->O2(self, rt->E3.array, K9::SUB0_CTX);
- rt->U0(arg, K9::SUB1_CTX);
- if (!I0) {
- return rt->R1(false);
- }
- if (!rt->F8(arg, rt->E3.array)) {
- return rt->R1(false);
- }
- if (rt->Q1(self, rt->E3.array)) {
- if (!rt->Q1(arg, rt->E3.array)) {
- return rt->R1(false);
- }
- auto a1 = getArrayDataFast(self);
- auto a2 = getArrayDataFast(self);
- if (a1.size() != a2.size()) {
- return rt->R1(false);
- }
- for (int64_t i = 0; i < a1.size(); i++) {
- auto &ta = rt->R5().area;
- rt->S5();
- rt->R5().area = ta;
- rt->R5().sub_areas = {ta, ta};
- auto res = rt->H5(I4::V11, a1[i], a2[i], true);
- rt->T5();
- if (!W0(res)) {
- return rt->R1(false);
- }
- }
- return rt->R1(true);
- }
- else if (rt->B4(self, rt->E3.array)) {
- if (!rt->B4(arg, rt->E3.array)) {
- return rt->R1(false);
- }
- return rt->R1(true);
- }
- return rt->R1(false);
- }
- static J10 *ArrayNeqL9(J10 *self, J10 *arg, K9 *rt, bool I0) {
- B2();
- auto res = ArrayEqL9(self, arg, rt, I0);
- return rt->R1(!W0(res));
- }
- static J10 *arraySizeMethod(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->M0(self, rt->E3.array, K9::SUB0_CTX);
- if (!I0) {
- return nullptr;
- }
- return G0(getArrayDataFast(self).size(), rt);
- }
- static J10 *arrayResizeMethod(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 1);
- auto self = args[0];
- auto new_size = args[1];
- rt->M0(self, rt->E3.array, K9::SUB0_CTX);
- rt->M0(new_size, rt->E3.integer, K9::SUB1_CTX);
- int64_t oldn = getArrayDataFast(self).size();
- int64_t newn = V0(new_size);
- if (newn <= 0) {
- rt->T4("New array size must be positive: " + new_size->userRepr(rt), rt->R5().sub_areas[1]);
- }
- getArrayDataFast(self).resize(newn);
- for (int64_t i = oldn; i < newn; i++) {
- getArrayDataFast(self)[i] = H0(rt);
- }
- if (!self->single_use) {
- self->Y2();
- }
- return self;
- }
- static J10 *arrayAppendMethod(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- rt->E0(args, 1);
- auto self = args[0];
- rt->M0(self, rt->E3.array, K9::SUB1_CTX);
- auto &Q12 = getArrayDataFast(self);
- for (int64_t i = 1; i < args.size(); i++) {
- rt->U0(args[i], (K9::ContextId)i);
- Q12.push_back(args[i]);
- }
- return self;
- }
- static J10 *arrayPrependMethod(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- rt->E0(args, 1);
- auto self = args[0];
- rt->M0(self, rt->E3.array, K9::SUB1_CTX);
- auto &Q12 = getArrayDataFast(self);
- std::vector<J10 *> pref;
- for (int64_t i = 1; i < args.size(); i++) {
- rt->U0(args[i], (K9::ContextId)i);
- pref.push_back(args[i]);
- }
- for (auto &item : Q12) {
- pref.push_back(item);
- }
- Q12 = pref;
- return self;
- }
- static J10 *arrayPoplastMethod(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- rt->A0(args, 0);
- auto self = args[0];
- rt->M0(self, rt->E3.array, K9::SUB1_CTX);
- auto &Q12 = getArrayDataFast(self);
- if (Q12.empty()) {
- return self;
- }
- Q12.pop_back();
- return self;
- }
- static J10 *arrayPopfirstMethod(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- rt->A0(args, 0);
- auto self = args[0];
- rt->M0(self, rt->E3.array, K9::SUB1_CTX);
- auto &Q12 = getArrayDataFast(self);
- if (Q12.empty()) {
- return self;
- }
- Q12.erase(Q12.begin());
- return self;
- }
- static J10 *arrayFirstMethod(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- rt->A0(args, 0);
- auto self = args[0];
- rt->M0(self, rt->E3.array, K9::SUB1_CTX);
- auto &Q12 = getArrayDataFast(self);
- if (Q12.empty()) {
- return rt->S1();
- }
- return Q12[0];
- }
- static J10 *arrayLastMethod(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- rt->A0(args, 0);
- auto self = args[0];
- rt->M0(self, rt->E3.array, K9::SUB1_CTX);
- auto &Q12 = getArrayDataFast(self);
- if (Q12.empty()) {
- return rt->S1();
- }
- return Q12.back();
- }
- static J10 *arrayEmptyMethod(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- rt->A0(args, 0);
- auto self = args[0];
- rt->M0(self, rt->E3.array, K9::SUB1_CTX);
- auto &Q12 = getArrayDataFast(self);
- return rt->R1(Q12.empty());
- }
- static J10 *arrayClearMethod(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- rt->A0(args, 0);
- auto self = args[0];
- rt->M0(self, rt->E3.array, K9::SUB1_CTX);
- auto &Q12 = getArrayDataFast(self);
- Q12.clear();
- return self;
- }
- static J10 *arrayCopyMethod(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- rt->A0(args, 0);
- auto self = args[0];
- rt->M0(self, rt->E3.array, K9::SUB1_CTX);
- return rt->copy(self);
- }
- static J10 *arrayFilterMethod(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- rt->A0(args, 1);
- auto self = args[0];
- auto arg = args[1];
- rt->M0(self, rt->E3.array, K9::SUB1_CTX);
- rt->M0(arg, rt->E3.function, K9::SUB2_CTX);
- std::vector<J10 *> new_Q12;
- auto ctx = rt->R5();
- rt->S5();
- rt->R5().area = ctx.area;
- rt->R5().sub_areas = {ctx.area, ctx.area};
- for (auto &obj : getArrayDataFast(self)) {
- auto res = rt->H5(I4::J12, arg, std::vector<J10 *> {obj}, true);
- if (getBooleanValue(res, rt)) {
- new_Q12.push_back(obj);
- }
- }
- rt->T5();
- getArrayDataFast(self) = new_Q12;
- return self;
- }
- static J10 *arrayApplyMethod(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- rt->A0(args, 1);
- auto self = args[0];
- auto arg = args[1];
- rt->M0(self, rt->E3.array, K9::SUB1_CTX);
- rt->M0(arg, rt->E3.function, K9::SUB2_CTX);
- auto ctx = rt->R5();
- rt->S5();
- rt->R5().area = ctx.area;
- rt->R5().sub_areas = {ctx.area, ctx.area};
- for (auto &obj : getArrayDataFast(self)) {
- rt->H5(I4::J12, arg, std::vector<J10 *> {obj}, true);
- }
- rt->T5();
- return self;
- }
- static J10 *arrayReverseMethod(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- rt->A0(args, 0);
- auto self = args[0];
- rt->M0(self, rt->E3.array, K9::SUB1_CTX);
- std::reverse(getArrayDataFast(self).begin(), getArrayDataFast(self).end());
- return self;
- }
- static J10 *arraySortMethod(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- rt->A0(args, 1);
- auto self = args[0];
- auto arg = args[1];
- rt->M0(self, rt->E3.array, K9::SUB1_CTX);
- rt->M0(arg, rt->E3.function, K9::SUB2_CTX);
- auto ctx = rt->R5();
- rt->S5();
- rt->R5().area = ctx.area;
- rt->R5().sub_areas = {ctx.area, ctx.area};
- std::sort(getArrayDataFast(self).begin(), getArrayDataFast(self).end(), [rt, arg](const auto &a, const auto &b) {
- auto res = rt->H5(I4::J12, arg, std::vector<J10 *> {a, b}, true);
- return getBooleanValue(res, rt);
- });
- rt->T5();
- return self;
- }
- static J10 *arrayCombineMethod(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- rt->A0(args, 2);
- auto self = args[0];
- auto arg = args[1];
- auto init = args[2];
- rt->M0(self, rt->E3.array, K9::SUB1_CTX);
- rt->M0(arg, rt->E3.function, K9::SUB2_CTX);
- rt->U0(init, K9::SUB3_CTX);
- auto ctx = rt->R5();
- rt->S5();
- rt->R5().area = ctx.area;
- rt->R5().sub_areas = {ctx.area, ctx.area};
- for (auto obj : getArrayDataFast(self)) {
- init = rt->H5(I4::J12, arg, std::vector<J10 *> {init, obj}, true);
- }
- rt->T5();
- return init;
- }
- static J10 *arrayFindfirstMethod(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- rt->A0(args, 1);
- auto self = args[0];
- auto arg = args[1];
- rt->M0(self, rt->E3.array, K9::SUB1_CTX);
- rt->M0(arg, rt->E3.function, K9::SUB2_CTX);
- auto ctx = rt->R5();
- rt->S5();
- rt->R5().area = ctx.area;
- rt->R5().sub_areas = {ctx.area, ctx.area};
- for (auto obj : getArrayDataFast(self)) {
- auto res = rt->H5(I4::J12, arg, std::vector<J10 *> {obj}, true);
- if (getBooleanValue(res, rt)) {
- rt->T5();
- return obj;
- }
- }
- rt->T5();
- return rt->S1();
- }
- static J10 *arrayFindlastMethod(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- rt->A0(args, 1);
- auto self = args[0];
- auto arg = args[1];
- rt->M0(self, rt->E3.array, K9::SUB1_CTX);
- rt->M0(arg, rt->E3.function, K9::SUB2_CTX);
- auto ctx = rt->R5();
- rt->S5();
- rt->R5().area = ctx.area;
- rt->R5().sub_areas = {ctx.area, ctx.area};
- for (auto it = getArrayDataFast(self).rend(); it != getArrayDataFast(self).rbegin(); it++) {
- auto res = rt->H5(I4::J12, arg, std::vector<J10 *> {*it}, true);
- if (getBooleanValue(res, rt)) {
- rt->T5();
- return *it;
- }
- }
- rt->T5();
- return rt->S1();
- }
- static J10 *arrayAllMethod(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- rt->A0(args, 1);
- auto self = args[0];
- auto arg = args[1];
- rt->M0(self, rt->E3.array, K9::SUB1_CTX);
- rt->M0(arg, rt->E3.function, K9::SUB2_CTX);
- auto ctx = rt->R5();
- rt->S5();
- rt->R5().area = ctx.area;
- rt->R5().sub_areas = {ctx.area, ctx.area};
- for (auto obj : getArrayDataFast(self)) {
- auto res = rt->H5(I4::J12, arg, std::vector<J10 *> {obj}, true);
- if (!getBooleanValue(res, rt)) {
- rt->T5();
- return rt->R1(false);
- }
- }
- rt->T5();
- return rt->R1(true);
- }
- static J10 *arrayAnyMethod(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- rt->A0(args, 1);
- auto self = args[0];
- auto arg = args[1];
- rt->M0(self, rt->E3.array, K9::SUB1_CTX);
- rt->M0(arg, rt->E3.function, K9::SUB2_CTX);
- auto ctx = rt->R5();
- rt->S5();
- rt->R5().area = ctx.area;
- rt->R5().sub_areas = {ctx.area, ctx.area};
- for (auto obj : getArrayDataFast(self)) {
- auto res = rt->H5(I4::J12, arg, std::vector<J10 *> {obj}, true);
- if (getBooleanValue(res, rt)) {
- rt->T5();
- return rt->R1(true);
- }
- }
- rt->T5();
- return rt->R1(false);
- }
- static J10 *arrayNoneMethod(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- rt->A0(args, 1);
- auto self = args[0];
- auto arg = args[1];
- rt->M0(self, rt->E3.array, K9::SUB1_CTX);
- rt->M0(arg, rt->E3.function, K9::SUB2_CTX);
- auto ctx = rt->R5();
- rt->S5();
- rt->R5().area = ctx.area;
- rt->R5().sub_areas = {ctx.area, ctx.area};
- for (auto obj : getArrayDataFast(self)) {
- auto res = rt->H5(I4::J12, arg, std::vector<J10 *> {obj}, true);
- if (getBooleanValue(res, rt)) {
- rt->T5();
- return rt->R1(false);
- }
- }
- rt->T5();
- return rt->R1(true);
- }
- static J10 *arrayCountMethod(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- rt->A0(args, 1);
- auto self = args[0];
- auto arg = args[1];
- rt->M0(self, rt->E3.array, K9::SUB1_CTX);
- rt->M0(arg, rt->E3.function, K9::SUB2_CTX);
- auto ctx = rt->R5();
- int64_t ans = 0;
- rt->S5();
- rt->R5().area = ctx.area;
- rt->R5().sub_areas = {ctx.area, ctx.area};
- for (auto obj : getArrayDataFast(self)) {
- auto res = rt->H5(I4::J12, arg, std::vector<J10 *> {obj}, true);
- if (getBooleanValue(res, rt)) {
- ans++;
- }
- }
- rt->T5();
- return G0(ans, rt);
- }
- static J10 *array_U6(const std::vector<J10 *> &args, K9 *rt, bool I0) {
- B2();
- rt->A0(args, 0);
- auto self = args[0];
- rt->O2(self, rt->E3.array, K9::SUB1_CTX);
- if (!I0) {
- return self;
- }
- if (rt->B4(self, nullptr)) {
- return J0("Array", rt);
- }
- auto &arr = getArrayDataFast(self);
- std::string res = "{";
- if (arr.size() != 0) {
- auto o = rt->O7(N4::U6(rt), arr[0], {arr[0]}, true);
- rt->M0(o, rt->E3.string, K9::SUB1_CTX);
- res += L1(o);
- }
- for (int64_t i = 1; i < arr.size(); i++) {
- auto o = rt->O7(N4::U6(rt), arr[i], {arr[i]}, true);
- rt->M0(o, rt->E3.string, K9::SUB1_CTX);
- res += ", " + L1(o);
- }
- res += "}";
- return J0(res, rt);
- }
- void installArrayMethods(I12 *type, K9 *rt) {
- B2();
- type->S7(N4::U6(rt), Z9::C0(true, array_U6, nullptr, rt));
- type->S7(N4::S4(rt), Z9::C0(true, array_U6, nullptr, rt));
- type->S7(rt->S12->Z11("size"), C0(true, arraySizeMethod, nullptr, rt));
- type->S7(rt->S12->Z11("resize"), C0(true, arrayResizeMethod, nullptr, rt));
- type->S7(rt->S12->Z11("append"), C0(true, arrayAppendMethod, nullptr, rt));
- type->S7(rt->S12->Z11("prepend"), C0(true, arrayPrependMethod, nullptr, rt));
- type->S7(rt->S12->Z11("poplast"), C0(true, arrayPoplastMethod, nullptr, rt));
- type->S7(rt->S12->Z11("popfirst"), C0(true, arrayPopfirstMethod, nullptr, rt));
- type->S7(rt->S12->Z11("first"), C0(true, arrayFirstMethod, nullptr, rt));
- type->S7(rt->S12->Z11("last"), C0(true, arrayLastMethod, nullptr, rt));
- type->S7(rt->S12->Z11("empty"), C0(true, arrayEmptyMethod, nullptr, rt));
- type->S7(rt->S12->Z11("clear"), C0(true, arrayClearMethod, nullptr, rt));
- type->S7(rt->S12->Z11("copy"), C0(true, arrayCopyMethod, nullptr, rt));
- type->S7(rt->S12->Z11("filter"), C0(true, arrayFilterMethod, nullptr, rt));
- type->S7(rt->S12->Z11("apply"), C0(true, arrayApplyMethod, nullptr, rt));
- type->S7(rt->S12->Z11("reverse"), C0(true, arrayReverseMethod, nullptr, rt));
- type->S7(rt->S12->Z11("sort"), C0(true, arraySortMethod, nullptr, rt));
- type->S7(rt->S12->Z11("combine"), C0(true, arrayCombineMethod, nullptr, rt));
- type->S7(rt->S12->Z11("findfirst"), C0(true, arrayFindfirstMethod, nullptr, rt));
- type->S7(rt->S12->Z11("findlast"), C0(true, arrayFindlastMethod, nullptr, rt));
- type->S7(rt->S12->Z11("all"), C0(true, arrayAllMethod, nullptr, rt));
- type->S7(rt->S12->Z11("any"), C0(true, arrayAnyMethod, nullptr, rt));
- type->S7(rt->S12->Z11("none"), C0(true, arrayNoneMethod, nullptr, rt));
- type->S7(rt->S12->Z11("count"), C0(true, arrayCountMethod, nullptr, rt));
- }
- Q7::Q7(K9 *rt)
- : I12(rt) {
- B2();
- this->J9 = ArrayIndexL9;
- this->G12 = ArrayEqL9;
- this->I11 = ArrayNeqL9;
- }
- J10 *Q7::create(K9 *rt) {
- B2();
- G8 *ins = new U3(rt);
- J10 *obj = new J10(true, ins, this, rt);
- return obj;
- }
- J10 *Q7::copy(J10 *obj, K9 *rt) {
- B2();
- rt->O2(obj, rt->E3.array);
- if (obj->H8 == nullptr) {
- return new J10(false, nullptr, this, rt);
- }
- auto ins = obj->H8->copy(rt);
- auto res = new J10(true, ins, this, rt);
- return res;
- }
- std::string Q7::userRepr(K9 *rt) {
- B2();
- if (this == nullptr) {
- return "Q7(nullptr)";
- }
- return "Q7";
- }
- std::vector<J10 *> &getArrayData(J10 *obj, K9 *rt) {
- B2();
- rt->M0(obj, rt->E3.array);
- return icast(obj->H8, H10::Z9::U3)->Q12;
- }
- std::vector<J10 *> &getArrayData(J10 *obj, K9 *rt, K9::ContextId ctx_id) {
- B2();
- rt->M0(obj, rt->E3.array, K9::SUB0_CTX);
- return icast(obj->H8, H10::Z9::U3)->Q12;
- }
- J10 *L0(const std::vector<J10 *> &Q12, K9 *rt) {
- B2();
- auto res = rt->make(rt->E3.array, K9::INSTANCE_OBJECT);
- getArrayDataFast(res) = Q12;
- return res;
- }
- }
- /*
- Copyright (c) 2024 Ihor Lukianov (lis05)
- Permission is hereby granted, free of charge, to any person obtaining a copy of
- this software and associated documentation files (the "Software"), to deal in
- the Software without restriction, including without limitation the rights to
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
- the Software, and to permit persons to whom the Software is furnished to do so,
- subject to the following conditions:
- The above copyright notice and this permission notice shall be included in all
- copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, N12ESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
- #include <chrono>
- using namespace std::chrono;
- using namespace H10;
- using namespace H10::Z9;
- void emergency_error_exit() {
- exit(1);
- }
- // TODO: add --profiler flag
- int main(int argc, char *argv[]) {
- const char *src = R"(
- //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- arr = make(Array)
- .resize(read(Integer))
- .apply(function(x){x=read(Integer);});
- target = arr.copy().sort(function(a,b){a>b;})[1];
- // don't have a function that would return element's position yet
- for i = 0; i < arr.size(); i++; {
- if arr[i] == target; {
- println(i + 1);
- return;
- }
- }
- //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- )";
- C4 em(emergency_error_exit);
- M11 lx(&em);
- K10 pr(&em);
- D4 S12;
- auto strsrc = std::string(src);
- auto L11s = lx.process(strsrc);
- for (auto &L11 : L11s) {
- L11.Y10 = S12.Z11(L11.Q12);
- }
- auto program = pr.B12(L11s);
- O1 gcst;
- K9 rt(&gcst, &em, &S12);
- auto res = rt.execute(program, false);
- delete program;
- }
Advertisement
Add Comment
Please, Sign In to add comment