got redo working

This commit is contained in:
2025-08-17 15:44:17 -06:00
parent 491cf29e68
commit f554b09efc
5 changed files with 8 additions and 11 deletions

View File

@@ -1,4 +1,4 @@
use std::{cell::RefCell, clone};
use std::cell::RefCell;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct IdGenerator {
@@ -118,7 +118,7 @@ impl TypeUsage {
}
pub fn replace_type(&self, old: &str, new: &Identifier) -> TypeUsage {
return match &self {
match &self {
TypeUsage::Function(function) => {
return TypeUsage::Function(FunctionTypeUsage {
arguments: function.arguments.iter().map(|arg| arg.replace_type(old, new)).collect(),
@@ -126,7 +126,7 @@ impl TypeUsage {
});
}
TypeUsage::Named(named) => {
let name = if (named.name.name.value == old) {
let name = if named.name.name.value == old {
new.clone()
} else {
named.name.clone()
@@ -138,7 +138,7 @@ impl TypeUsage {
}
TypeUsage::Namespace(namespace) => return TypeUsage::Namespace(namespace.clone()),
TypeUsage::Unknown(unkown) => return TypeUsage::Unknown(unkown.clone()),
};
}
}
}

View File

@@ -413,7 +413,7 @@ impl TreeWalkInterpreter {
}
ast::Subexpression::VariableUsage(variable_usage) => {
if !ctx.environment.contains_key(&variable_usage.name.name.value) {
panic!(variable_usage.name.name.value.clone());
panic!("{}", variable_usage.name.name.value.clone());
}
let variable_value = match &ctx.environment[&variable_usage.name.name.value] {
NamedEntity::Variable(v) => v.clone(),

View File

@@ -32,9 +32,6 @@ fn main() {
.get_matches();
let input = matches.value_of("INPUT").unwrap();
let default_output = input.rsplitn(2, ".").collect::<Vec<&str>>().last().unwrap().clone();
let _output = matches.value_of("OUTPUT").unwrap_or(default_output);
let contents = fs::read_to_string(input).expect("input file not found");
let unknown_id_gen = ast::IdGenerator::new("S");
let module_ast = grammar::ModuleParser::new().parse(&unknown_id_gen, &contents).unwrap(); //TODO: convert to error

View File

@@ -132,7 +132,7 @@ impl TraitChecker {
for impl_function in impl_.functions.iter() {
let mut found = false;
for trait_item in trait_declaration.functions.iter() {
let declaration = match trait_item {
match trait_item {
ast::TraitItem::FunctionDeclaration(declaration) => {
if impl_function.declaration.name.name.value == declaration.name.name.value {
found = true;

View File

@@ -536,12 +536,12 @@ impl Context {
fn add_impl(&self, impl_: &ast::Impl, traits: &HashMap<String, ast::TraitTypeDeclaration>) -> Result<Context> {
let mut functions = HashMap::new();
for func in impl_.functions.iter() {
if (func.declaration.arguments.len() == 0) {
if func.declaration.arguments.len() == 0 {
continue;
}
match &func.declaration.arguments[0].type_ {
ast::TypeUsage::Named(named) => {
if (named.name.name.value != "Self") {
if named.name.name.value != "Self" {
continue;
}
}