no segfault!

This commit is contained in:
2026-01-28 22:30:02 +02:00
parent 1f4645ed24
commit 834b5b1213
21 changed files with 1311 additions and 338 deletions

View File

@@ -2,7 +2,7 @@ use std::collections::HashMap;
use statement::{ConstVar, Enum, Function, StaticVar, Struct};
use crate::{common::loc::LocBox, parser::ast::{expr::Path, statement::Let, typ::Type}};
use crate::{common::loc::LocBox, parser::ast::{expr::StructLit, literal::Literal, statement::Let, typ::Type}};
pub use crate::tokeniser::tokentype::*;
pub mod expr;
@@ -11,7 +11,7 @@ pub mod statement;
pub mod typ;
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub struct Scope {
pub vars: HashMap<Ident, LocBox<Let>>,
pub static_vars: HashMap<Ident, StaticVar>,
@@ -29,7 +29,10 @@ pub struct Program {
pub member_functions: HashMap<Ident, HashMap<Ident, LocBox<Function>>>,
pub static_vars: HashMap<Ident, StaticVar>,
pub const_vars: HashMap<Ident, ConstVar>,
pub scope: Option<Scope>
pub literals: HashMap<String, Literal>, // string is id of literal
pub struct_literals: HashMap<String, StructLit>, // string is id of literal
pub scope: Option<Scope>,
pub curr_fn_args: HashMap<Ident, LocBox<Type>>
}
@@ -102,7 +105,7 @@ impl Program {
}
#[derive(Debug, Clone, PartialEq, PartialOrd)]
#[derive(Debug, Clone, PartialEq, PartialOrd, Hash)]
pub enum Ast {
Expr(LocBox<expr::Expr>),
Statement(LocBox<statement::Statement>),