sliger on docker
This commit is contained in:
parent
2662c327ca
commit
4363874cd2
51
.vscode/settings.json
vendored
51
.vscode/settings.json
vendored
@ -1,3 +1,52 @@
|
||||
{
|
||||
"deno.enable": true
|
||||
"deno.enable": true,
|
||||
"files.associations": {
|
||||
"array": "cpp",
|
||||
"atomic": "cpp",
|
||||
"bit": "cpp",
|
||||
"*.tcc": "cpp",
|
||||
"cctype": "cpp",
|
||||
"clocale": "cpp",
|
||||
"cmath": "cpp",
|
||||
"compare": "cpp",
|
||||
"concepts": "cpp",
|
||||
"cstdarg": "cpp",
|
||||
"cstddef": "cpp",
|
||||
"cstdint": "cpp",
|
||||
"cstdio": "cpp",
|
||||
"cstdlib": "cpp",
|
||||
"cwchar": "cpp",
|
||||
"cwctype": "cpp",
|
||||
"deque": "cpp",
|
||||
"string": "cpp",
|
||||
"unordered_map": "cpp",
|
||||
"vector": "cpp",
|
||||
"exception": "cpp",
|
||||
"algorithm": "cpp",
|
||||
"functional": "cpp",
|
||||
"iterator": "cpp",
|
||||
"memory": "cpp",
|
||||
"memory_resource": "cpp",
|
||||
"numeric": "cpp",
|
||||
"optional": "cpp",
|
||||
"random": "cpp",
|
||||
"string_view": "cpp",
|
||||
"system_error": "cpp",
|
||||
"tuple": "cpp",
|
||||
"type_traits": "cpp",
|
||||
"utility": "cpp",
|
||||
"fstream": "cpp",
|
||||
"initializer_list": "cpp",
|
||||
"iosfwd": "cpp",
|
||||
"iostream": "cpp",
|
||||
"istream": "cpp",
|
||||
"limits": "cpp",
|
||||
"new": "cpp",
|
||||
"numbers": "cpp",
|
||||
"ostream": "cpp",
|
||||
"stdexcept": "cpp",
|
||||
"streambuf": "cpp",
|
||||
"typeinfo": "cpp",
|
||||
"variant": "cpp"
|
||||
}
|
||||
}
|
||||
|
@ -362,7 +362,6 @@ export class Checker {
|
||||
}
|
||||
const pos = expr.pos;
|
||||
const subject = this.checkExpr(expr.kind.subject);
|
||||
console.log(expr);
|
||||
if (subject.type !== "fn") {
|
||||
this.report("cannot call non-fn", pos);
|
||||
return { type: "error" };
|
||||
|
@ -30,6 +30,6 @@ lowerer.lower(ast);
|
||||
lowerer.printProgram();
|
||||
const program = lowerer.finish();
|
||||
//console.log(JSON.stringify(program, null, 4));
|
||||
console.log(JSON.stringify(program));
|
||||
// console.log(JSON.stringify(program));
|
||||
|
||||
await Deno.writeTextFile("out.slgbc", JSON.stringify(program));
|
||||
|
@ -42,7 +42,6 @@ export class Parser {
|
||||
}
|
||||
|
||||
private report(msg: string, pos = this.pos()) {
|
||||
console.log(`Parser: ${msg} at ${pos.line}:${pos.col}`);
|
||||
this.reporter.reportError({
|
||||
msg,
|
||||
pos,
|
||||
|
9
runtime/Dockerfile
Normal file
9
runtime/Dockerfile
Normal file
@ -0,0 +1,9 @@
|
||||
from gcc
|
||||
|
||||
WORKDIR /workdir
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN make -j 8
|
||||
|
||||
ENTRYPOINT [ "./build/sliger", "run", "out.slgbc" ]
|
@ -14,16 +14,18 @@ CXX_SOURCES = $(shell find . -name "*.cpp" -type f -printf '%P\n')
|
||||
|
||||
CXX_OBJECTS = $(patsubst %.cpp,build/%.o,$(CXX_SOURCES))
|
||||
|
||||
CXX = g++
|
||||
|
||||
all: build_dir $(OUT)
|
||||
|
||||
$(OUT): $(CXX_OBJECTS)
|
||||
g++ -o $@ $(CXX_FLAGS) $^
|
||||
$(CXX) -o $@ $(CXX_FLAGS) $^
|
||||
|
||||
build_dir:
|
||||
mkdir -p build/
|
||||
|
||||
build/%.o: %.cpp $(CXX_HEADERS)
|
||||
g++ -c -o $@ $(CXX_FLAGS) $<
|
||||
$(CXX) -c -o $@ $(CXX_FLAGS) $<
|
||||
|
||||
clean:
|
||||
rm -rf build/
|
||||
|
@ -9,6 +9,8 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
bool print_stack_debug = false;
|
||||
|
||||
int execute_file_and_exit(std::string filename)
|
||||
{
|
||||
auto file = std::ifstream();
|
||||
@ -33,6 +35,7 @@ int execute_file_and_exit(std::string filename)
|
||||
{
|
||||
.flame_graph = false,
|
||||
.code_coverage = false,
|
||||
.print_stack_debug = print_stack_debug,
|
||||
});
|
||||
vm.run_until_done();
|
||||
return 0;
|
||||
|
@ -68,8 +68,10 @@ void VM::run_n_instructions(size_t amount)
|
||||
|
||||
void VM::run_instruction()
|
||||
{
|
||||
// std::cout << std::format(" {:>4}: {:<12}{}\n", this->pc,
|
||||
// maybe_op_to_string(this->program[this->pc]), stack_repr_string(8));
|
||||
if (this->opts.print_stack_debug) {
|
||||
std::cout << std::format(" {:>4}: {:<12}{}\n", this->pc,
|
||||
maybe_op_to_string(this->program[this->pc]), stack_repr_string(8));
|
||||
}
|
||||
auto op = eat_op();
|
||||
switch (op) {
|
||||
case Op::Nop:
|
||||
@ -343,6 +345,7 @@ void VM::run_builtin(Builtin builtin_id)
|
||||
assert_stack_has(1);
|
||||
auto message = stack_pop().as_string().value;
|
||||
std::cout << message;
|
||||
stack_push(Null());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -142,6 +142,7 @@ private:
|
||||
struct VMOpts {
|
||||
bool flame_graph;
|
||||
bool code_coverage;
|
||||
bool print_stack_debug;
|
||||
};
|
||||
|
||||
class VM {
|
||||
|
@ -9,6 +9,7 @@ auto VmProvider::load_and_run(std::vector<uint32_t> instructions) -> void
|
||||
{
|
||||
.flame_graph = true,
|
||||
.code_coverage = true,
|
||||
.print_stack_debug = false,
|
||||
});
|
||||
vm.run_until_done();
|
||||
this->vm = vm;
|
||||
|
19
slige-run-docker.sh
Executable file
19
slige-run-docker.sh
Executable file
@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
echo Text:
|
||||
cat $1
|
||||
|
||||
echo Compiling $1...
|
||||
|
||||
deno run --allow-read --allow-write compiler/main.ts $1
|
||||
|
||||
echo Running out.slgbc...
|
||||
|
||||
cp out.slgbc runtime/
|
||||
|
||||
cd runtime/
|
||||
|
||||
docker build . -t sliger-buildenv
|
||||
docker run --rm -it sliger-buildenv
|
Loading…
Reference in New Issue
Block a user