Skip to content

Commit

Permalink
clippy run
Browse files Browse the repository at this point in the history
  • Loading branch information
lexa-diky committed Jul 11, 2024
1 parent d7649fd commit c1c350f
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 32 deletions.
4 changes: 2 additions & 2 deletions src/cli/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::fs::File;
use std::io::Write;
use std::panic::catch_unwind;
use std::path::{Path, PathBuf};
use std::path::Path;
use std::thread::sleep;
use std::time::{Duration, Instant};

Expand Down Expand Up @@ -175,7 +175,7 @@ impl Cli {
let compiler = HexoCompiler::new(context);

let source_path = Path::new(&source);
let compiler_source = FileCompilerSource::new(&source_path);
let compiler_source = FileCompilerSource::new(source_path);

let compilation_result = compiler
.compile(&compiler_source)
Expand Down
8 changes: 2 additions & 6 deletions src/compiler/rst/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ impl RstCompiler<'_> {

let bb = self.build_bytes(scope_id, &mut scope, cst.main().emits())?;

Ok(HexoFile::new(
cst.path(),
scope,
bb,
))
Ok(HexoFile::new(bb))
}

fn build_bytes(
Expand Down Expand Up @@ -89,7 +85,7 @@ impl RstCompiler<'_> {
Error::NativeFunctionIsUnsafe {
name: native_function.signature().name().to_string()
}
)
);
}

let executor = native_function.executor();
Expand Down
19 changes: 2 additions & 17 deletions src/compiler/rst/node.rs
Original file line number Diff line number Diff line change
@@ -1,32 +1,17 @@
use crate::compiler::rst::scope::CompilationScope;
use crate::util::byte_buffer::ByteBuffer;
use std::path::{Path, PathBuf};

#[derive(Debug)]
pub(crate) struct HexoFile {
path: PathBuf,
context: CompilationScope,
emits: ByteBuffer,
}

impl HexoFile {

pub(crate) fn new(path: &Path, context: CompilationScope, emits: ByteBuffer) -> HexoFile {
pub(crate) fn new(emits: ByteBuffer) -> HexoFile {
HexoFile {
path: path.to_path_buf(),
context,
emits,
emits: emits,
}
}

pub(crate) fn path(&self) -> &Path {
&self.path
}

pub(crate) fn context(&self) -> &CompilationScope {
&self.context
}

pub(crate) fn emits(&self) -> &ByteBuffer {
&self.emits
}
Expand Down
9 changes: 4 additions & 5 deletions src/compiler/rst/scope.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use std::collections::HashMap;
use std::path::Path;

use crate::compiler::cst::CstEmitStatement;
use crate::compiler::native_fn::{NativeFunction, NativeFunctionIndex};
use crate::util::id::HexoId;
use crate::util::byte_buffer::ByteBuffer;
use std::collections::HashMap;
use std::path::{Path, PathBuf};
use crate::util::id::HexoId;

#[derive(Clone, Debug)]
pub(crate) struct ConstantBinding {
Expand All @@ -27,15 +28,13 @@ pub(crate) struct LocalCompilationScope {

#[derive(Clone, Debug)]
pub(crate) struct CompilationScope {
self_path: PathBuf,
local_scopes: HashMap<HexoId, LocalCompilationScope>,
native_function_index: NativeFunctionIndex,
}

impl CompilationScope {
pub(crate) fn new(path: &Path) -> CompilationScope {
CompilationScope {
self_path: path.to_path_buf(),
local_scopes: HashMap::new(),
native_function_index: NativeFunctionIndex::new(),
}
Expand Down
4 changes: 3 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#![feature(test)]

#![allow(
redundant_field_names
)]

use crate::cli::Cli;

Expand Down
2 changes: 1 addition & 1 deletion src/util/byte_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl From<Vec<u8>> for ByteBuffer {
}

mod test {
use crate::util::byte_buffer::ByteBuffer;
use super::ByteBuffer;

#[test]
fn byte_push() {
Expand Down

0 comments on commit c1c350f

Please sign in to comment.