|
| 1 | +/** |
| 2 | + * NitroPascal Runtime Library |
| 3 | + * |
| 4 | + * This is the C++ Runtime Library (RTL) that provides Delphi/Object Pascal |
| 5 | + * semantics in C++20. The code generator emits calls to these functions |
| 6 | + * and classes, making code generation trivial. |
| 7 | + * |
| 8 | + * Key Design Principles: |
| 9 | + * - All Delphi semantics are wrapped in C++ functions/classes |
| 10 | + * - Code generator just emits function calls (simple syntax translation) |
| 11 | + * - All complexity lives here (written once, correct once) |
| 12 | + * - Uses C++20 features (fold expressions, concepts, etc.) |
| 13 | + * |
| 14 | + * Module Organization: |
| 15 | + * - runtime_types.h: Core type aliases |
| 16 | + * - runtime_operators_custom.h: Custom output operators (before namespace) |
| 17 | + * - runtime_string.h/cpp: String class and utilities |
| 18 | + * - runtime_console.h/cpp: Console I/O |
| 19 | + * - runtime_control.h/cpp: Control flow (for, while, repeat) |
| 20 | + * - runtime_operators.h/cpp: Arithmetic operators (div, mod, shl, shr) |
| 21 | + * - runtime_ordinal.h/cpp: Ordinal functions (Ord, Chr, Succ, Pred, Inc, Dec) |
| 22 | + * - runtime_containers.h/cpp: DynArray<T>, Set<T> |
| 23 | + * - runtime_memory.h/cpp: Memory management (New, Dispose, GetMem, Move) |
| 24 | + * - runtime_math.h/cpp: Math functions (Abs, Sqrt, Sin, Cos, etc.) |
| 25 | + * - runtime_file.h/cpp: File I/O (Text, Binary files) |
| 26 | + * - runtime_exceptions.h/cpp: Exception handling |
| 27 | + * - runtime_cmdline.h/cpp: Command line parameters |
| 28 | + * - runtime_format.h/cpp: String formatting |
| 29 | + * |
| 30 | + * Version: 1.0 |
| 31 | + * Date: 2025-10-15 |
| 32 | + */ |
| 33 | + |
| 34 | +#pragma once |
| 35 | + |
| 36 | +// ============================================================================ |
| 37 | +// GLOBAL INCLUDES (required before np namespace) |
| 38 | +// ============================================================================ |
| 39 | + |
| 40 | +#include <iostream> |
| 41 | +#include <string> |
| 42 | +#include <functional> |
| 43 | +#include <cstdint> |
| 44 | +#include <vector> |
| 45 | +#include <unordered_set> |
| 46 | +#include <memory> |
| 47 | +#include <sstream> |
| 48 | +#include <iomanip> |
| 49 | +#include <stdexcept> |
| 50 | +#include <cassert> |
| 51 | +#include <array> |
| 52 | +#include <cstring> |
| 53 | +#include <cmath> |
| 54 | +#include <cstdlib> |
| 55 | +#include <ctime> |
| 56 | +#include <fstream> |
| 57 | +#include <sys/stat.h> |
| 58 | +#include <algorithm> |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | +// ============================================================================ |
| 63 | +// MODULAR INCLUDES IN DEPENDENCY ORDER |
| 64 | +// ============================================================================ |
| 65 | + |
| 66 | +#include "runtime_types.h" |
| 67 | +#include "runtime_operators_custom.h" |
| 68 | +#include "runtime_string.h" |
| 69 | +#include "runtime_console.h" |
| 70 | +#include "runtime_control.h" |
| 71 | +#include "runtime_operators.h" |
| 72 | +#include "runtime_ordinal.h" |
| 73 | +#include "runtime_containers.h" |
| 74 | +#include "runtime_memory.h" |
| 75 | +#include "runtime_math.h" |
| 76 | +#include "runtime_file.h" |
| 77 | +#include "runtime_exceptions.h" |
| 78 | +#include "runtime_cmdline.h" |
| 79 | +#include "runtime_format.h" |
0 commit comments