summaryrefslogtreecommitdiff
path: root/cpp/src/Slice/Parser.cpp
diff options
context:
space:
mode:
authorMichi Henning <michi@zeroc.com>2002-07-16 09:41:39 +0000
committerMichi Henning <michi@zeroc.com>2002-07-16 09:41:39 +0000
commit963bf35c720a698dfea603c1bcfe81115aaa96d1 (patch)
treef578d5647e6972ee8e50dcedd11986f3f515da35 /cpp/src/Slice/Parser.cpp
parentAdded IceBox.Name configuration variable (diff)
downloadice-963bf35c720a698dfea603c1bcfe81115aaa96d1.tar.bz2
ice-963bf35c720a698dfea603c1bcfe81115aaa96d1.tar.xz
ice-963bf35c720a698dfea603c1bcfe81115aaa96d1.zip
Added sanity checks to make sure that the meaning of an identifier doesn't
change halfway through a scope. This all works now, except for operations because, currently, parameter lists are not in their own scope (but they have to be). Will add that tomorrow. Also want to improve diagnostics to show, if an identifier changes meaning, where it was introduced with different meaning.
Diffstat (limited to 'cpp/src/Slice/Parser.cpp')
-rw-r--r--cpp/src/Slice/Parser.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp
index a83d6d5a7d0..c6b70ebcc31 100644
--- a/cpp/src/Slice/Parser.cpp
+++ b/cpp/src/Slice/Parser.cpp
@@ -185,6 +185,12 @@ Slice::Contained::operator==(const Contained& rhs) const
return _scoped == rhs._scoped;
}
+bool
+Slice::Contained::operator!=(const Contained& rhs) const
+{
+ return _scoped != rhs._scoped;
+}
+
Slice::Contained::Contained(const ContainerPtr& container, const string& name) :
SyntaxTreeBase(container->unit()),
_container(container),
@@ -1237,6 +1243,48 @@ Slice::Container::containerRecDependencies(set<ConstructedPtr>& dependencies)
}
}
+bool
+Slice::Container::addIntroduced(const string& scoped, ContainedPtr namedThing)
+{
+ if(scoped[0] == ':') // Only unscoped names introduce anything
+ {
+ return true;
+ }
+
+ //
+ // Split off first component of scoped name
+ //
+ string::size_type pos = scoped.find("::");
+ string firstComponent = scoped.substr(0, pos);
+
+ //
+ // If we don't have type, use the Contained for the first component
+ //
+ if(namedThing == 0)
+ {
+ ContainedList cl = lookupContained(firstComponent, false);
+ if(cl.empty())
+ {
+ return true; // Ignore types whose creation failed previously
+ }
+ namedThing = cl.front();
+ }
+
+ //
+ // Check if we have the introduced name in the map already...
+ //
+ map<string, ContainedPtr>::const_iterator it = _introducedMap.find(firstComponent);
+ if(it == _introducedMap.end())
+ {
+ _introducedMap[firstComponent] = namedThing; // No, insert it
+ return true;
+ }
+ else
+ {
+ return it->second == namedThing; // Return whether it is the same as last time
+ }
+}
+
Slice::Container::Container(const UnitPtr& unit) :
SyntaxTreeBase(unit)
{