Compare commits

..

No commits in common. "257a7e64c2f5473b7ebe3d7858010504e6b322b0" and "40d611ae37bcc68a103d0c83ee94c69b3e1fd3b5" have entirely different histories.

3 changed files with 51 additions and 107 deletions

View file

@ -653,7 +653,6 @@ impl<'a> Semantics<'a> {
TreeKind::LetStatement => Some(Type::Nothing), TreeKind::LetStatement => Some(Type::Nothing),
TreeKind::ReturnStatement => Some(Type::Unreachable), TreeKind::ReturnStatement => Some(Type::Unreachable),
TreeKind::ExpressionStatement => self.type_of_expression_statement(tree), TreeKind::ExpressionStatement => self.type_of_expression_statement(tree),
TreeKind::IfStatement => self.type_of_if_statement(tree),
TreeKind::Identifier => self.type_of_identifier(t, tree), TreeKind::Identifier => self.type_of_identifier(t, tree),
TreeKind::FunctionDecl => self.type_of_function_decl(tree), TreeKind::FunctionDecl => self.type_of_function_decl(tree),
@ -1021,10 +1020,6 @@ impl<'a> Semantics<'a> {
Some(Type::Function(parameter_types, return_type)) Some(Type::Function(parameter_types, return_type))
} }
fn type_of_if_statement(&self, tree: &Tree) -> Option<Type> {
Some(self.type_of(tree.nth_tree(0)?))
}
pub fn dump_compiler_state(&self, tr: Option<TreeRef>) { pub fn dump_compiler_state(&self, tr: Option<TreeRef>) {
eprintln!("Parsed the tree as:"); eprintln!("Parsed the tree as:");
eprintln!("\n{}", self.syntax_tree.dump(true)); eprintln!("\n{}", self.syntax_tree.dump(true));

View file

@ -1,61 +1,24 @@
fun test() { true and false or false and !true;
true and false or false and !true
}
// @no-errors // @no-errors
// @compiles-to:
// | function test (0 args, 0 locals):
// | strings (0):
// | code (15):
// | 0: PushTrue
// | 1: JumpFalse(4)
// | 2: PushTrue
// | 3: Jump(5)
// | 4: PushFalse
// | 5: JumpTrue(8)
// | 6: PushTrue
// | 7: Jump(14)
// | 8: PushFalse
// | 9: JumpFalse(12)
// | 10: PushTrue
// | 11: Jump(14)
// | 12: PushTrue
// | 13: BoolNot
// | 14: Return
// | function << module >> (0 args, 0 locals):
// | strings (0):
// | code (2):
// | 0: PushNothing
// | 1: Return
// |
// @eval: Bool(false)
// @type: 15 bool // @type: 15 bool
// @concrete: // @concrete:
// | File // | File
// | FunctionDecl // | ExpressionStatement
// | Fun:'"fun"' // | BinaryExpression
// | Identifier:'"test"' // | BinaryExpression
// | ParamList // | LiteralExpression
// | LeftParen:'"("' // | True:'"true"'
// | RightParen:'")"' // | And:'"and"'
// | Block // | LiteralExpression
// | LeftBrace:'"{"' // | False:'"false"'
// | ExpressionStatement // | Or:'"or"'
// | BinaryExpression // | BinaryExpression
// | BinaryExpression // | LiteralExpression
// | LiteralExpression // | False:'"false"'
// | True:'"true"' // | And:'"and"'
// | And:'"and"' // | UnaryExpression
// | LiteralExpression // | Bang:'"!"'
// | False:'"false"' // | LiteralExpression
// | Or:'"or"' // | True:'"true"'
// | BinaryExpression // | Semicolon:'";"'
// | LiteralExpression
// | False:'"false"'
// | And:'"and"'
// | UnaryExpression
// | Bang:'"!"'
// | LiteralExpression
// | True:'"true"'
// | RightBrace:'"}"'
//

View file

@ -1,59 +1,51 @@
fun test() { if true { "discarded"; 23 } else { 45 }
if true { "discarded"; 23 } else { 45 }
}
// @no-errors // @no-errors
// Here come some type probes! // Here come some type probes!
// (type of the condition) // (type of the condition)
// @type: 20 bool // @type: 3 bool
// //
// (the discarded expression) // (the discarded expression)
// @type: 27 string // @type: 10 string
// //
// (the "then" clause) // (the "then" clause)
// @type: 40 f64 // @type: 23 f64
// @type: 43 f64 // @type: 26 f64
// //
// (the "else" clause) // (the "else" clause)
// @type: 52 f64 // @type: 35 f64
// @type: 55 f64 // @type: 38 f64
//
// (the overall expression)
// @type: 0 f64
// //
// @concrete: // @concrete:
// | File // | File
// | FunctionDecl // | IfStatement
// | Fun:'"fun"' // | ConditionalExpression
// | Identifier:'"test"' // | If:'"if"'
// | ParamList // | LiteralExpression
// | LeftParen:'"("' // | True:'"true"'
// | RightParen:'")"' // | Block
// | Block // | LeftBrace:'"{"'
// | LeftBrace:'"{"' // | ExpressionStatement
// | IfStatement
// | ConditionalExpression
// | If:'"if"'
// | LiteralExpression // | LiteralExpression
// | True:'"true"' // | String:'"\"discarded\""'
// | Block // | Semicolon:'";"'
// | LeftBrace:'"{"' // | ExpressionStatement
// | ExpressionStatement // | LiteralExpression
// | LiteralExpression // | Number:'"23"'
// | String:'"\"discarded\""' // | RightBrace:'"}"'
// | Semicolon:'";"' // | Else:'"else"'
// | ExpressionStatement // | Block
// | LiteralExpression // | LeftBrace:'"{"'
// | Number:'"23"' // | ExpressionStatement
// | RightBrace:'"}"' // | LiteralExpression
// | Else:'"else"' // | Number:'"45"'
// | Block // | RightBrace:'"}"'
// | LeftBrace:'"{"'
// | ExpressionStatement
// | LiteralExpression
// | Number:'"45"'
// | RightBrace:'"}"'
// | RightBrace:'"}"'
// //
// @compiles-to: // @compiles-to:
// | function test (0 args, 0 locals): // | function << module >> (0 args, 0 locals):
// | strings (1): // | strings (1):
// | 0: "discarded" // | 0: "discarded"
// | code (8): // | code (8):
@ -65,10 +57,4 @@ fun test() {
// | 5: Jump(7) // | 5: Jump(7)
// | 6: PushFloat(45.0) // | 6: PushFloat(45.0)
// | 7: Return // | 7: Return
// | function << module >> (0 args, 0 locals):
// | strings (0):
// | code (2):
// | 0: PushNothing
// | 1: Return
// | // |
// @eval: Float(23.0)