rename to assembly_pass
This commit is contained in:
parent
9fd0b02380
commit
8dab4d3eee
8 changed files with 14 additions and 14 deletions
|
|
@ -32,7 +32,7 @@ Borrowing from that: 'the place where http lives'.
|
||||||
- Therefore, services cannot call other services, because that is the recipe for spaghetti. Refactor your logic, abstract and put lower level code in utilities.
|
- Therefore, services cannot call other services, because that is the recipe for spaghetti. Refactor your logic, abstract and put lower level code in utilities.
|
||||||
- openapi support
|
- openapi support
|
||||||
|
|
||||||
### An interpreter written in Rust.
|
### An compiler/runtime written in Rust.
|
||||||
I cherry picked things I like, mostly from rust and python.
|
I cherry picked things I like, mostly from rust and python.
|
||||||
- strictly typed
|
- strictly typed
|
||||||
- [] is a list
|
- [] is a list
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::builtins::lookup;
|
use crate::builtins::lookup;
|
||||||
use crate::compiler::asm_pass::Op::{Add, And, Assign, BitAnd, BitOr, BitXor, Call, CallBuiltin, Constant, DefList, DefMap, Divide, Dup, Equal, Get, Goto, GotoIf, GotoIfNot, Greater, GreaterEqual, Less, LessEqual, ListGet, Multiply, Negate, Not, NotEqual, Or, Pop, Print, Return, Shr, Subtract};
|
use crate::compiler::assembly_pass::Op::{Add, And, Assign, BitAnd, BitOr, BitXor, Call, CallBuiltin, Constant, DefList, DefMap, Divide, Dup, Equal, Get, Goto, GotoIf, GotoIfNot, Greater, GreaterEqual, Less, LessEqual, ListGet, Multiply, Negate, Not, NotEqual, Or, Pop, Print, Return, Shr, Subtract};
|
||||||
use crate::compiler::ast_pass::Expression::NamedParameter;
|
use crate::compiler::ast_pass::Expression::NamedParameter;
|
||||||
use crate::compiler::ast_pass::{Expression, Function, Parameter, Statement};
|
use crate::compiler::ast_pass::{Expression, Function, Parameter, Statement};
|
||||||
use crate::compiler::tokens::TokenType;
|
use crate::compiler::tokens::TokenType;
|
||||||
|
|
@ -2,7 +2,7 @@ use std::collections::HashMap;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use walkdir::WalkDir;
|
use walkdir::WalkDir;
|
||||||
use crate::{compiler, symbol_builder, AsmRegistry, TIPI_EXT};
|
use crate::{compiler, symbol_builder, AsmRegistry, TIPI_EXT};
|
||||||
use crate::compiler::asm_pass::AsmChunk;
|
use crate::compiler::assembly_pass::AsmChunk;
|
||||||
use crate::errors::TipiLangError;
|
use crate::errors::TipiLangError;
|
||||||
use crate::errors::TipiLangError::Platform;
|
use crate::errors::TipiLangError::Platform;
|
||||||
|
|
||||||
|
|
@ -10,7 +10,7 @@ mod compiler_tests;
|
||||||
pub mod scan_pass;
|
pub mod scan_pass;
|
||||||
pub mod ast_pass;
|
pub mod ast_pass;
|
||||||
pub mod tokens;
|
pub mod tokens;
|
||||||
pub mod asm_pass;
|
pub mod assembly_pass;
|
||||||
|
|
||||||
pub fn compile_sourcedir(source_dir: &str) -> Result<HashMap<String, AsmChunk>, TipiLangError> {
|
pub fn compile_sourcedir(source_dir: &str) -> Result<HashMap<String, AsmChunk>, TipiLangError> {
|
||||||
let mut asm_registry = AsmRegistry::new();
|
let mut asm_registry = AsmRegistry::new();
|
||||||
|
|
@ -27,7 +27,7 @@ pub fn compile_sourcedir(source_dir: &str) -> Result<HashMap<String, AsmChunk>,
|
||||||
let path = path.strip_prefix(source_dir).unwrap().replace(TIPI_EXT, "");
|
let path = path.strip_prefix(source_dir).unwrap().replace(TIPI_EXT, "");
|
||||||
|
|
||||||
symbol_builder::build(&path, &statements, &mut symbol_table);
|
symbol_builder::build(&path, &statements, &mut symbol_table);
|
||||||
asm_pass::compile(Some(&path), &statements, &symbol_table, &mut asm_registry)?;
|
assembly_pass::compile(Some(&path), &statements, &symbol_table, &mut asm_registry)?;
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!("{}", e);
|
println!("{}", e);
|
||||||
|
|
@ -51,7 +51,7 @@ pub fn compile(src: &str) -> Result<HashMap<String, AsmChunk>, TipiLangError> {
|
||||||
let mut symbol_table = HashMap::new();
|
let mut symbol_table = HashMap::new();
|
||||||
let ast = compiler::ast_pass::compile(None, tokens, &mut symbol_table)?;
|
let ast = compiler::ast_pass::compile(None, tokens, &mut symbol_table)?;
|
||||||
symbol_builder::build("", &ast, &mut symbol_table);
|
symbol_builder::build("", &ast, &mut symbol_table);
|
||||||
asm_pass::compile(None, &ast, &symbol_table, &mut asm_registry)?;
|
assembly_pass::compile(None, &ast, &symbol_table, &mut asm_registry)?;
|
||||||
Ok(asm_registry)
|
Ok(asm_registry)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -62,7 +62,7 @@ pub(crate) fn run(src: &str) -> Result<crate::value::Value, TipiLangError> {
|
||||||
let ast = compiler::ast_pass::compile(None, tokens, &mut symbol_table)?;
|
let ast = compiler::ast_pass::compile(None, tokens, &mut symbol_table)?;
|
||||||
symbol_builder::build("", &ast, &mut symbol_table);
|
symbol_builder::build("", &ast, &mut symbol_table);
|
||||||
let mut asm_registry = HashMap::new();
|
let mut asm_registry = HashMap::new();
|
||||||
asm_pass::compile(None, &ast, &symbol_table, &mut asm_registry)?;
|
assembly_pass::compile(None, &ast, &symbol_table, &mut asm_registry)?;
|
||||||
let registry = arc_swap::ArcSwap::from(std::sync::Arc::new(asm_registry));
|
let registry = arc_swap::ArcSwap::from(std::sync::Arc::new(asm_registry));
|
||||||
crate::vm::interpret(registry.load(), "main").map_err(TipiLangError::from)
|
crate::vm::interpret(registry.load(), "main").map_err(TipiLangError::from)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use std::thread;
|
||||||
use std::time::{Duration, SystemTime};
|
use std::time::{Duration, SystemTime};
|
||||||
use arc_swap::ArcSwap;
|
use arc_swap::ArcSwap;
|
||||||
use log::info;
|
use log::info;
|
||||||
use crate::compiler::asm_pass::AsmChunk;
|
use crate::compiler::assembly_pass::AsmChunk;
|
||||||
use crate::compiler::compile_sourcedir;
|
use crate::compiler::compile_sourcedir;
|
||||||
|
|
||||||
const ONE_SEC: Duration = Duration::from_secs(1);
|
const ONE_SEC: Duration = Duration::from_secs(1);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::compiler::asm_pass::AsmChunk;
|
use crate::compiler::assembly_pass::AsmChunk;
|
||||||
use crate::compiler::ast_pass::{Expression, Statement};
|
use crate::compiler::ast_pass::{Expression, Statement};
|
||||||
use crate::errors::CompilerErrorAtLine;
|
use crate::errors::CompilerErrorAtLine;
|
||||||
use crate::symbol_builder::Symbol;
|
use crate::symbol_builder::Symbol;
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ use std::collections::HashMap;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use arc_swap::ArcSwap;
|
use arc_swap::ArcSwap;
|
||||||
use log::info;
|
use log::info;
|
||||||
use tipi_lang::compiler::asm_pass::AsmChunk;
|
use tipi_lang::compiler::assembly_pass::AsmChunk;
|
||||||
use tipi_lang::compiler::{compile_sourcedir, map_underlying};
|
use tipi_lang::compiler::{compile_sourcedir, map_underlying};
|
||||||
|
|
||||||
/// A simple CLI tool to greet users
|
/// A simple CLI tool to greet users
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::compiler::asm_pass::AsmChunk;
|
use crate::compiler::assembly_pass::AsmChunk;
|
||||||
use crate::compiler::scan_pass::scan;
|
use crate::compiler::scan_pass::scan;
|
||||||
use crate::compiler::{asm_pass, ast_pass, map_underlying};
|
use crate::compiler::{assembly_pass, ast_pass, map_underlying};
|
||||||
use crate::errors::TipiLangError;
|
use crate::errors::TipiLangError;
|
||||||
use crate::symbol_builder;
|
use crate::symbol_builder;
|
||||||
use crate::vm::Vm;
|
use crate::vm::Vm;
|
||||||
|
|
@ -16,7 +16,7 @@ pub fn start(registry: Arc<ArcSwap<HashMap<String, AsmChunk>>>) -> Result<(), Ti
|
||||||
println!(":h for help");
|
println!(":h for help");
|
||||||
let mut symbol_table = HashMap::new();
|
let mut symbol_table = HashMap::new();
|
||||||
let mut vm = Vm::new(®istry.load());
|
let mut vm = Vm::new(®istry.load());
|
||||||
let mut asm_pass = asm_pass::AsmPass::new("main");
|
let mut asm_pass = assembly_pass::AsmPass::new("main");
|
||||||
loop {
|
loop {
|
||||||
print!(">");
|
print!(">");
|
||||||
io::stdout().flush().map_err(map_underlying())?;
|
io::stdout().flush().map_err(map_underlying())?;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::compiler::asm_pass::{AsmChunk, Op};
|
use crate::compiler::assembly_pass::{AsmChunk, Op};
|
||||||
use crate::errors::{RuntimeError, ValueError};
|
use crate::errors::{RuntimeError, ValueError};
|
||||||
use crate::value::{Object, Value};
|
use crate::value::{Object, Value};
|
||||||
use crate::{AsmRegistry};
|
use crate::{AsmRegistry};
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue