Skip to content

Commit

Permalink
Only Expose Root Expression from SyntaxTree
Browse files Browse the repository at this point in the history
We don't need more than a reference to the root expression for
lowering now. Fixup a TODO and simplify the bind.
  • Loading branch information
iwillspeak committed Aug 16, 2020
1 parent 1ee2241 commit c1fef2f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/sem/binder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@ impl Binder {
pub fn bind_tree(&mut self, tree: syntax::SyntaxTree<'_>) -> Expression {
let source = tree.source();
add_builtin_types(self.scopes.current_mut(), source);
let (expr, _end) = tree.into_parts();
self.declare_expression(&expr);
self.bind_expression(&expr, source)
let expr = tree.root_expression();
self.declare_expression(expr);
self.bind_expression(expr, source)
}

/// Declare any items in the current expression that should be
Expand Down
11 changes: 5 additions & 6 deletions src/syntax/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ impl<'a> SyntaxTree<'a> {
!self.diagnostics.is_empty()
}

/// Returns the root of the expression tree and the EOF token
/// Get the Root Expression
///
/// FIXME: should root and token just be public and remove this,
/// `root()`, and `end()`?
pub fn into_parts(self) -> (Expression, Token) {
(self.root, self.end)
/// Accesses the base of the expression tree. The only other part
/// of the tree is the `end` token.
pub fn root_expression(&self) -> &Expression {
&self.root
}

/// Access the Borrowed Source
Expand All @@ -125,7 +125,6 @@ impl<'a> SyntaxTree<'a> {
}
}

///
/// Walks the subnodes of this tree and prints a text representation
/// of them as an ASCII tree.
fn pretty_tree<W>(
Expand Down

0 comments on commit c1fef2f

Please sign in to comment.