mirror of
https://github.com/usatiuk/psil.git
synced 2025-10-28 10:47:49 +01:00
Clang format all the things
This commit is contained in:
@@ -2,8 +2,28 @@
|
||||
BasedOnStyle: LLVM
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments: None
|
||||
AlignConsecutiveAssignments:
|
||||
Enabled: true
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignConsecutiveBitFields:
|
||||
Enabled: true
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignConsecutiveDeclarations:
|
||||
Enabled: true
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignConsecutiveMacros:
|
||||
Enabled: true
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignTrailingComments:
|
||||
Kind: Always
|
||||
OverEmptyLines: 2
|
||||
SpacesBeforeTrailingComments: 1
|
||||
AlignOperands: Align
|
||||
AlignEscapedNewlines: Right
|
||||
AllowAllArgumentsOnNextLine: false
|
||||
AllowAllConstructorInitializersOnNextLine: false
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
@@ -33,7 +53,7 @@ BreakBeforeBinaryOperators: None
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BreakInheritanceList: BeforeColon
|
||||
ColumnLimit: 120
|
||||
ColumnLimit: 0
|
||||
CompactNamespaces: false
|
||||
ContinuationIndentWidth: 8
|
||||
IndentCaseLabels: true
|
||||
@@ -56,7 +76,6 @@ SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeRangeBasedForLoopColon: false
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 0
|
||||
SpacesInAngles: false
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInContainerLiterals: false
|
||||
|
||||
10
.idea/codeStyles/Project.xml
generated
Normal file
10
.idea/codeStyles/Project.xml
generated
Normal file
@@ -0,0 +1,10 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<RiderCodeStyleSettings>
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppClangFormat/EnableClangFormatSupport/@EntryValue" value="true" type="bool" />
|
||||
</RiderCodeStyleSettings>
|
||||
<clangFormatSettings>
|
||||
<option name="ENABLED" value="true" />
|
||||
</clangFormatSettings>
|
||||
</code_scheme>
|
||||
</component>
|
||||
7
.idea/editor.xml
generated
Normal file
7
.idea/editor.xml
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="BackendCodeEditorSettings">
|
||||
<option name="/Default/Housekeeping/GlobalSettingsUpgraded/IsUpgraded/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppClangFormat/EnableClangFormatSupport/@EntryValue" value="true" type="bool" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -14,14 +14,20 @@
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
class Logger
|
||||
{
|
||||
class Logger {
|
||||
public:
|
||||
Logger();
|
||||
|
||||
enum LogLevel { ALWAYS = 0, ERROR = 1, INFO = 2, DEBUG = 3, TRACE = 4 };
|
||||
enum LogLevel { ALWAYS = 0,
|
||||
ERROR = 1,
|
||||
INFO = 2,
|
||||
DEBUG = 3,
|
||||
TRACE = 4 };
|
||||
|
||||
enum LogTag { MemoryContext, VM, Compiler, LogTagMax };
|
||||
enum LogTag { MemoryContext,
|
||||
VM,
|
||||
Compiler,
|
||||
LogTagMax };
|
||||
|
||||
static void log(LogTag tag, const std::string &what, int level);
|
||||
static void log(LogTag tag, const std::function<void(std::ostream &)> &fn, int level);
|
||||
@@ -48,7 +54,11 @@ public:
|
||||
private:
|
||||
std::array<LogLevel, LogTag::LogTagMax> _levels{};
|
||||
static inline std::unordered_map<int, std::string> _level_names{
|
||||
{ALWAYS, "ALWAYS"}, {ERROR, "ERROR"}, {INFO, "INFO"}, {DEBUG, "DEBUG"}, {TRACE, "TRACE"},
|
||||
{ALWAYS, "ALWAYS"},
|
||||
{ERROR, "ERROR"},
|
||||
{INFO, "INFO"},
|
||||
{DEBUG, "DEBUG"},
|
||||
{TRACE, "TRACE"},
|
||||
};
|
||||
static inline std::unordered_map<std::string, LogTag> _str_to_tag{
|
||||
{"VM", VM},
|
||||
|
||||
@@ -27,7 +27,8 @@ void Logger::log(LogTag tag, const std::string &what, int level) {
|
||||
<< "[" << tag_to_str(tag) << "][" << get()._level_names.at(level) << "] " << what << '\n';
|
||||
|
||||
if (level == 1) get()._out_err.get() << out.str();
|
||||
else get()._out.get() << out.str();
|
||||
else
|
||||
get()._out.get() << out.str();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,9 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
enum class CellType { NUMATOM, STRATOM, CONS };
|
||||
enum class CellType { NUMATOM,
|
||||
STRATOM,
|
||||
CONS };
|
||||
|
||||
using CellValType = int64_t;
|
||||
|
||||
|
||||
@@ -52,17 +52,69 @@ namespace Command {
|
||||
};
|
||||
|
||||
static inline std::unordered_map<std::string_view, CellValType> str_to_cmd{
|
||||
{"NIL", 1}, {"LDC", 2}, {"LD", 3}, {"SEL", 4}, {"JOIN", 5}, {"LDF", 6}, {"AP", 7},
|
||||
{"RET", 8}, {"DUM", 9}, {"RAP", 10}, {"STOP", 11}, {"ATOM", 12}, {"ADD", 13}, {"SUB", 14},
|
||||
{"READCHAR", 15}, {"PUTCHAR", 16}, {"PUTNUM", 17}, {"EVAL", 18}, {"PRINT", 19}, {"READ", 20}, {"CONS", 21},
|
||||
{"LDG", 22}, {"CAR", 23}, {"CDR", 24}, {"EQ", 25}, {"LT", 26}, {"GT", 27}, {"NILC", 28},
|
||||
{"MULT", 29}, {"DIV", 30}, {"QUIT", 31}};
|
||||
{"NIL", 1},
|
||||
{"LDC", 2},
|
||||
{"LD", 3},
|
||||
{"SEL", 4},
|
||||
{"JOIN", 5},
|
||||
{"LDF", 6},
|
||||
{"AP", 7},
|
||||
{"RET", 8},
|
||||
{"DUM", 9},
|
||||
{"RAP", 10},
|
||||
{"STOP", 11},
|
||||
{"ATOM", 12},
|
||||
{"ADD", 13},
|
||||
{"SUB", 14},
|
||||
{"READCHAR", 15},
|
||||
{"PUTCHAR", 16},
|
||||
{"PUTNUM", 17},
|
||||
{"EVAL", 18},
|
||||
{"PRINT", 19},
|
||||
{"READ", 20},
|
||||
{"CONS", 21},
|
||||
{"LDG", 22},
|
||||
{"CAR", 23},
|
||||
{"CDR", 24},
|
||||
{"EQ", 25},
|
||||
{"LT", 26},
|
||||
{"GT", 27},
|
||||
{"NILC", 28},
|
||||
{"MULT", 29},
|
||||
{"DIV", 30},
|
||||
{"QUIT", 31}};
|
||||
static inline std::unordered_map<CellValType, std::string> cmd_to_str{
|
||||
{1, "NIL"}, {2, "LDC"}, {3, "LD"}, {4, "SEL"}, {5, "JOIN"}, {6, "LDF"}, {7, "AP"},
|
||||
{8, "RET"}, {9, "DUM"}, {10, "RAP"}, {11, "STOP"}, {12, "ATOM"}, {13, "ADD"}, {14, "SUB"},
|
||||
{15, "READCHAR"}, {16, "PUTCHAR"}, {17, "PUTNUM"}, {18, "EVAL"}, {19, "PRINT"}, {20, "READ"}, {21, "CONS"},
|
||||
{22, "LDG"}, {23, "CAR"}, {24, "CDR"}, {25, "EQ"}, {26, "LT"}, {27, "GT"}, {28, "NILC"},
|
||||
{29, "MULT"}, {30, "DIV"}, {31, "QUIT"}};
|
||||
{1, "NIL"},
|
||||
{2, "LDC"},
|
||||
{3, "LD"},
|
||||
{4, "SEL"},
|
||||
{5, "JOIN"},
|
||||
{6, "LDF"},
|
||||
{7, "AP"},
|
||||
{8, "RET"},
|
||||
{9, "DUM"},
|
||||
{10, "RAP"},
|
||||
{11, "STOP"},
|
||||
{12, "ATOM"},
|
||||
{13, "ADD"},
|
||||
{14, "SUB"},
|
||||
{15, "READCHAR"},
|
||||
{16, "PUTCHAR"},
|
||||
{17, "PUTNUM"},
|
||||
{18, "EVAL"},
|
||||
{19, "PRINT"},
|
||||
{20, "READ"},
|
||||
{21, "CONS"},
|
||||
{22, "LDG"},
|
||||
{23, "CAR"},
|
||||
{24, "CDR"},
|
||||
{25, "EQ"},
|
||||
{26, "LT"},
|
||||
{27, "GT"},
|
||||
{28, "NILC"},
|
||||
{29, "MULT"},
|
||||
{30, "DIV"},
|
||||
{31, "QUIT"}};
|
||||
|
||||
static inline Handle make_cmd(CellValType cmd) {
|
||||
if (Options::get<bool>("command_strs")) {
|
||||
|
||||
@@ -18,9 +18,23 @@ using namespace Command;
|
||||
|
||||
|
||||
static std::unordered_map<std::string_view, CommandE> builtins{
|
||||
{"+", ADD}, {"-", SUB}, {"cons", CONS}, {"car", CAR}, {"cdr", CDR}, {"=", EQ},
|
||||
{">", GT}, {"<", LT}, {"nil", NIL}, {"nil?", NILC}, {"atom", ATOM}, {"*", MULT},
|
||||
{"/", DIV}, {"read", READ}, {"eval", EVAL}, {"print", PRINT}, {"quit", QUIT}};
|
||||
{"+", ADD},
|
||||
{"-", SUB},
|
||||
{"cons", CONS},
|
||||
{"car", CAR},
|
||||
{"cdr", CDR},
|
||||
{"=", EQ},
|
||||
{">", GT},
|
||||
{"<", LT},
|
||||
{"nil", NIL},
|
||||
{"nil?", NILC},
|
||||
{"atom", ATOM},
|
||||
{"*", MULT},
|
||||
{"/", DIV},
|
||||
{"read", READ},
|
||||
{"eval", EVAL},
|
||||
{"print", PRINT},
|
||||
{"quit", QUIT}};
|
||||
|
||||
Handle Compiler::compile(const Handle &src, Handle fake_env, const Handle &suffix) {
|
||||
Handle out;
|
||||
|
||||
Reference in New Issue
Block a user