From c26549d254aff09d58764eb40455dbd325c86588 Mon Sep 17 00:00:00 2001 From: pixelsystem Date: Fri, 1 Mar 2024 06:26:53 -1000 Subject: [PATCH] Set up for #14 --- compiler/src/ast.rs | 2 ++ compiler/src/inference.rs | 2 ++ compiler/src/parser.rs | 54 +++++++++++++++++++++++++++++++-------- 3 files changed, 47 insertions(+), 11 deletions(-) diff --git a/compiler/src/ast.rs b/compiler/src/ast.rs index 24ea1af..ba6d46e 100644 --- a/compiler/src/ast.rs +++ b/compiler/src/ast.rs @@ -187,6 +187,7 @@ pub struct ArgDeclaration { pub ty: Option, } + #[derive(PartialEq, Debug)] pub struct ValueDeclaration { pub loc: crate::Location, //should be location of the ident. @@ -196,6 +197,7 @@ pub struct ValueDeclaration { pub ty: Option, pub value: ValueType, pub generictypes: Option, + pub abi : Option, } impl ValueDeclaration { fn replace(&mut self, nice_name: &str, actual: &str) { diff --git a/compiler/src/inference.rs b/compiler/src/inference.rs index ead0049..2829640 100644 --- a/compiler/src/inference.rs +++ b/compiler/src/inference.rs @@ -113,6 +113,7 @@ impl Context { ty, value, generictypes, + abi, } = val; let id = self.get_next_expr_id(); @@ -1356,6 +1357,7 @@ mod tests { super::untyped_ast::Expr::ValueRead("a".to_string(), (0, 0)), ), generictypes: None, + abi:None }, )], }; diff --git a/compiler/src/parser.rs b/compiler/src/parser.rs index 8f050fe..ce3adb2 100644 --- a/compiler/src/parser.rs +++ b/compiler/src/parser.rs @@ -1196,7 +1196,8 @@ where ], ty: Some(types::ERROR), value: ValueType::Expr(Expr::Error), - generictypes: generics + generictypes: generics, + abi:None }), loc, warnings, @@ -1607,6 +1608,7 @@ where ty: Some(types::ERROR), value: ValueType::Expr(Expr::Error), generictypes:generics, + abi:None }, loc:ident_span, warnings:Vec::new(), @@ -1649,7 +1651,8 @@ where args, ty: Some(types::ERROR), value: ValueType::Expr(ast::Expr::Error), - generictypes:generics + generictypes:generics, + abi:None, }, loc:ident_span, warnings, @@ -1684,7 +1687,8 @@ where args, ty, value: ValueType::Expr(Expr::Error), - generictypes: generics + generictypes: generics, + abi:None, }, loc:ident_span, warnings, @@ -1706,7 +1710,8 @@ where args, ty, value: ValueType::Expr(Expr::Error), - generictypes: generics + generictypes: generics, + abi:None, }, loc:ident_span, warnings, @@ -1742,6 +1747,7 @@ where ty, value: ValueType::Expr(Expr::Error), generictypes: generics, + abi:None }, loc:ident_span, warnings, @@ -1780,6 +1786,7 @@ where ty, value, generictypes: generics, + abi:None }, loc:ident_span, warnings, @@ -1797,6 +1804,7 @@ where ty: Some(types::ERROR), value: ValueType::Expr(Expr::Error), generictypes:generics, + abi:None, }, loc:(0,0), warnings:Vec::new(), @@ -2437,6 +2445,7 @@ mod tests { value: "5".to_string(), }), generictypes: None, + abi:None }), parser.next_statement().ast ); @@ -2467,6 +2476,7 @@ mod tests { (1, 4) )]), generictypes: None, + abi:None, }), parser.declaration().ast ) @@ -2506,6 +2516,7 @@ let foo _ : ( int32 -> int32 ) -> int32 = (2, 4) )]), generictypes: None, + abi:None, }), parser.next_statement().ast, "function as arg" @@ -2542,6 +2553,7 @@ let foo _ : int32 -> ( int32 -> int32 ) = (2, 4) )]), generictypes:None, + abi:None, }), parser.next_statement().ast, "function as rt" @@ -2563,6 +2575,7 @@ let foo _ : int32 -> ( int32 -> int32 ) = value: "3".to_owned(), }), generictypes: None, + abi:None, }), parser.declaration().ast, "simple declaration" @@ -2591,6 +2604,7 @@ let foo _ : int32 -> ( int32 -> int32 ) = args: Vec::new(), value: ValueType::Expr(Expr::StringLiteral(r#"merp " yes"#.to_string())), generictypes: None, + abi:None, }), Statement::Return( Expr::NumericLiteral { @@ -2600,6 +2614,7 @@ let foo _ : int32 -> ( int32 -> int32 ) = ) ]), generictypes: None, + abi:None, }), parser.declaration().ast, "declaration with block" @@ -2645,6 +2660,7 @@ let foo _ : int32 -> ( int32 -> int32 ) = ) ]), generictypes: None, + abi:None, }), parser.declaration().ast, "operator declaration w/ function call", @@ -2699,6 +2715,7 @@ let main _ : int32 -> int32 = ) ]), generictypes: None, + abi:None, }), parser.next_statement().ast, ) @@ -2791,6 +2808,7 @@ let main _ : int32 -> int32 = ) ]), generictypes: None, + abi:None, }), parser.next_statement().ast ); @@ -2887,6 +2905,7 @@ let main _ : int32 -> int32 = ) ].into_iter().collect(), }), + abi:None, }), parser.declaration().ast, ) @@ -2997,7 +3016,8 @@ for type Tuple = { }, (1, 4) )]), - generictypes: None + generictypes: None, + abi:None, }), parser.declaration().ast ) @@ -3082,7 +3102,8 @@ for type Tuple = { ), loc: (0, 36) })), - generictypes: None + generictypes: None, + abi:None, }), parser.declaration().ast, "inline_expr" @@ -3129,7 +3150,8 @@ for type Tuple = { ), loc: (2, 41) })), - generictypes: None + generictypes: None, + abi:None, }), parser.declaration().ast, "out_of_line_expr" @@ -3188,6 +3210,7 @@ for type Tuple = { loc: (7, 44) })), generictypes: None, + abi:None, }), parser.declaration().ast, "expr_with_statement" @@ -3246,7 +3269,8 @@ for type Tuple = { ), loc: (14, 52) })), - generictypes: None + generictypes: None, + abi:None, }), parser.declaration().ast, "expr with else if" @@ -3310,6 +3334,7 @@ for type Tuple = { loc: (17, 4) })]), generictypes: None, + abi:None, }), parser.declaration().ast, "statement" @@ -3368,6 +3393,7 @@ for type Tuple = { loc: (25, 4), })]), generictypes: None, + abi:None, }), parser.declaration().ast, "statement_with_else_if" @@ -3427,6 +3453,7 @@ for type Tuple = { loc: (32, 57) })), generictypes: None, + abi:None, }), parser.declaration().ast, "multi line expr with else if" @@ -3491,6 +3518,7 @@ for type Tuple = { ] })), generictypes: None, + abi:None, }), parser.declaration().ast, "match_expr_ints" @@ -3526,7 +3554,8 @@ for type Tuple = { value: ValueType::Expr(ast::Expr::NumericLiteral { value: "2".to_string(), }), - generictypes: None + generictypes: None, + abi:None, })], ret: Some( ast::Expr::BinaryOpCall(BinaryOpCall { @@ -3573,6 +3602,7 @@ for type Tuple = { ] })), generictypes: None, + abi:None, }), parser.declaration().ast, "match_expr_with_block" @@ -3647,7 +3677,8 @@ for type Tuple = { }, ] })]), - generictypes: None + generictypes: None, + abi:None, }), parser.declaration().ast, "match_statement", @@ -3684,7 +3715,8 @@ let arr = [0,0,0,0]; ], loc: (1, 11) }), - generictypes: None + generictypes: None, + abi:None, }), arr, "arrays"