Skip to content

Commit 3295942

Browse files
committed
Add in a toplevel pass to grab global declarations for analysis pass
1 parent 3ba43fc commit 3295942

File tree

7 files changed

+817
-8
lines changed

7 files changed

+817
-8
lines changed

gcc/rust/Make-lang.in

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ GRS_OBJS = \
7070
rust/rust-ast-full-test.o \
7171
rust/rust-session-manager.o \
7272
rust/rust-resolution.o \
73+
rust/rust-scan.o \
7374
rust/rust-compile.o \
7475
$(END)
7576
# removed object files from here

gcc/rust/analysis/rust-resolution.cc

+9-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
namespace Rust {
2020
namespace Analysis {
2121

22-
TypeResolution::TypeResolution (AST::Crate &crate) : crate (crate)
22+
TypeResolution::TypeResolution (AST::Crate &crate, TopLevelScan &toplevel)
23+
: crate (crate), toplevel (toplevel)
2324
{
2425
typeScope.Push ();
2526
scope.Push ();
@@ -50,9 +51,9 @@ TypeResolution::~TypeResolution ()
5051
}
5152

5253
bool
53-
TypeResolution::ResolveNamesAndTypes (AST::Crate &crate)
54+
TypeResolution::ResolveNamesAndTypes (AST::Crate &crate, TopLevelScan &toplevel)
5455
{
55-
TypeResolution resolver (crate);
56+
TypeResolution resolver (crate, toplevel);
5657
return resolver.go ();
5758
}
5859

@@ -315,7 +316,11 @@ TypeResolution::visit (AST::AssignmentExpr &expr)
315316
// scope will require knowledge of the type
316317

317318
// do the lhsType and the rhsType match
318-
typesAreCompatible (lhsType, rhsType, expr.right_expr->get_locus_slow ());
319+
if (!typesAreCompatible (lhsType, rhsType,
320+
expr.right_expr->get_locus_slow ()))
321+
return;
322+
323+
// is the lhs mutable?
319324
}
320325

321326
void

gcc/rust/analysis/rust-resolution.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "rust-system.h"
44
#include "rust-ast-full.h"
55
#include "rust-ast-visitor.h"
6+
#include "rust-scan.h"
67
#include "scope.h"
78

89
namespace Rust {
@@ -11,7 +12,7 @@ namespace Analysis {
1112
class TypeResolution : public AST::ASTVisitor
1213
{
1314
public:
14-
static bool ResolveNamesAndTypes (AST::Crate &crate);
15+
static bool ResolveNamesAndTypes (AST::Crate &crate, TopLevelScan &toplevel);
1516

1617
~TypeResolution ();
1718

@@ -221,7 +222,7 @@ class TypeResolution : public AST::ASTVisitor
221222
virtual void visit (AST::BareFunctionType &type);
222223

223224
private:
224-
TypeResolution (AST::Crate &crate);
225+
TypeResolution (AST::Crate &crate, TopLevelScan &toplevel);
225226

226227
bool go ();
227228

@@ -230,6 +231,7 @@ class TypeResolution : public AST::ASTVisitor
230231
Scope<AST::Type *> scope;
231232
Scope<AST::Type *> typeScope;
232233
AST::Crate &crate;
234+
TopLevelScan &toplevel;
233235

234236
std::vector<AST::IdentifierPattern> letPatternBuffer;
235237
std::vector<AST::Type *> typeBuffer;

0 commit comments

Comments
 (0)