From 467141184aa274126ff7e2a41d08bb621b7a3fdf Mon Sep 17 00:00:00 2001 From: Philip Herron Date: Thu, 24 Dec 2020 21:26:26 +0000 Subject: Implement constant expressions --- gcc/rust/resolve/rust-ast-resolve-item.h | 6 ++++++ gcc/rust/resolve/rust-ast-resolve-toplevel.h | 9 +++++++++ 2 files changed, 15 insertions(+) (limited to 'gcc/rust/resolve') diff --git a/gcc/rust/resolve/rust-ast-resolve-item.h b/gcc/rust/resolve/rust-ast-resolve-item.h index 2c21a52..eca52dc 100644 --- a/gcc/rust/resolve/rust-ast-resolve-item.h +++ b/gcc/rust/resolve/rust-ast-resolve-item.h @@ -39,6 +39,12 @@ public: ~ResolveItem () {} + void visit (AST::ConstantItem &constant) + { + ResolveType::go (constant.get_type ().get (), constant.get_node_id ()); + ResolveExpr::go (constant.get_expr ().get (), constant.get_node_id ()); + } + void visit (AST::Function &function) { if (function.has_return_type ()) diff --git a/gcc/rust/resolve/rust-ast-resolve-toplevel.h b/gcc/rust/resolve/rust-ast-resolve-toplevel.h index fcc9663..0b6256e 100644 --- a/gcc/rust/resolve/rust-ast-resolve-toplevel.h +++ b/gcc/rust/resolve/rust-ast-resolve-toplevel.h @@ -36,6 +36,15 @@ public: ~ResolveTopLevel () {} + void visit (AST::ConstantItem &constant) + { + resolver->get_name_scope ().insert (constant.get_identifier (), + constant.get_node_id ()); + resolver->insert_new_definition (constant.get_node_id (), + Definition{constant.get_node_id (), + constant.get_node_id ()}); + } + void visit (AST::Function &function) { // function_names are simple std::String identifiers so this can be a -- cgit v1.1