From 17981acc4941dc2c79e34aa6c0a23a74f253b865 Mon Sep 17 00:00:00 2001 From: Natapat Samutpong Date: Wed, 26 Jan 2022 09:21:53 +0700 Subject: [PATCH] refactor: move file up 1 director --- .gitignore => blspc/.gitignore | 0 Cargo.lock => blspc/Cargo.lock | 0 Cargo.toml => blspc/Cargo.toml | 0 Makefile => blspc/Makefile | 0 README.md => blspc/README.md | 0 {example => blspc/example}/hello.blsp | 0 blspc/example/if.blsp | 1 + {example => blspc/example}/math.blsp | 0 {example => blspc/example}/s.blsp | 0 {src => blspc/src}/args.rs | 0 {src => blspc/src}/compiler/compile.rs | 0 {src => blspc/src}/compiler/lib.rs | 13 ++++++++----- {src => blspc/src}/compiler/mod.rs | 0 {src => blspc/src}/main.rs | 0 {src => blspc/src}/parser.rs | 0 {src => blspc/src}/util.rs | 0 16 files changed, 9 insertions(+), 5 deletions(-) rename .gitignore => blspc/.gitignore (100%) rename Cargo.lock => blspc/Cargo.lock (100%) rename Cargo.toml => blspc/Cargo.toml (100%) rename Makefile => blspc/Makefile (100%) rename README.md => blspc/README.md (100%) rename {example => blspc/example}/hello.blsp (100%) create mode 100644 blspc/example/if.blsp rename {example => blspc/example}/math.blsp (100%) rename {example => blspc/example}/s.blsp (100%) rename {src => blspc/src}/args.rs (100%) rename {src => blspc/src}/compiler/compile.rs (100%) rename {src => blspc/src}/compiler/lib.rs (80%) rename {src => blspc/src}/compiler/mod.rs (100%) rename {src => blspc/src}/main.rs (100%) rename {src => blspc/src}/parser.rs (100%) rename {src => blspc/src}/util.rs (100%) diff --git a/.gitignore b/blspc/.gitignore similarity index 100% rename from .gitignore rename to blspc/.gitignore diff --git a/Cargo.lock b/blspc/Cargo.lock similarity index 100% rename from Cargo.lock rename to blspc/Cargo.lock diff --git a/Cargo.toml b/blspc/Cargo.toml similarity index 100% rename from Cargo.toml rename to blspc/Cargo.toml diff --git a/Makefile b/blspc/Makefile similarity index 100% rename from Makefile rename to blspc/Makefile diff --git a/README.md b/blspc/README.md similarity index 100% rename from README.md rename to blspc/README.md diff --git a/example/hello.blsp b/blspc/example/hello.blsp similarity index 100% rename from example/hello.blsp rename to blspc/example/hello.blsp diff --git a/blspc/example/if.blsp b/blspc/example/if.blsp new file mode 100644 index 0000000..f0c6555 --- /dev/null +++ b/blspc/example/if.blsp @@ -0,0 +1 @@ +(if true (print "True") (print "False")) \ No newline at end of file diff --git a/example/math.blsp b/blspc/example/math.blsp similarity index 100% rename from example/math.blsp rename to blspc/example/math.blsp diff --git a/example/s.blsp b/blspc/example/s.blsp similarity index 100% rename from example/s.blsp rename to blspc/example/s.blsp diff --git a/src/args.rs b/blspc/src/args.rs similarity index 100% rename from src/args.rs rename to blspc/src/args.rs diff --git a/src/compiler/compile.rs b/blspc/src/compiler/compile.rs similarity index 100% rename from src/compiler/compile.rs rename to blspc/src/compiler/compile.rs diff --git a/src/compiler/lib.rs b/blspc/src/compiler/lib.rs similarity index 80% rename from src/compiler/lib.rs rename to blspc/src/compiler/lib.rs index 74e7c6e..65001d3 100644 --- a/src/compiler/lib.rs +++ b/blspc/src/compiler/lib.rs @@ -35,14 +35,16 @@ pub enum Instr { // Load a literal value onto the stack. Load { address: Register }, // Store a literal value into a register. - Store { address: Register, value: Type, }, + Store { address: Register, value: Type }, // Call intrinsic function. Call { address: Register, args: Register }, // Immediate arithmetic. - IAdd { lhs: Register, rhs: Register, to: Register, }, - ISub { lhs: Register, rhs: Register, to: Register, }, - IMul { lhs: Register, rhs: Register, to: Register, }, - IDiv { lhs: Register, rhs: Register, to: Register, }, + IAdd { lhs: Register, rhs: Register, to: Register }, + ISub { lhs: Register, rhs: Register, to: Register }, + IMul { lhs: Register, rhs: Register, to: Register }, + IDiv { lhs: Register, rhs: Register, to: Register }, + // Jumping + JumpIfFalse { cond: Register, to: Register }, } impl Display for Instr { @@ -55,6 +57,7 @@ impl Display for Instr { Instr::ISub { lhs, rhs, to } => write!(f, "ISUB {} {} {}", lhs, rhs, to), Instr::IMul { lhs, rhs, to } => write!(f, "IMUL {} {} {}", lhs, rhs, to), Instr::IDiv { lhs, rhs, to } => write!(f, "IDIV {} {} {}", lhs, rhs, to), + Instr::JumpIfFalse { cond, to } => write!(f, "JUMP_IF_FALSE {} {}", cond, to), } } } \ No newline at end of file diff --git a/src/compiler/mod.rs b/blspc/src/compiler/mod.rs similarity index 100% rename from src/compiler/mod.rs rename to blspc/src/compiler/mod.rs diff --git a/src/main.rs b/blspc/src/main.rs similarity index 100% rename from src/main.rs rename to blspc/src/main.rs diff --git a/src/parser.rs b/blspc/src/parser.rs similarity index 100% rename from src/parser.rs rename to blspc/src/parser.rs diff --git a/src/util.rs b/blspc/src/util.rs similarity index 100% rename from src/util.rs rename to blspc/src/util.rs