aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Herron <phil@nebuloninc.com>2020-05-16 20:30:04 +0100
committerPhilip Herron <philip.herron@embecosm.com>2020-11-28 19:12:14 +0000
commitfffedd184038ba59ac669437c672ec940cc743ac (patch)
tree325025b0b4eda2cb1b5fa1d6f5aa5eb7f9ef1f9a
parentb9289b5969123d8c4edc94f3de62deb7921f572d (diff)
downloadgcc-fffedd184038ba59ac669437c672ec940cc743ac.zip
gcc-fffedd184038ba59ac669437c672ec940cc743ac.tar.gz
gcc-fffedd184038ba59ac669437c672ec940cc743ac.tar.bz2
Add a basic lookup for builtin types
-rw-r--r--gcc/rust/analysis/rust-resolution.cc37
1 files changed, 31 insertions, 6 deletions
diff --git a/gcc/rust/analysis/rust-resolution.cc b/gcc/rust/analysis/rust-resolution.cc
index 186ecd3c..fe4dd6d 100644
--- a/gcc/rust/analysis/rust-resolution.cc
+++ b/gcc/rust/analysis/rust-resolution.cc
@@ -1,6 +1,21 @@
#include "rust-resolution.h"
#include "rust-diagnostics.h"
+#define ADD_BUILTIN_TYPE(_X, _S) \
+ do \
+ { \
+ AST::PathIdentSegment seg (_X); \
+ auto typePath = ::std::unique_ptr<AST::TypePathSegment> ( \
+ new AST::TypePathSegment (::std::move (seg), false, \
+ Linemap::unknown_location ())); \
+ ::std::vector< ::std::unique_ptr<AST::TypePathSegment> > segs; \
+ segs.push_back (::std::move (typePath)); \
+ auto bType = new AST::TypePath (::std::move (segs), \
+ Linemap::unknown_location (), false); \
+ _S.Insert (_X, bType); \
+ } \
+ while (0)
+
namespace Rust {
namespace Analysis {
@@ -9,12 +24,22 @@ TypeResolution::TypeResolution (AST::Crate &crate) : crate (crate)
typeScope.Push ();
scope.Push ();
- // push all builtin types
- // base is parse_path_ident_segment based up on segments
- /* scope.Insert ("u8",
- new AST::MaybeNamedParam (Identifier ("u8"),
- AST::MaybeNamedParam::IDENTIFIER,
- NULL, Location ()));*/
+ // push all builtin types - this is probably too basic for future needs
+ ADD_BUILTIN_TYPE ("u8", typeScope);
+ ADD_BUILTIN_TYPE ("u16", typeScope);
+ ADD_BUILTIN_TYPE ("u32", typeScope);
+ ADD_BUILTIN_TYPE ("u64", typeScope);
+
+ ADD_BUILTIN_TYPE ("i8", typeScope);
+ ADD_BUILTIN_TYPE ("i16", typeScope);
+ ADD_BUILTIN_TYPE ("i32", typeScope);
+ ADD_BUILTIN_TYPE ("i64", typeScope);
+
+ ADD_BUILTIN_TYPE ("f32", typeScope);
+ ADD_BUILTIN_TYPE ("f64", typeScope);
+
+ ADD_BUILTIN_TYPE ("char", typeScope);
+ ADD_BUILTIN_TYPE ("str", typeScope);
}
TypeResolution::~TypeResolution ()