Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/leek-lang/leek
Browse files Browse the repository at this point in the history
  • Loading branch information
wowkster committed May 30, 2024
2 parents 41cb3ad + 61b8edb commit 8f71e8b
Show file tree
Hide file tree
Showing 18 changed files with 2,301 additions and 2,466 deletions.
117 changes: 53 additions & 64 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[workspace]

resolver = "2"
members = [
"compiler",
]
4 changes: 2 additions & 2 deletions compiler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ edition = "2021"

[dependencies]
ansi_term = "0.12.1"
clap = { version = "4.1.6", features = ["derive"] }
clap = { version = "4.3.19", features = ["derive"] }
diff = "0.1.13"
indoc = "2.0.1"
itertools = "0.10.5"
itertools = "0.11.0"
mktemp = "0.5.0"
6 changes: 3 additions & 3 deletions compiler/src/backend/codegen/mod.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
use std::{path::Path, process::Command, str::FromStr};

use crate::frontend::ast::LeekAst;
use crate::frontend::ast::Ast;

use self::x86_linux_gnu::CodeGeneratorX86LinuxGNU;

use super::LeekCompilerConfig;
use super::CompilerConfig;

pub mod x86_64_linux_gnu;
pub mod x86_linux_gnu;

pub trait CodeGenerator {
fn generate_assembly(&self, ast: LeekAst, compiler_options: &LeekCompilerConfig) -> String;
fn generate_assembly(&self, ast: Ast, compiler_options: &CompilerConfig) -> String;
fn create_assembler_command(&self, input_file: &Path, output_file: &Path) -> Command;
fn create_linker_command(&self, input_file: &Path, output_file: &Path) -> Command;
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/backend/codegen/x86_linux_gnu/mod.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use indoc::indoc;
use std::{path::Path, process::Command};

use crate::{backend::LeekCompilerConfig, frontend::ast::LeekAst};
use crate::{backend::CompilerConfig, frontend::ast::Ast};

use super::CodeGenerator;

pub struct CodeGeneratorX86LinuxGNU;

impl CodeGenerator for CodeGeneratorX86LinuxGNU {
fn generate_assembly(&self, _ast: LeekAst, _compiler_options: &LeekCompilerConfig) -> String {
fn generate_assembly(&self, _ast: Ast, _compiler_options: &CompilerConfig) -> String {
String::from(indoc! {"
global main
Expand Down
12 changes: 6 additions & 6 deletions compiler/src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use itertools::Itertools;

use crate::{
common::{
config::{EmitMode, LeekCompilerConfig},
error::LeekCompilerError,
config::{CompilerConfig, EmitMode},
error::CompilerError,
},
frontend::ast::LeekAst,
frontend::ast::Ast,
};

use self::codegen::{CodeGenTarget, CodeGenerator};
Expand All @@ -33,10 +33,10 @@ macro_rules! display_buffer {
}

pub fn compile_ast(
ast: LeekAst,
compiler_options: &LeekCompilerConfig,
ast: Ast,
compiler_options: &CompilerConfig,
target: CodeGenTarget,
) -> Result<(), LeekCompilerError> {
) -> Result<(), CompilerError> {
let code_generator = target.get_code_generator();

// If the output name is specified, use that.
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/common/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub enum EmitMode {
AssemblyFile,
}

pub struct LeekCompilerConfig {
pub struct CompilerConfig {
pub opt_level: OptimizationLevel,
pub build_mode: BuildMode,
pub emit_mode: EmitMode,
Expand Down
Loading

0 comments on commit 8f71e8b

Please sign in to comment.