diff options
author | Benoit Foucher <benoit@zeroc.com> | 2009-03-24 11:45:18 +0100 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2009-03-24 11:45:18 +0100 |
commit | 06a08ecf28e205277336a97a6173db7ccbed1adc (patch) | |
tree | a369a5044a63f8cdba9e7c0a461e24ae344486b4 /cpp/src/Slice | |
parent | Merge branch 'R3_3_branch' (diff) | |
parent | Bug 3924: slice2py missing from VC60 installer (diff) | |
download | ice-06a08ecf28e205277336a97a6173db7ccbed1adc.tar.bz2 ice-06a08ecf28e205277336a97a6173db7ccbed1adc.tar.xz ice-06a08ecf28e205277336a97a6173db7ccbed1adc.zip |
Merge commit 'origin/R3_3_branch'
Conflicts:
CHANGES
cpp/demo/Freeze/backup/.depend
cpp/demo/Freeze/bench/.depend
cpp/demo/Freeze/casino/.depend
cpp/demo/Freeze/customEvictor/.depend
cpp/demo/Freeze/library/.depend
cpp/demo/Freeze/phonebook/.depend
cpp/demo/Freeze/transform/.depend
cpp/demo/Glacier2/callback/.depend
cpp/demo/Glacier2/chat/.depend
cpp/demo/Ice/async/.depend
cpp/demo/Ice/bidir/.depend
cpp/demo/Ice/callback/.depend
cpp/demo/Ice/converter/.depend
cpp/demo/Ice/hello/.depend
cpp/demo/Ice/invoke/.depend
cpp/demo/Ice/latency/.depend
cpp/demo/Ice/minimal/.depend
cpp/demo/Ice/multicast/.depend
cpp/demo/Ice/nested/.depend
cpp/demo/Ice/nrvo/.depend
cpp/demo/Ice/session/.depend
cpp/demo/Ice/throughput/.depend
cpp/demo/Ice/value/.depend
cpp/demo/IceBox/hello/.depend
cpp/demo/IceGrid/allocate/.depend
cpp/demo/IceGrid/icebox/.depend
cpp/demo/IceGrid/replication/.depend
cpp/demo/IceGrid/sessionActivation/.depend
cpp/demo/IceGrid/simple/.depend
cpp/demo/IceStorm/clock/.depend
cpp/demo/IceStorm/counter/.depend
cpp/demo/IceStorm/replicated/.depend
cpp/demo/IceStorm/replicated2/.depend
cpp/demo/book/freeze_filesystem/.depend
cpp/demo/book/lifecycle/.depend
cpp/demo/book/printer/.depend
cpp/demo/book/simple_filesystem/.depend
cpp/src/Freeze/.depend
cpp/src/FreezeScript/.depend
cpp/src/Ice/.depend
cpp/src/Ice/UdpTransceiver.cpp
cpp/src/Ice/UdpTransceiver.h
cpp/src/IceBox/.depend
cpp/src/IceGrid/.depend
cpp/src/IceGridLib/.depend
cpp/src/IcePatch2/.depend
cpp/src/IceStorm/.depend
cpp/src/slice2freeze/.depend
cpp/test/Freeze/complex/.depend
cpp/test/Freeze/dbmap/.depend
cpp/test/Freeze/evictor/.depend
cpp/test/Freeze/oldevictor/.depend
cpp/test/FreezeScript/dbmap/.depend
cpp/test/FreezeScript/evictor/.depend
cpp/test/Glacier2/attack/.depend
cpp/test/Glacier2/dynamicFiltering/.depend
cpp/test/Glacier2/router/.depend
cpp/test/Glacier2/sessionControl/.depend
cpp/test/Glacier2/ssl/.depend
cpp/test/Glacier2/staticFiltering/.depend
cpp/test/Ice/adapterDeactivation/.depend
cpp/test/Ice/background/.depend
cpp/test/Ice/binding/.depend
cpp/test/Ice/checksum/.depend
cpp/test/Ice/checksum/server/.depend
cpp/test/Ice/custom/.depend
cpp/test/Ice/exceptions/.depend
cpp/test/Ice/facets/.depend
cpp/test/Ice/faultTolerance/.depend
cpp/test/Ice/gc/.depend
cpp/test/Ice/hold/.depend
cpp/test/Ice/inheritance/.depend
cpp/test/Ice/interceptor/.depend
cpp/test/Ice/location/.depend
cpp/test/Ice/objects/.depend
cpp/test/Ice/operations/.depend
cpp/test/Ice/proxy/.depend
cpp/test/Ice/retry/.depend
cpp/test/Ice/servantLocator/.depend
cpp/test/Ice/slicing/exceptions/.depend
cpp/test/Ice/slicing/objects/.depend
cpp/test/Ice/stream/.depend
cpp/test/Ice/stringConverter/.depend
cpp/test/Ice/timeout/.depend
cpp/test/Ice/udp/.depend
cpp/test/IceBox/configuration/.depend
cpp/test/IceGrid/activation/.depend
cpp/test/IceGrid/allocation/.depend
cpp/test/IceGrid/deployer/.depend
cpp/test/IceGrid/distribution/.depend
cpp/test/IceGrid/replicaGroup/.depend
cpp/test/IceGrid/replication/.depend
cpp/test/IceGrid/session/.depend
cpp/test/IceGrid/simple/.depend
cpp/test/IceGrid/update/.depend
cpp/test/IceSSL/configuration/.depend
cpp/test/IceStorm/federation/.depend
cpp/test/IceStorm/federation2/.depend
cpp/test/IceStorm/rep1/.depend
cpp/test/IceStorm/repgrid/.depend
cpp/test/IceStorm/repstress/.depend
cpp/test/IceStorm/single/.depend
cpp/test/IceStorm/stress/.depend
cpp/test/Slice/keyword/.depend
cs/src/Ice/Instance.cs
cs/src/IceSSL/ConnectorI.cs
java/demo/book/simple_filesystem/Filesystem/DirectoryI.java
java/demo/book/simple_filesystem/Filesystem/FileI.java
java/src/IceInternal/TcpConnector.java
java/src/IceSSL/ConnectorI.java
py/modules/IcePy/.depend
rb/src/IceRuby/.depend
Diffstat (limited to 'cpp/src/Slice')
-rw-r--r-- | cpp/src/Slice/.depend | 7 | ||||
-rw-r--r-- | cpp/src/Slice/CPlusPlusUtil.cpp | 145 | ||||
-rw-r--r-- | cpp/src/Slice/CsUtil.cpp | 136 | ||||
-rw-r--r-- | cpp/src/Slice/FileTracker.cpp | 94 | ||||
-rw-r--r-- | cpp/src/Slice/Grammar.cpp | 1938 | ||||
-rw-r--r-- | cpp/src/Slice/Grammar.h | 33 | ||||
-rw-r--r-- | cpp/src/Slice/Grammar.y | 2 | ||||
-rw-r--r-- | cpp/src/Slice/JavaUtil.cpp | 388 | ||||
-rw-r--r-- | cpp/src/Slice/Makefile.mak | 4 | ||||
-rw-r--r-- | cpp/src/Slice/Parser.cpp | 85 | ||||
-rw-r--r-- | cpp/src/Slice/Preprocessor.cpp | 86 | ||||
-rw-r--r-- | cpp/src/Slice/PythonUtil.cpp | 229 | ||||
-rw-r--r-- | cpp/src/Slice/RubyUtil.cpp | 11 | ||||
-rw-r--r-- | cpp/src/Slice/Util.cpp | 167 |
14 files changed, 2226 insertions, 1099 deletions
diff --git a/cpp/src/Slice/.depend b/cpp/src/Slice/.depend index ee89ffd647f..158e40d9aa2 100644 --- a/cpp/src/Slice/.depend +++ b/cpp/src/Slice/.depend @@ -2,13 +2,14 @@ Scanner$(OBJEXT): Scanner.cpp $(includedir)/IceUtil/Config.h ../Slice/GrammarUti Grammar$(OBJEXT): ../Slice/Grammar.cpp ../Slice/GrammarUtil.h $(includedir)/Slice/Parser.h $(includedir)/IceUtil/Shared.h $(includedir)/IceUtil/Config.h $(includedir)/IceUtil/Handle.h $(includedir)/IceUtil/Exception.h $(includedir)/IceUtil/UUID.h Parser$(OBJEXT): Parser.cpp $(includedir)/IceUtil/Functional.h $(includedir)/IceUtil/Handle.h $(includedir)/IceUtil/Exception.h $(includedir)/IceUtil/Config.h $(includedir)/IceUtil/InputUtil.h $(includedir)/IceUtil/StringUtil.h $(includedir)/IceUtil/Unicode.h $(includedir)/Slice/Parser.h $(includedir)/IceUtil/Shared.h ../Slice/GrammarUtil.h $(includedir)/Slice/Util.h CPlusPlusUtil$(OBJEXT): CPlusPlusUtil.cpp $(includedir)/Slice/CPlusPlusUtil.h $(includedir)/Slice/Parser.h $(includedir)/IceUtil/Shared.h $(includedir)/IceUtil/Config.h $(includedir)/IceUtil/Handle.h $(includedir)/IceUtil/Exception.h $(includedir)/IceUtil/OutputUtil.h $(includedir)/Slice/Util.h -CsUtil$(OBJEXT): CsUtil.cpp $(includedir)/Slice/CsUtil.h $(includedir)/Slice/Parser.h $(includedir)/IceUtil/Shared.h $(includedir)/IceUtil/Config.h $(includedir)/IceUtil/Handle.h $(includedir)/IceUtil/Exception.h $(includedir)/IceUtil/OutputUtil.h $(includedir)/Slice/DotNetNames.h $(includedir)/IceUtil/Functional.h -JavaUtil$(OBJEXT): JavaUtil.cpp $(includedir)/Slice/JavaUtil.h $(includedir)/Slice/Parser.h $(includedir)/IceUtil/Shared.h $(includedir)/IceUtil/Config.h $(includedir)/IceUtil/Handle.h $(includedir)/IceUtil/Exception.h $(includedir)/IceUtil/OutputUtil.h $(includedir)/IceUtil/Functional.h +CsUtil$(OBJEXT): CsUtil.cpp $(includedir)/Slice/CsUtil.h $(includedir)/Slice/Parser.h $(includedir)/IceUtil/Shared.h $(includedir)/IceUtil/Config.h $(includedir)/IceUtil/Handle.h $(includedir)/IceUtil/Exception.h $(includedir)/IceUtil/OutputUtil.h $(includedir)/Slice/DotNetNames.h $(includedir)/Slice/Util.h $(includedir)/IceUtil/Functional.h +JavaUtil$(OBJEXT): JavaUtil.cpp $(includedir)/IceUtil/DisableWarnings.h $(includedir)/Slice/JavaUtil.h $(includedir)/Slice/Parser.h $(includedir)/IceUtil/Shared.h $(includedir)/IceUtil/Config.h $(includedir)/IceUtil/Handle.h $(includedir)/IceUtil/Exception.h $(includedir)/IceUtil/OutputUtil.h $(includedir)/Slice/FileTracker.h $(includedir)/Slice/Util.h $(includedir)/IceUtil/Functional.h Preprocessor$(OBJEXT): Preprocessor.cpp $(includedir)/IceUtil/DisableWarnings.h $(includedir)/Slice/Preprocessor.h $(includedir)/IceUtil/Config.h $(includedir)/Slice/Util.h $(includedir)/Slice/Parser.h $(includedir)/IceUtil/Shared.h $(includedir)/IceUtil/Handle.h $(includedir)/IceUtil/Exception.h $(includedir)/IceUtil/StringUtil.h $(includedir)/IceUtil/FileUtil.h $(includedir)/IceUtil/UUID.h $(includedir)/IceUtil/Unicode.h Checksum$(OBJEXT): Checksum.cpp $(includedir)/Slice/Checksum.h $(includedir)/Slice/Parser.h $(includedir)/IceUtil/Shared.h $(includedir)/IceUtil/Config.h $(includedir)/IceUtil/Handle.h $(includedir)/IceUtil/Exception.h ../Slice/MD5.h PythonUtil$(OBJEXT): PythonUtil.cpp $(includedir)/Slice/PythonUtil.h $(includedir)/Slice/Parser.h $(includedir)/IceUtil/Shared.h $(includedir)/IceUtil/Config.h $(includedir)/IceUtil/Handle.h $(includedir)/IceUtil/Exception.h $(includedir)/IceUtil/OutputUtil.h $(includedir)/Slice/Checksum.h $(includedir)/Slice/Util.h $(includedir)/IceUtil/IceUtil.h $(includedir)/IceUtil/AbstractMutex.h $(includedir)/IceUtil/Lock.h $(includedir)/IceUtil/ThreadException.h $(includedir)/IceUtil/Time.h $(includedir)/IceUtil/Cache.h $(includedir)/IceUtil/Mutex.h $(includedir)/IceUtil/CountDownLatch.h $(includedir)/IceUtil/Cond.h $(includedir)/IceUtil/CtrlCHandler.h $(includedir)/IceUtil/Functional.h $(includedir)/IceUtil/Monitor.h $(includedir)/IceUtil/RWRecMutex.h $(includedir)/IceUtil/Thread.h $(includedir)/IceUtil/RecMutex.h $(includedir)/IceUtil/StaticMutex.h $(includedir)/IceUtil/Timer.h $(includedir)/IceUtil/UUID.h $(includedir)/IceUtil/Unicode.h $(includedir)/IceUtil/StringUtil.h $(includedir)/IceUtil/InputUtil.h DotNetNames$(OBJEXT): DotNetNames.cpp $(includedir)/Slice/DotNetNames.h RubyUtil$(OBJEXT): RubyUtil.cpp $(includedir)/Slice/RubyUtil.h $(includedir)/Slice/Parser.h $(includedir)/IceUtil/Shared.h $(includedir)/IceUtil/Config.h $(includedir)/IceUtil/Handle.h $(includedir)/IceUtil/Exception.h $(includedir)/IceUtil/OutputUtil.h $(includedir)/Slice/Checksum.h $(includedir)/Slice/Util.h $(includedir)/IceUtil/Functional.h $(includedir)/IceUtil/InputUtil.h -Util$(OBJEXT): Util.cpp $(includedir)/Slice/Util.h $(includedir)/Slice/Parser.h $(includedir)/IceUtil/Shared.h $(includedir)/IceUtil/Config.h $(includedir)/IceUtil/Handle.h $(includedir)/IceUtil/Exception.h $(includedir)/IceUtil/Unicode.h $(includedir)/IceUtil/FileUtil.h +Util$(OBJEXT): Util.cpp $(includedir)/Slice/Util.h $(includedir)/Slice/Parser.h $(includedir)/IceUtil/Shared.h $(includedir)/IceUtil/Config.h $(includedir)/IceUtil/Handle.h $(includedir)/IceUtil/Exception.h $(includedir)/IceUtil/Unicode.h $(includedir)/IceUtil/FileUtil.h $(includedir)/IceUtil/StringUtil.h +FileTracker$(OBJEXT): FileTracker.cpp $(includedir)/Slice/FileTracker.h $(includedir)/IceUtil/Shared.h $(includedir)/IceUtil/Config.h $(includedir)/Slice/Parser.h $(includedir)/IceUtil/Handle.h $(includedir)/IceUtil/Exception.h MD5$(OBJEXT): MD5.cpp ../Slice/MD5.h $(includedir)/IceUtil/Config.h ../Slice/MD5I.h MD5I$(OBJEXT): MD5I.cpp ../Slice/MD5I.h diff --git a/cpp/src/Slice/CPlusPlusUtil.cpp b/cpp/src/Slice/CPlusPlusUtil.cpp index 6997b9b436c..507faac36dc 100644 --- a/cpp/src/Slice/CPlusPlusUtil.cpp +++ b/cpp/src/Slice/CPlusPlusUtil.cpp @@ -59,7 +59,8 @@ Slice::printVersionCheck(Output& out) { out << "\n"; out << "\n#ifndef ICE_IGNORE_VERSION"; - if(ICE_INT_VERSION % 100 > 50) + int iceVersion = ICE_INT_VERSION; // Use this to prevent warning with C++Builder + if(iceVersion % 100 > 50) { // // Beta version: exact match required @@ -215,6 +216,13 @@ Slice::typeToString(const TypePtr& type, bool useWstring, const StringList& meta } else { + // Get the metadata associated at the point of definition. + bool protobuf; + seqType = findMetaData(seq, seq->getMetaData(), true, protobuf); + if(protobuf && !seqType.empty()) + { + return seqType; + } return fixKwd(seq->scoped()); } } @@ -348,6 +356,13 @@ Slice::inputTypeToString(const TypePtr& type, bool useWstring, const StringList& } else { + // Get the metadata associated at the point of definition. + bool protobuf; + seqType = findMetaData(seq, seq->getMetaData(), true, protobuf); + if(protobuf && !seqType.empty()) + { + return "const " + seqType + "&"; + } return "const " + fixKwd(seq->scoped()) + "&"; } } @@ -432,6 +447,12 @@ Slice::outputTypeToString(const TypePtr& type, bool useWstring, const StringList } else { + bool protobuf; + seqType = findMetaData(seq, seq->getMetaData(), true, protobuf); + if(protobuf && !seqType.empty()) + { + return seqType + "&"; + } return fixKwd(seq->scoped()) + "&"; } } @@ -679,6 +700,7 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string& if(marshal) { string scope = fixKwd(seq->scope()); + if(seqType == "array" || seqType == "range:array") { // @@ -758,11 +780,13 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string& else { // - // No modifying metadata specified. Use appropriate write methods for type. + // No modifying metadata specified. Use appropriate + // write methods for type. // StringList l = seq->getMetaData(); - seqType = findMetaData(l, false); - if(!seqType.empty()) + bool protobuf; + seqType = findMetaData(seq, l, false, protobuf); + if(protobuf || !seqType.empty()) { out << nl << scope << "__" << funcSeq << (pointer ? "" : "&") << stream << ", " << fixedParam << ");"; @@ -911,12 +935,14 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string& else { // - // No modifying metadata supplied. Just use appropriate read function. + // No modifying metadata supplied. Just use + // appropriate read function. // StringList l = seq->getMetaData(); - seqType = findMetaData(l, false); - if(!seqType.empty() || !builtin || builtin->kind() == Builtin::KindObject || - builtin->kind() == Builtin::KindObjectProxy) + bool protobuf; + seqType = findMetaData(seq, l, false, protobuf); + if(protobuf || !seqType.empty() || !builtin || builtin->kind() == Builtin::KindObject || + builtin->kind() == Builtin::KindObjectProxy) { out << nl << scope << "__" << funcSeq << (pointer ? "" : "&") << stream << ", " << fixedParam << ");"; @@ -1019,8 +1045,13 @@ writeRangeAllocateCode(Output& out, const TypePtr& type, const string& fixedName SequencePtr seq = SequencePtr::dynamicCast(type); if(seq) { - string seqType = findMetaData(metaData, true); - if(seqType.find("range") == 0 && seqType != "range:array") + bool protobuf; + string seqType = findMetaData(seq, metaData, true, protobuf); + if(!protobuf && seqType.empty()) + { + seqType = findMetaData(seq, seq->getMetaData(), true, protobuf); + } + if(!protobuf && seqType.find("range") == 0 && seqType != "range:array") { StringList md; if(seqType.find("range:") == 0) @@ -1305,9 +1336,10 @@ Slice::writeStreamMarshalUnmarshalCode(Output& out, const TypePtr& type, const s } else { - seqType = findMetaData(seq->getMetaData(), false); + bool protobuf; + seqType = findMetaData(seq, seq->getMetaData(), false, protobuf); builtin = BuiltinPtr::dynamicCast(seq->type()); - if(!seqType.empty() || !builtin || (builtin->kind() == Builtin::KindObject || + if(protobuf || !seqType.empty() || !builtin || (builtin->kind() == Builtin::KindObject || builtin->kind() == Builtin::KindObjectProxy)) { string scope = fixKwd(seq->scope()); @@ -1501,6 +1533,95 @@ Slice::writeStreamMarshalUnmarshalCode(Output& out, const TypePtr& type, const s assert(false); } +// Accepted metadata. +// +// cpp:type:<typename> +// cpp:const +// cpp:array +// cpp:range:<typename> +// cpp:protobuf<:typename> +// + +// This form is for sequences definitions only. +string +Slice::findMetaData(const SequencePtr& seq, const StringList& metaData, bool inParam, bool& isProtobuf) +{ + isProtobuf = false; + static const string prefix = "cpp:"; + for(StringList::const_iterator q = metaData.begin(); q != metaData.end(); ++q) + { + string str = *q; + if(str.find(prefix) == 0) + { + string::size_type pos = str.find(':', prefix.size()); + string ss; + if(pos == string::npos) + { + ss = str.substr(prefix.size()); + } + else + { + ss = str.substr(prefix.size(), pos - prefix.size()); + } + // + // If the form is cpp:type:<...> the data after cpp:type: + // is returned. If the form is cpp:range:<...> (and this + // is an inParam) the data after cpp: is returned. + // + if(ss == "protobuf" || pos != string::npos) + { + string ss = str.substr(prefix.size(), pos - prefix.size()); + if(ss == "type") + { + return str.substr(pos + 1); + } + else if(ss == "protobuf") + { + BuiltinPtr builtin = BuiltinPtr::dynamicCast(seq->type()); + if(!builtin || builtin->kind() != Builtin::KindByte) + { + continue; + } + isProtobuf = true; + if(pos != string::npos) + { + return str.substr(pos + 1); + } + return ""; + } + else if(inParam && ss == "range") + { + return str.substr(prefix.size()); + } + } + // + // If the data is an inParam and the metadata is cpp:array + // or cpp:range then array or range is returned. + // + else if(inParam) + { + if(ss == "array" || ss == "range") + { + return ss; + } + } + // + // Otherwise if the data is "class" it is returned. + // + else + { + if(ss == "class") + { + return ss; + } + } + } + } + + return ""; +} + +// Does not handle cpp:protobuf string Slice::findMetaData(const StringList& metaData, bool inParam) { diff --git a/cpp/src/Slice/CsUtil.cpp b/cpp/src/Slice/CsUtil.cpp index ae8c6e667cc..2f656872638 100644 --- a/cpp/src/Slice/CsUtil.cpp +++ b/cpp/src/Slice/CsUtil.cpp @@ -9,6 +9,7 @@ #include <Slice/CsUtil.h> #include <Slice/DotNetNames.h> +#include <Slice/Util.h> #include <IceUtil/Functional.h> #include <sys/types.h> @@ -213,6 +214,13 @@ Slice::CsGenerator::typeToString(const TypePtr& type) } } + prefix = "clr:serializable:"; + if(seq->findMetaData(prefix, meta)) + { + string type = meta.substr(prefix.size()); + return global() + type; + } + return typeToString(seq->type()) + "[]"; } @@ -887,6 +895,21 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, } default: { + string prefix = "clr:serializable:"; + string meta; + if(seq->findMetaData(prefix, meta)) + { + if(marshal) + { + out << nl << stream << ".writeSerializable(" << param << ");"; + } + else + { + out << nl << param << " = (" << typeToString(seq) << ")" << stream << ".readSerializable();"; + } + break; + } + typeS[0] = toupper(static_cast<unsigned char>(typeS[0])); if(marshal) { @@ -1500,42 +1523,52 @@ Slice::CsGenerator::validateMetaData(const UnitPtr& u) u->visit(&visitor, true); } -Slice::CsGenerator::MetaDataVisitor::MetaDataVisitor() - : _globalMetaDataDone(false) -{ -} - bool -Slice::CsGenerator::MetaDataVisitor::visitModuleStart(const ModulePtr& p) +Slice::CsGenerator::MetaDataVisitor::visitUnitStart(const UnitPtr& p) { - if(!_globalMetaDataDone) + // + // Validate global metadata in the top-level file and all included files. + // + StringList files = p->allFiles(); + + for(StringList::iterator q = files.begin(); q != files.end(); ++q) { - // - // Validate global metadata. - // - DefinitionContextPtr dc = p->definitionContext(); + string file = *q; + DefinitionContextPtr dc = p->findDefinitionContext(file); assert(dc); StringList globalMetaData = dc->getMetaData(); - string file = dc->filename(); - static const string prefix = "cs:"; - for(StringList::const_iterator q = globalMetaData.begin(); q != globalMetaData.end(); ++q) + + static const string csPrefix = "cs:"; + static const string clrPrefix = "clr:"; + for(StringList::const_iterator r = globalMetaData.begin(); r != globalMetaData.end(); ++r) { - string s = *q; + string s = *r; if(_history.count(s) == 0) { - if(s.find(prefix) == 0) + if(s.find(csPrefix) == 0) { - static const string attributePrefix = "cs:attribute:"; - if(s.find(attributePrefix) != 0 || s.size() == attributePrefix.size()) + static const string csAttributePrefix = csPrefix + "attribute:"; + if(s.find(csAttributePrefix) == 0 && s.size() > csAttributePrefix.size()) { - cerr << file << ": warning: ignoring invalid global metadata `" << s << "'" << endl; + continue; } + emitWarning(file, -1, "ignoring invalid global metadata `" + s + "'"); + _history.insert(s); + } + else if(s.find(clrPrefix) == 0) + { + emitWarning(file, -1, "ignoring invalid global metadata `" + s + "'"); + _history.insert(s); } - _history.insert(s); } } - _globalMetaDataDone = true; } + return true; +} + +bool +Slice::CsGenerator::MetaDataVisitor::visitModuleStart(const ModulePtr& p) +{ validate(p); return true; } @@ -1595,13 +1628,20 @@ Slice::CsGenerator::MetaDataVisitor::visitOperation(const OperationPtr& p) ClassDefPtr cl = ClassDefPtr::dynamicCast(p->container()); if(!cl->isLocal()) { - cerr << p->definitionContext()->filename() << ":" << p->line() - << ": warning: metdata directive `UserException' applies only to local operations " - << "but enclosing " << (cl->isInterface() ? "interface" : "class") << "`" << cl->name() - << "' is not local" << endl; + ostringstream os; + os << "ignoring invalid metadata `UserException': directive applies only to local operations " + << "but enclosing " << (cl->isInterface() ? "interface" : "class") << "`" << cl->name() + << "' is not local"; + emitWarning(p->file(), p->line(), os.str()); } } validate(p); + + ParamDeclList params = p->parameters(); + for(ParamDeclList::const_iterator i = params.begin(); i != params.end(); ++i) + { + visitParamDecl(*i); + } } void @@ -1645,15 +1685,9 @@ Slice::CsGenerator::MetaDataVisitor::validate(const ContainedPtr& cont) { const string msg = "ignoring invalid metadata"; - DefinitionContextPtr dc = cont->definitionContext(); - assert(dc); - string file = dc->filename(); - StringList localMetaData = cont->getMetaData(); - StringList::const_iterator p; - - for(p = localMetaData.begin(); p != localMetaData.end(); ++p) + for(StringList::const_iterator p = localMetaData.begin(); p != localMetaData.end(); ++p) { string s = *p; @@ -1669,9 +1703,10 @@ Slice::CsGenerator::MetaDataVisitor::validate(const ContainedPtr& cont) { continue; } - if(s.substr(prefix.size(), 8) == "generic:") + static const string clrGenericPrefix = prefix + "generic:"; + if(s.find(clrGenericPrefix) == 0) { - string type = s.substr(prefix.size() + 8); + string type = s.substr(clrGenericPrefix.size()); if(type == "LinkedList" || type == "Queue" || type == "Stack") { ClassDeclPtr cd = ClassDeclPtr::dynamicCast(seq->type()); @@ -1686,6 +1721,23 @@ Slice::CsGenerator::MetaDataVisitor::validate(const ContainedPtr& cont) continue; // Custom type or List<T> } } + static const string clrSerializablePrefix = prefix + "serializable:"; + if(s.find(clrSerializablePrefix) == 0) + { + string meta; + if(cont->findMetaData(prefix + "collection", meta) + || cont->findMetaData(prefix + "generic:", meta)) + { + emitWarning(cont->file(), cont->line(), msg + " `" + meta + "':\n" + + "serialization can only be used with the array mapping for byte sequences"); + } + string type = s.substr(clrSerializablePrefix.size()); + BuiltinPtr builtin = BuiltinPtr::dynamicCast(seq->type()); + if(!type.empty() && builtin && builtin->kind() == Builtin::KindByte) + { + continue; + } + } } else if(StructPtr::dynamicCast(cont)) { @@ -1711,18 +1763,19 @@ Slice::CsGenerator::MetaDataVisitor::validate(const ContainedPtr& cont) { continue; } - if(s.substr(prefix.size(), 8) == "generic:") + static const string clrGenericPrefix = prefix + "generic:"; + if(s.find(clrGenericPrefix) == 0) { - string type = s.substr(prefix.size() + 8); + string type = s.substr(clrGenericPrefix.size()); if(type == "SortedDictionary" || type == "SortedList") { continue; } } } - cerr << file << ":" << cont->line() << ": warning: " << msg << " `" << s << "'" << endl; + emitWarning(cont->file(), cont->line(), msg + " `" + s + "'"); + _history.insert(s); } - _history.insert(s); } prefix = "cs:"; @@ -1730,13 +1783,14 @@ Slice::CsGenerator::MetaDataVisitor::validate(const ContainedPtr& cont) { if(s.find(prefix) == 0) { - if(s.substr(prefix.size()) == "attribute:") + static const string csAttributePrefix = prefix + "attribute:"; + if(s.find(csAttributePrefix) == 0 && s.size() > csAttributePrefix.size()) { continue; } - cerr << file << ":" << cont->line() << ": warning: " << msg << " `" << s << "'" << endl; + emitWarning(cont->file(), cont->line(), msg + " `" + s + "'"); + _history.insert(s); } - _history.insert(s); } } } diff --git a/cpp/src/Slice/FileTracker.cpp b/cpp/src/Slice/FileTracker.cpp index 43d9632ad17..2d4ce2293e4 100644 --- a/cpp/src/Slice/FileTracker.cpp +++ b/cpp/src/Slice/FileTracker.cpp @@ -9,6 +9,10 @@ #include <Slice/FileTracker.h> +#ifdef __sun +# include <unistd.h> +#endif + #ifdef _WIN32 # include <direct.h> #endif @@ -36,7 +40,11 @@ Slice::FileException::ice_name() const void Slice::FileException::ice_print(ostream& out) const { +#if defined(_MSC_VER) && (_MSC_VER < 1300) + Exception::ice_print(out); +#else IceUtil::Exception::ice_print(out); +#endif out << ": " << _reason; } @@ -61,7 +69,8 @@ Slice::FileException::reason() const static Slice::FileTrackerPtr Instance; -Slice::FileTracker::FileTracker() +Slice::FileTracker::FileTracker() : + _curr(_generated.end()) { } @@ -81,9 +90,33 @@ Slice::FileTracker::instance() } void +Slice::FileTracker::setSource(const string& source) +{ + _source = source; + pair<map<string, list<string> >::iterator, bool> p = _generated.insert(make_pair(source, list<string>())); + assert(p.second); + _curr = p.first; +} + +void +Slice::FileTracker::setOutput(const string& output, bool error) +{ + assert(!_source.empty()); + _errors.insert(make_pair(_source, output)); + if(error) + { + _curr = _generated.end(); + } +} + +void Slice::FileTracker::addFile(const string& file) { _files.push_front(make_pair(file, false)); + if(_curr != _generated.end()) + { + _curr->second.push_back(file); + } } void @@ -115,3 +148,62 @@ Slice::FileTracker::cleanup() } } } + +void +Slice::FileTracker::dumpxml() +{ + cout << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl; + + cout << "<generated>" << endl; + for(map<string, string>::const_iterator p = _errors.begin(); p != _errors.end(); ++p) + { + cout << " <source name=\"" << p->first << "\""; + + map<string, list<string> >::const_iterator q = _generated.find(p->first); + if(q == _generated.end()) + { + cout << " error=\"true\">" << endl; + } + else + { + cout << ">" << endl; + for(list<string>::const_iterator r = q->second.begin(); r != q->second.end(); ++r) + { + cout << " <file name=\"" << *r << "\"/>" << endl; + } + } + cout << " <output>" << escape(p->second) << "</output>" << endl; + cout << " </source>" << endl; + } + cout << "</generated>" << endl; +} + +string +Slice::FileTracker::escape(const string& str) const +{ + ostringstream ostr; + + for(string::const_iterator p = str.begin(); p != str.end(); ++p) + { + switch(*p) + { + case '<': + ostr << "<"; + break; + case '>': + ostr << ">"; + break; + case '&': + ostr << "&"; + break; + case '"': + ostr << """; + break; + default: + ostr << *p; + break; + } + } + + return ostr.str(); +} diff --git a/cpp/src/Slice/Grammar.cpp b/cpp/src/Slice/Grammar.cpp index 9d94b2eae25..ae2b63f51c1 100644 --- a/cpp/src/Slice/Grammar.cpp +++ b/cpp/src/Slice/Grammar.cpp @@ -1,7 +1,9 @@ -/* A Bison parser, made by GNU Bison 1.875c. */ +/* A Bison parser, made by GNU Bison 2.3. */ -/* Skeleton parser for Yacc-like parsing with Bison, - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -15,16 +17,24 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ -/* Written by Richard Stallman by simplifying the original so called - ``semantic'' parser. */ +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ /* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local @@ -36,6 +46,9 @@ /* Identify Bison output. */ #define YYBISON 1 +/* Bison version. */ +#define YYBISON_VERSION "2.3" + /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -45,8 +58,7 @@ /* Using locations. */ #define YYLSP_NEEDED 0 -/* If NAME_PREFIX is specified substitute the variables and functions - names. */ +/* Substitute the variable and function names. */ #define yyparse slice_parse #define yylex slice_lex #define yyerror slice_error @@ -105,6 +117,7 @@ BAD_CHAR = 298 }; #endif +/* Tokens. */ #define ICE_MODULE 258 #define ICE_CLASS 259 #define ICE_INTERFACE 260 @@ -151,7 +164,7 @@ /* Copy the first part of user declarations. */ -#line 1 "../Slice/Grammar.y" +#line 1 "Grammar.y" // ********************************************************************** @@ -209,7 +222,12 @@ slice_error(const char* s) # define YYERROR_VERBOSE 0 #endif -#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef int YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 @@ -221,56 +239,171 @@ typedef int YYSTYPE; /* Copy the second part of user declarations. */ -/* Line 214 of yacc.c. */ -#line 226 "Grammar.tab.c" +/* Line 216 of yacc.c. */ +#line 244 "Grammar.tab.c" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif -#if ! defined (yyoverflow) || YYERROR_VERBOSE +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif -# ifndef YYFREE -# define YYFREE free +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include <stddef.h> /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int # endif -# ifndef YYMALLOC -# define YYMALLOC malloc +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if YYENABLE_NLS +# if ENABLE_NLS +# include <libintl.h> /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid # endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ # ifdef YYSTACK_USE_ALLOCA # if YYSTACK_USE_ALLOCA -# define YYSTACK_ALLOC alloca -# endif -# else -# if defined (alloca) || defined (_ALLOCA_H) -# define YYSTACK_ALLOC alloca -# else # ifdef __GNUC__ # define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include <alloca.h> /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include <malloc.h> /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif # endif # endif # endif # ifdef YYSTACK_ALLOC - /* Pacify GCC's `empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) -# else -# if defined (__STDC__) || defined (__cplusplus) -# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ # endif +# else # define YYSTACK_ALLOC YYMALLOC # define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif # endif -#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ -#if (! defined (yyoverflow) \ - && (! defined (__cplusplus) \ - || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc { - short yyss; + yytype_int16 yyss; YYSTYPE yyvs; }; @@ -280,24 +413,24 @@ union yyalloc /* The size of an array large to enough to hold all stacks, each with N elements. */ # define YYSTACK_BYTES(N) \ - ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) /* Copy COUNT objects from FROM to TO. The source and destination do not overlap. */ # ifndef YYCOPY -# if defined (__GNUC__) && 1 < __GNUC__ +# if defined __GNUC__ && 1 < __GNUC__ # define YYCOPY(To, From, Count) \ __builtin_memcpy (To, From, (Count) * sizeof (*(From))) # else # define YYCOPY(To, From, Count) \ do \ { \ - register YYSIZE_T yyi; \ + YYSIZE_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (To)[yyi] = (From)[yyi]; \ } \ - while (0) + while (YYID (0)) # endif # endif @@ -315,39 +448,33 @@ union yyalloc yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ - while (0) + while (YYID (0)) #endif -#if defined (__STDC__) || defined (__cplusplus) - typedef signed char yysigned_char; -#else - typedef short yysigned_char; -#endif - -/* YYFINAL -- State number of the termination state. */ +/* YYFINAL -- State number of the termination state. */ #define YYFINAL 13 /* YYLAST -- Last index in YYTABLE. */ #define YYLAST 775 -/* YYNTOKENS -- Number of terminals. */ +/* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 53 -/* YYNNTS -- Number of nonterminals. */ +/* YYNNTS -- Number of nonterminals. */ #define YYNNTS 67 -/* YYNRULES -- Number of rules. */ +/* YYNRULES -- Number of rules. */ #define YYNRULES 184 -/* YYNRULES -- Number of states. */ +/* YYNRULES -- Number of states. */ #define YYNSTATES 269 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 298 -#define YYTRANSLATE(YYX) \ +#define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ -static const unsigned char yytranslate[] = +static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -384,7 +511,7 @@ static const unsigned char yytranslate[] = #if YYDEBUG /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in YYRHS. */ -static const unsigned short yyprhs[] = +static const yytype_uint16 yyprhs[] = { 0, 0, 3, 5, 9, 13, 14, 15, 19, 20, 26, 27, 32, 35, 36, 38, 40, 42, 44, 46, @@ -407,8 +534,8 @@ static const unsigned short yyprhs[] = 521, 523, 525, 527, 529 }; -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ -static const yysigned_char yyrhs[] = +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = { 54, 0, -1, 57, -1, 41, 115, 42, -1, 39, 115, 40, -1, -1, -1, 55, 58, 57, -1, -1, @@ -467,11 +594,11 @@ static const yysigned_char yyrhs[] = }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const unsigned short yyrline[] = +static const yytype_uint16 yyrline[] = { 0, 105, 105, 113, 122, 127, 136, 135, 145, 144, - 156, 155, 160, 165, 172, 176, 180, 184, 188, 192, - 196, 200, 204, 208, 212, 216, 220, 230, 229, 262, + 155, 154, 159, 164, 171, 175, 179, 183, 187, 191, + 195, 199, 203, 207, 211, 215, 219, 229, 228, 262, 266, 277, 288, 287, 314, 323, 331, 340, 343, 348, 355, 368, 374, 378, 389, 400, 399, 435, 444, 447, 452, 459, 465, 469, 480, 494, 493, 533, 568, 576, @@ -491,9 +618,9 @@ static const unsigned short yyrline[] = }; #endif -#if YYDEBUG || YYERROR_VERBOSE -/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { "$end", "error", "$undefined", "ICE_MODULE", "ICE_CLASS", @@ -528,7 +655,7 @@ static const char *const yytname[] = # ifdef YYPRINT /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to token YYLEX-NUM. */ -static const unsigned short yytoknum[] = +static const yytype_uint16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, @@ -540,7 +667,7 @@ static const unsigned short yytoknum[] = # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const unsigned char yyr1[] = +static const yytype_uint8 yyr1[] = { 0, 53, 54, 55, 56, 56, 58, 57, 59, 57, 60, 57, 57, 57, 61, 61, 61, 61, 61, 61, @@ -564,7 +691,7 @@ static const unsigned char yyr1[] = }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const unsigned char yyr2[] = +static const yytype_uint8 yyr2[] = { 0, 2, 1, 3, 3, 0, 0, 3, 0, 5, 0, 4, 2, 0, 1, 1, 1, 1, 1, 1, @@ -590,7 +717,7 @@ static const unsigned char yyr2[] = /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state STATE-NUM when YYTABLE doesn't specify something else to do. Zero means the default is an error. */ -static const unsigned char yydefact[] = +static const yytype_uint8 yydefact[] = { 0, 0, 0, 0, 0, 6, 147, 2, 10, 143, 145, 0, 0, 1, 0, 0, 146, 5, 12, 14, @@ -621,8 +748,8 @@ static const unsigned char yydefact[] = 124, 98, 99, 100, 119, 123, 0, 121, 97 }; -/* YYDEFGOTO[NTERM-NUM]. */ -static const short yydefgoto[] = +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int16 yydefgoto[] = { -1, 4, 5, 6, 7, 14, 41, 33, 18, 19, 56, 49, 20, 21, 137, 115, 177, 179, 194, 50, @@ -636,7 +763,7 @@ static const short yydefgoto[] = /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ #define YYPACT_NINF -192 -static const short yypact[] = +static const yytype_int16 yypact[] = { 400, -26, -9, -9, 27, -192, 62, -192, -192, -9, -192, 18, 20, -192, 77, 30, -192, 35, 58, -192, @@ -668,7 +795,7 @@ static const short yypact[] = }; /* YYPGOTO[NTERM-NUM]. */ -static const short yypgoto[] = +static const yytype_int16 yypgoto[] = { -192, -192, -192, -17, -7, -192, -192, -192, -192, -192, -192, -192, -192, -192, -192, -192, -179, -186, -192, -192, @@ -684,7 +811,7 @@ static const short yypgoto[] = number is the opposite. If zero, do what YYDEFACT says. If YYTABLE_NINF, syntax error. */ #define YYTABLE_NINF -118 -static const short yytable[] = +static const yytype_int16 yytable[] = { 40, 114, 102, 104, 106, 108, 136, 38, 113, 139, 70, 144, 195, 224, 215, 197, 165, 125, 8, 169, @@ -766,7 +893,7 @@ static const short yytable[] = 0, 0, 0, 0, 67, 68 }; -static const short yycheck[] = +static const yytype_int16 yycheck[] = { 17, 12, 42, 43, 44, 45, 114, 14, 48, 117, 40, 119, 176, 204, 193, 178, 140, 32, 44, 146, @@ -850,7 +977,7 @@ static const short yycheck[] = /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ -static const unsigned char yystos[] = +static const yytype_uint8 yystos[] = { 0, 1, 39, 41, 54, 55, 56, 57, 44, 34, 114, 115, 115, 0, 58, 3, 26, 27, 61, 62, @@ -881,22 +1008,6 @@ static const unsigned char yystos[] = 100, 101, 112, 119, 70, 113, 48, 119, 100 }; -#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) -# define YYSIZE_T __SIZE_TYPE__ -#endif -#if ! defined (YYSIZE_T) && defined (size_t) -# define YYSIZE_T size_t -#endif -#if ! defined (YYSIZE_T) -# if defined (__STDC__) || defined (__cplusplus) -# include <stddef.h> /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# endif -#endif -#if ! defined (YYSIZE_T) -# define YYSIZE_T unsigned int -#endif - #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) #define YYEMPTY (-2) @@ -922,30 +1033,63 @@ do \ yychar = (Token); \ yylval = (Value); \ yytoken = YYTRANSLATE (yychar); \ - YYPOPSTACK; \ + YYPOPSTACK (1); \ goto yybackup; \ } \ else \ - { \ - yyerror ("syntax error: cannot back up");\ + { \ + yyerror (YY_("syntax error: cannot back up")); \ YYERROR; \ } \ -while (0) +while (YYID (0)) + #define YYTERROR 1 #define YYERRCODE 256 -/* YYLLOC_DEFAULT -- Compute the default location (before the actions - are run). */ +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) #ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - ((Current).first_line = (Rhs)[1].first_line, \ - (Current).first_column = (Rhs)[1].first_column, \ - (Current).last_line = (Rhs)[N].last_line, \ - (Current).last_column = (Rhs)[N].last_column) +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) #endif + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + /* YYLEX -- calling `yylex' with the right arguments. */ #ifdef YYLEX_PARAM @@ -966,42 +1110,96 @@ while (0) do { \ if (yydebug) \ YYFPRINTF Args; \ -} while (0) +} while (YYID (0)) -# define YYDSYMPRINT(Args) \ -do { \ - if (yydebug) \ - yysymprint Args; \ -} while (0) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) -# define YYDSYMPRINTF(Title, Token, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yysymprint (stderr, \ - Token, Value); \ - YYFPRINTF (stderr, "\n"); \ - } \ -} while (0) + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; +#endif +{ + if (!yyvaluep) + return; +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep); + YYFPRINTF (yyoutput, ")"); +} /*------------------------------------------------------------------. | yy_stack_print -- Print the state stack from its BOTTOM up to its | | TOP (included). | `------------------------------------------------------------------*/ -#if defined (__STDC__) || defined (__cplusplus) +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static void -yy_stack_print (short *bottom, short *top) +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) #else static void yy_stack_print (bottom, top) - short *bottom; - short *top; + yytype_int16 *bottom; + yytype_int16 *top; #endif { YYFPRINTF (stderr, "Stack now"); - for (/* Nothing. */; bottom <= top; ++bottom) + for (; bottom <= top; ++bottom) YYFPRINTF (stderr, " %d", *bottom); YYFPRINTF (stderr, "\n"); } @@ -1010,45 +1208,52 @@ yy_stack_print (bottom, top) do { \ if (yydebug) \ yy_stack_print ((Bottom), (Top)); \ -} while (0) +} while (YYID (0)) /*------------------------------------------------. | Report that the YYRULE is going to be reduced. | `------------------------------------------------*/ -#if defined (__STDC__) || defined (__cplusplus) +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static void -yy_reduce_print (int yyrule) +yy_reduce_print (YYSTYPE *yyvsp, int yyrule) #else static void -yy_reduce_print (yyrule) +yy_reduce_print (yyvsp, yyrule) + YYSTYPE *yyvsp; int yyrule; #endif { + int yynrhs = yyr2[yyrule]; int yyi; - unsigned int yylno = yyrline[yyrule]; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", - yyrule - 1, yylno); - /* Print the symbols being reduced, and their result. */ - for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) - YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); - YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + ); + fprintf (stderr, "\n"); + } } # define YY_REDUCE_PRINT(Rule) \ do { \ if (yydebug) \ - yy_reduce_print (Rule); \ -} while (0) + yy_reduce_print (yyvsp, Rule); \ +} while (YYID (0)) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ # define YYDPRINTF(Args) -# define YYDSYMPRINT(Args) -# define YYDSYMPRINTF(Title, Token, Value, Location) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) # define YY_STACK_PRINT(Bottom, Top) # define YY_REDUCE_PRINT(Rule) #endif /* !YYDEBUG */ @@ -1063,13 +1268,9 @@ int yydebug; if the built-in stack extension method is used). Do not make this value too large; the results are undefined if - SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) evaluated with infinite-precision integer arithmetic. */ -#if defined (YYMAXDEPTH) && YYMAXDEPTH == 0 -# undef YYMAXDEPTH -#endif - #ifndef YYMAXDEPTH # define YYMAXDEPTH 10000 #endif @@ -1079,45 +1280,47 @@ int yydebug; #if YYERROR_VERBOSE # ifndef yystrlen -# if defined (__GLIBC__) && defined (_STRING_H) +# if defined __GLIBC__ && defined _STRING_H # define yystrlen strlen # else /* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static YYSIZE_T -# if defined (__STDC__) || defined (__cplusplus) yystrlen (const char *yystr) -# else +#else +static YYSIZE_T yystrlen (yystr) - const char *yystr; -# endif + const char *yystr; +#endif { - register const char *yys = yystr; - - while (*yys++ != '\0') + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) continue; - - return yys - yystr - 1; + return yylen; } # endif # endif # ifndef yystpcpy -# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE # define yystpcpy stpcpy # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static char * -# if defined (__STDC__) || defined (__cplusplus) yystpcpy (char *yydest, const char *yysrc) -# else +#else +static char * yystpcpy (yydest, yysrc) - char *yydest; - const char *yysrc; -# endif + char *yydest; + const char *yysrc; +#endif { - register char *yyd = yydest; - register const char *yys = yysrc; + char *yyd = yydest; + const char *yys = yysrc; while ((*yyd++ = *yys++) != '\0') continue; @@ -1127,70 +1330,192 @@ yystpcpy (yydest, yysrc) # endif # endif -#endif /* !YYERROR_VERBOSE */ - - - -#if YYDEBUG -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif -#if defined (__STDC__) || defined (__cplusplus) -static void -yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) -#else -static void -yysymprint (yyoutput, yytype, yyvaluep) - FILE *yyoutput; - int yytype; - YYSTYPE *yyvaluep; -#endif +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) { - /* Pacify ``unused variable'' warnings. */ - (void) yyvaluep; + int yyn = yypact[yystate]; - if (yytype < YYNTOKENS) - { - YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); -# ifdef YYPRINT - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); -# endif - } + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; else - YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); - - switch (yytype) { - default: - break; + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; } - YYFPRINTF (yyoutput, ")"); } +#endif /* YYERROR_VERBOSE */ + -#endif /* ! YYDEBUG */ /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ -#if defined (__STDC__) || defined (__cplusplus) +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static void -yydestruct (int yytype, YYSTYPE *yyvaluep) +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) #else static void -yydestruct (yytype, yyvaluep) +yydestruct (yymsg, yytype, yyvaluep) + const char *yymsg; int yytype; YYSTYPE *yyvaluep; #endif { - /* Pacify ``unused variable'' warnings. */ - (void) yyvaluep; + YYUSE (yyvaluep); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); switch (yytype) { default: - break; + break; } } @@ -1198,13 +1523,13 @@ yydestruct (yytype, yyvaluep) /* Prevent warnings from -Wmissing-prototypes. */ #ifdef YYPARSE_PARAM -# if defined (__STDC__) || defined (__cplusplus) +#if defined __STDC__ || defined __cplusplus int yyparse (void *YYPARSE_PARAM); -# else +#else int yyparse (); -# endif +#endif #else /* ! YYPARSE_PARAM */ -#if defined (__STDC__) || defined (__cplusplus) +#if defined __STDC__ || defined __cplusplus int yyparse (void); #else int yyparse (); @@ -1221,14 +1546,18 @@ int yyparse (); `----------*/ #ifdef YYPARSE_PARAM -# if defined (__STDC__) || defined (__cplusplus) -int yyparse (void *YYPARSE_PARAM) -# else -int yyparse (YYPARSE_PARAM) - void *YYPARSE_PARAM; -# endif +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif #else /* ! YYPARSE_PARAM */ -#if defined (__STDC__) || defined (__cplusplus) +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) int yyparse (void) #else @@ -1238,22 +1567,28 @@ yyparse () #endif #endif { - /* The lookahead symbol. */ + /* The look-ahead symbol. */ int yychar; -/* The semantic value of the lookahead symbol. */ +/* The semantic value of the look-ahead symbol. */ YYSTYPE yylval; /* Number of syntax errors so far. */ int yynerrs; - register int yystate; - register int yyn; + int yystate; + int yyn; int yyresult; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; - /* Lookahead token as an internal (translated) token number. */ + /* Look-ahead token as an internal (translated) token number. */ int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif /* Three stacks and their tools: `yyss': related to states, @@ -1264,18 +1599,18 @@ int yynerrs; to reallocate them elsewhere. */ /* The state stack. */ - short yyssa[YYINITDEPTH]; - short *yyss = yyssa; - register short *yyssp; + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; YYSTYPE *yyvs = yyvsa; - register YYSTYPE *yyvsp; + YYSTYPE *yyvsp; -#define YYPOPSTACK (yyvsp--, yyssp--) +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) YYSIZE_T yystacksize = YYINITDEPTH; @@ -1284,9 +1619,9 @@ int yynerrs; YYSTYPE yyval; - /* When reducing, the number of symbols on the RHS of the reduced - rule. */ - int yylen; + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; YYDPRINTF ((stderr, "Starting parse\n")); @@ -1310,8 +1645,7 @@ int yynerrs; `------------------------------------------------------------*/ yynewstate: /* In all cases, when you get here, the value and location stacks - have just been pushed. so pushing a state here evens the stacks. - */ + have just been pushed. So pushing a state here evens the stacks. */ yyssp++; yysetstate: @@ -1324,18 +1658,18 @@ int yynerrs; #ifdef yyoverflow { - /* Give user a chance to reallocate the stack. Use copies of + /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; - short *yyss1 = yyss; + yytype_int16 *yyss1 = yyss; /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ - yyoverflow ("parser stack overflow", + yyoverflow (YY_("memory exhausted"), &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), @@ -1346,21 +1680,21 @@ int yynerrs; } #else /* no yyoverflow */ # ifndef YYSTACK_RELOCATE - goto yyoverflowlab; + goto yyexhaustedlab; # else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) - goto yyoverflowlab; + goto yyexhaustedlab; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) yystacksize = YYMAXDEPTH; { - short *yyss1 = yyss; + yytype_int16 *yyss1 = yyss; union yyalloc *yyptr = (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) - goto yyoverflowlab; + goto yyexhaustedlab; YYSTACK_RELOCATE (yyss); YYSTACK_RELOCATE (yyvs); @@ -1391,19 +1725,17 @@ int yynerrs; `-----------*/ yybackup: -/* Do appropriate processing given the current state. */ -/* Read a lookahead token if we need one and don't already have one. */ -/* yyresume: */ - - /* First try to decide what to do without reference to lookahead token. */ + /* Do appropriate processing given the current state. Read a + look-ahead token if we need one and don't already have one. */ + /* First try to decide what to do without reference to look-ahead token. */ yyn = yypact[yystate]; if (yyn == YYPACT_NINF) goto yydefault; - /* Not known => get a lookahead token if don't already have one. */ + /* Not known => get a look-ahead token if don't already have one. */ - /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); @@ -1418,7 +1750,7 @@ yybackup: else { yytoken = YYTRANSLATE (yychar); - YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); } /* If the proper action on seeing token YYTOKEN is to reduce or to @@ -1438,22 +1770,21 @@ yybackup: if (yyn == YYFINAL) YYACCEPT; - /* Shift the lookahead token. */ - YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); - - /* Discard the token being shifted unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; - - *++yyvsp = yylval; - - /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + yystate = yyn; + *++yyvsp = yylval; + goto yynewstate; @@ -1489,36 +1820,36 @@ yyreduce: switch (yyn) { case 2: -#line 106 "../Slice/Grammar.y" +#line 106 "Grammar.y" { ;} break; case 3: -#line 114 "../Slice/Grammar.y" +#line 114 "Grammar.y" { - yyval = yyvsp[-1]; + (yyval) = (yyvsp[(2) - (3)]); ;} break; case 4: -#line 123 "../Slice/Grammar.y" +#line 123 "Grammar.y" { - yyval = yyvsp[-1]; + (yyval) = (yyvsp[(2) - (3)]); ;} break; case 5: -#line 127 "../Slice/Grammar.y" +#line 127 "Grammar.y" { - yyval = new StringListTok; + (yyval) = new StringListTok; ;} break; case 6: -#line 136 "../Slice/Grammar.y" +#line 136 "Grammar.y" { - StringListTokPtr metaData = StringListTokPtr::dynamicCast(yyvsp[0]); + StringListTokPtr metaData = StringListTokPtr::dynamicCast((yyvsp[(1) - (1)])); if(!metaData->v.empty()) { unit->addGlobalMetaData(metaData->v); @@ -1527,193 +1858,193 @@ yyreduce: break; case 8: -#line 145 "../Slice/Grammar.y" +#line 145 "Grammar.y" { - StringListTokPtr metaData = StringListTokPtr::dynamicCast(yyvsp[-1]); - ContainedPtr contained = ContainedPtr::dynamicCast(yyvsp[0]); + StringListTokPtr metaData = StringListTokPtr::dynamicCast((yyvsp[(1) - (2)])); + ContainedPtr contained = ContainedPtr::dynamicCast((yyvsp[(2) - (2)])); if(contained && !metaData->v.empty()) { contained->setMetaData(metaData->v); } - unit->setSeenDefinition(); ;} break; case 10: -#line 156 "../Slice/Grammar.y" +#line 155 "Grammar.y" { yyerrok; ;} break; case 12: -#line 161 "../Slice/Grammar.y" +#line 160 "Grammar.y" { unit->error("`;' missing after definition"); ;} break; case 13: -#line 165 "../Slice/Grammar.y" +#line 164 "Grammar.y" { ;} break; case 14: -#line 173 "../Slice/Grammar.y" +#line 172 "Grammar.y" { - assert(yyvsp[0] == 0 || ModulePtr::dynamicCast(yyvsp[0])); + assert((yyvsp[(1) - (1)]) == 0 || ModulePtr::dynamicCast((yyvsp[(1) - (1)]))); ;} break; case 15: -#line 177 "../Slice/Grammar.y" +#line 176 "Grammar.y" { - assert(yyvsp[0] == 0 || ClassDeclPtr::dynamicCast(yyvsp[0])); + assert((yyvsp[(1) - (1)]) == 0 || ClassDeclPtr::dynamicCast((yyvsp[(1) - (1)]))); ;} break; case 16: -#line 181 "../Slice/Grammar.y" +#line 180 "Grammar.y" { - assert(yyvsp[0] == 0 || ClassDefPtr::dynamicCast(yyvsp[0])); + assert((yyvsp[(1) - (1)]) == 0 || ClassDefPtr::dynamicCast((yyvsp[(1) - (1)]))); ;} break; case 17: -#line 185 "../Slice/Grammar.y" +#line 184 "Grammar.y" { - assert(yyvsp[0] == 0 || ClassDeclPtr::dynamicCast(yyvsp[0])); + assert((yyvsp[(1) - (1)]) == 0 || ClassDeclPtr::dynamicCast((yyvsp[(1) - (1)]))); ;} break; case 18: -#line 189 "../Slice/Grammar.y" +#line 188 "Grammar.y" { - assert(yyvsp[0] == 0 || ClassDefPtr::dynamicCast(yyvsp[0])); + assert((yyvsp[(1) - (1)]) == 0 || ClassDefPtr::dynamicCast((yyvsp[(1) - (1)]))); ;} break; case 19: -#line 193 "../Slice/Grammar.y" +#line 192 "Grammar.y" { - assert(yyvsp[0] == 0); + assert((yyvsp[(1) - (1)]) == 0); ;} break; case 20: -#line 197 "../Slice/Grammar.y" +#line 196 "Grammar.y" { - assert(yyvsp[0] == 0 || ExceptionPtr::dynamicCast(yyvsp[0])); + assert((yyvsp[(1) - (1)]) == 0 || ExceptionPtr::dynamicCast((yyvsp[(1) - (1)]))); ;} break; case 21: -#line 201 "../Slice/Grammar.y" +#line 200 "Grammar.y" { - assert(yyvsp[0] == 0); + assert((yyvsp[(1) - (1)]) == 0); ;} break; case 22: -#line 205 "../Slice/Grammar.y" +#line 204 "Grammar.y" { - assert(yyvsp[0] == 0 || StructPtr::dynamicCast(yyvsp[0])); + assert((yyvsp[(1) - (1)]) == 0 || StructPtr::dynamicCast((yyvsp[(1) - (1)]))); ;} break; case 23: -#line 209 "../Slice/Grammar.y" +#line 208 "Grammar.y" { - assert(yyvsp[0] == 0 || SequencePtr::dynamicCast(yyvsp[0])); + assert((yyvsp[(1) - (1)]) == 0 || SequencePtr::dynamicCast((yyvsp[(1) - (1)]))); ;} break; case 24: -#line 213 "../Slice/Grammar.y" +#line 212 "Grammar.y" { - assert(yyvsp[0] == 0 || DictionaryPtr::dynamicCast(yyvsp[0])); + assert((yyvsp[(1) - (1)]) == 0 || DictionaryPtr::dynamicCast((yyvsp[(1) - (1)]))); ;} break; case 25: -#line 217 "../Slice/Grammar.y" +#line 216 "Grammar.y" { - assert(yyvsp[0] == 0 || EnumPtr::dynamicCast(yyvsp[0])); + assert((yyvsp[(1) - (1)]) == 0 || EnumPtr::dynamicCast((yyvsp[(1) - (1)]))); ;} break; case 26: -#line 221 "../Slice/Grammar.y" +#line 220 "Grammar.y" { - assert(yyvsp[0] == 0 || ConstPtr::dynamicCast(yyvsp[0])); + assert((yyvsp[(1) - (1)]) == 0 || ConstPtr::dynamicCast((yyvsp[(1) - (1)]))); ;} break; case 27: -#line 230 "../Slice/Grammar.y" +#line 229 "Grammar.y" { - StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); + unit->setSeenDefinition(); + StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(2) - (2)])); ContainerPtr cont = unit->currentContainer(); ModulePtr module = cont->createModule(ident->v); if(module) { cont->checkIntroduced(ident->v, module); unit->pushContainer(module); - yyval = module; + (yyval) = module; } else { - yyval = 0; + (yyval) = 0; } ;} break; case 28: -#line 246 "../Slice/Grammar.y" +#line 246 "Grammar.y" { - if(yyvsp[-3]) + if((yyvsp[(3) - (6)])) { unit->popContainer(); - yyval = yyvsp[-3]; + (yyval) = (yyvsp[(3) - (6)]); } else { - yyval = 0; + (yyval) = 0; } ;} break; case 29: -#line 263 "../Slice/Grammar.y" +#line 263 "Grammar.y" { - yyval = yyvsp[0]; + (yyval) = (yyvsp[(2) - (2)]); ;} break; case 30: -#line 267 "../Slice/Grammar.y" +#line 267 "Grammar.y" { - StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); + StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(2) - (2)])); unit->error("keyword `" + ident->v + "' cannot be used as exception name"); - yyval = yyvsp[0]; // Dummy + (yyval) = (yyvsp[(2) - (2)]); // Dummy ;} break; case 31: -#line 278 "../Slice/Grammar.y" +#line 278 "Grammar.y" { unit->error("exceptions cannot be forward declared"); - yyval = 0; + (yyval) = 0; ;} break; case 32: -#line 288 "../Slice/Grammar.y" +#line 288 "Grammar.y" { - BoolTokPtr local = BoolTokPtr::dynamicCast(yyvsp[-2]); - StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[-1]); - ExceptionPtr base = ExceptionPtr::dynamicCast(yyvsp[0]); + BoolTokPtr local = BoolTokPtr::dynamicCast((yyvsp[(1) - (3)])); + StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(2) - (3)])); + ExceptionPtr base = ExceptionPtr::dynamicCast((yyvsp[(3) - (3)])); ContainerPtr cont = unit->currentContainer(); ExceptionPtr ex = cont->createException(ident->v, base, local->v); if(ex) @@ -1721,44 +2052,44 @@ yyreduce: cont->checkIntroduced(ident->v, ex); unit->pushContainer(ex); } - yyval = ex; + (yyval) = ex; ;} break; case 33: -#line 302 "../Slice/Grammar.y" +#line 302 "Grammar.y" { - if(yyvsp[-3]) + if((yyvsp[(4) - (7)])) { unit->popContainer(); } - yyval = yyvsp[-3]; + (yyval) = (yyvsp[(4) - (7)]); ;} break; case 34: -#line 315 "../Slice/Grammar.y" +#line 315 "Grammar.y" { - StringTokPtr scoped = StringTokPtr::dynamicCast(yyvsp[0]); + StringTokPtr scoped = StringTokPtr::dynamicCast((yyvsp[(2) - (2)])); ContainerPtr cont = unit->currentContainer(); ContainedPtr contained = cont->lookupException(scoped->v); cont->checkIntroduced(scoped->v); - yyval = contained; + (yyval) = contained; ;} break; case 35: -#line 323 "../Slice/Grammar.y" +#line 323 "Grammar.y" { - yyval = 0; + (yyval) = 0; ;} break; case 36: -#line 332 "../Slice/Grammar.y" +#line 332 "Grammar.y" { - StringListTokPtr metaData = StringListTokPtr::dynamicCast(yyvsp[-3]); - ContainedPtr contained = ContainedPtr::dynamicCast(yyvsp[-2]); + StringListTokPtr metaData = StringListTokPtr::dynamicCast((yyvsp[(1) - (4)])); + ContainedPtr contained = ContainedPtr::dynamicCast((yyvsp[(2) - (4)])); if(contained && !metaData->v.empty()) { contained->setMetaData(metaData->v); @@ -1767,64 +2098,64 @@ yyreduce: break; case 37: -#line 341 "../Slice/Grammar.y" +#line 341 "Grammar.y" { ;} break; case 38: -#line 344 "../Slice/Grammar.y" +#line 344 "Grammar.y" { unit->error("`;' missing after definition"); ;} break; case 39: -#line 348 "../Slice/Grammar.y" +#line 348 "Grammar.y" { ;} break; case 40: -#line 356 "../Slice/Grammar.y" +#line 356 "Grammar.y" { - TypePtr type = TypePtr::dynamicCast(yyvsp[-1]); - StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); + TypePtr type = TypePtr::dynamicCast((yyvsp[(1) - (2)])); + StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(2) - (2)])); TypeStringTokPtr typestring = new TypeStringTok; typestring->v = make_pair(type, ident->v); - yyval = typestring; + (yyval) = typestring; ;} break; case 42: -#line 375 "../Slice/Grammar.y" +#line 375 "Grammar.y" { - yyval = yyvsp[0]; + (yyval) = (yyvsp[(2) - (2)]); ;} break; case 43: -#line 379 "../Slice/Grammar.y" +#line 379 "Grammar.y" { - StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); + StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(2) - (2)])); unit->error("keyword `" + ident->v + "' cannot be used as struct name"); - yyval = yyvsp[0]; // Dummy + (yyval) = (yyvsp[(2) - (2)]); // Dummy ;} break; case 44: -#line 390 "../Slice/Grammar.y" +#line 390 "Grammar.y" { unit->error("structs cannot be forward declared"); - yyval = 0; // Dummy + (yyval) = 0; // Dummy ;} break; case 45: -#line 400 "../Slice/Grammar.y" +#line 400 "Grammar.y" { - BoolTokPtr local = BoolTokPtr::dynamicCast(yyvsp[-1]); - StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); + BoolTokPtr local = BoolTokPtr::dynamicCast((yyvsp[(1) - (2)])); + StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(2) - (2)])); ContainerPtr cont = unit->currentContainer(); StructPtr st = cont->createStruct(ident->v, local->v); if(st) @@ -1832,23 +2163,23 @@ yyreduce: cont->checkIntroduced(ident->v, st); unit->pushContainer(st); } - yyval = st; + (yyval) = st; ;} break; case 46: -#line 413 "../Slice/Grammar.y" +#line 413 "Grammar.y" { - if(yyvsp[-3]) + if((yyvsp[(3) - (6)])) { unit->popContainer(); } - yyval = yyvsp[-3]; + (yyval) = (yyvsp[(3) - (6)]); // // Empty structures are not allowed // - StructPtr st = StructPtr::dynamicCast(yyval); + StructPtr st = StructPtr::dynamicCast((yyval)); assert(st); if(st->dataMembers().empty()) { @@ -1858,10 +2189,10 @@ yyreduce: break; case 47: -#line 436 "../Slice/Grammar.y" +#line 436 "Grammar.y" { - StringListTokPtr metaData = StringListTokPtr::dynamicCast(yyvsp[-3]); - ContainedPtr contained = ContainedPtr::dynamicCast(yyvsp[-2]); + StringListTokPtr metaData = StringListTokPtr::dynamicCast((yyvsp[(1) - (4)])); + ContainedPtr contained = ContainedPtr::dynamicCast((yyvsp[(2) - (4)])); if(contained && !metaData->v.empty()) { contained->setMetaData(metaData->v); @@ -1870,59 +2201,59 @@ yyreduce: break; case 48: -#line 445 "../Slice/Grammar.y" +#line 445 "Grammar.y" { ;} break; case 49: -#line 448 "../Slice/Grammar.y" +#line 448 "Grammar.y" { unit->error("`;' missing after definition"); ;} break; case 50: -#line 452 "../Slice/Grammar.y" +#line 452 "Grammar.y" { ;} break; case 52: -#line 466 "../Slice/Grammar.y" +#line 466 "Grammar.y" { - yyval = yyvsp[0]; + (yyval) = (yyvsp[(2) - (2)]); ;} break; case 53: -#line 470 "../Slice/Grammar.y" +#line 470 "Grammar.y" { - StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); + StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(2) - (2)])); unit->error("keyword `" + ident->v + "' cannot be used as class name"); - yyval = yyvsp[0]; // Dummy + (yyval) = (yyvsp[(2) - (2)]); // Dummy ;} break; case 54: -#line 481 "../Slice/Grammar.y" +#line 481 "Grammar.y" { - BoolTokPtr local = BoolTokPtr::dynamicCast(yyvsp[-1]); - StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); + BoolTokPtr local = BoolTokPtr::dynamicCast((yyvsp[(1) - (2)])); + StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(2) - (2)])); ContainerPtr cont = unit->currentContainer(); ClassDeclPtr cl = cont->createClassDecl(ident->v, false, local->v); - yyval = cl; + (yyval) = cl; ;} break; case 55: -#line 494 "../Slice/Grammar.y" +#line 494 "Grammar.y" { - BoolTokPtr local = BoolTokPtr::dynamicCast(yyvsp[-3]); - StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[-2]); + BoolTokPtr local = BoolTokPtr::dynamicCast((yyvsp[(1) - (4)])); + StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(2) - (4)])); ContainerPtr cont = unit->currentContainer(); - ClassDefPtr base = ClassDefPtr::dynamicCast(yyvsp[-1]); - ClassListTokPtr bases = ClassListTokPtr::dynamicCast(yyvsp[0]); + ClassDefPtr base = ClassDefPtr::dynamicCast((yyvsp[(3) - (4)])); + ClassListTokPtr bases = ClassListTokPtr::dynamicCast((yyvsp[(4) - (4)])); if(base) { bases->v.push_front(base); @@ -1932,37 +2263,37 @@ yyreduce: { cont->checkIntroduced(ident->v, cl); unit->pushContainer(cl); - yyval = cl; + (yyval) = cl; } else { - yyval = 0; + (yyval) = 0; } ;} break; case 56: -#line 517 "../Slice/Grammar.y" +#line 517 "Grammar.y" { - if(yyvsp[-3]) + if((yyvsp[(5) - (8)])) { unit->popContainer(); - yyval = yyvsp[-3]; + (yyval) = (yyvsp[(5) - (8)]); } else { - yyval = 0; + (yyval) = 0; } ;} break; case 57: -#line 534 "../Slice/Grammar.y" +#line 534 "Grammar.y" { - StringTokPtr scoped = StringTokPtr::dynamicCast(yyvsp[0]); + StringTokPtr scoped = StringTokPtr::dynamicCast((yyvsp[(2) - (2)])); ContainerPtr cont = unit->currentContainer(); TypeList types = cont->lookupType(scoped->v); - yyval = 0; + (yyval) = 0; if(!types.empty()) { ClassDeclPtr cl = ClassDeclPtr::dynamicCast(types.front()); @@ -1986,7 +2317,7 @@ yyreduce: else { cont->checkIntroduced(scoped->v); - yyval = def; + (yyval) = def; } } } @@ -1994,31 +2325,31 @@ yyreduce: break; case 58: -#line 568 "../Slice/Grammar.y" +#line 568 "Grammar.y" { - yyval = 0; + (yyval) = 0; ;} break; case 59: -#line 577 "../Slice/Grammar.y" +#line 577 "Grammar.y" { - yyval = yyvsp[0]; + (yyval) = (yyvsp[(2) - (2)]); ;} break; case 60: -#line 581 "../Slice/Grammar.y" +#line 581 "Grammar.y" { - yyval = new ClassListTok; + (yyval) = new ClassListTok; ;} break; case 61: -#line 590 "../Slice/Grammar.y" +#line 590 "Grammar.y" { - StringListTokPtr metaData = StringListTokPtr::dynamicCast(yyvsp[-3]); - ContainedPtr contained = ContainedPtr::dynamicCast(yyvsp[-2]); + StringListTokPtr metaData = StringListTokPtr::dynamicCast((yyvsp[(1) - (4)])); + ContainedPtr contained = ContainedPtr::dynamicCast((yyvsp[(2) - (4)])); if(contained && !metaData->v.empty()) { contained->setMetaData(metaData->v); @@ -2027,29 +2358,29 @@ yyreduce: break; case 62: -#line 599 "../Slice/Grammar.y" +#line 599 "Grammar.y" { ;} break; case 63: -#line 602 "../Slice/Grammar.y" +#line 602 "Grammar.y" { unit->error("`;' missing after definition"); ;} break; case 64: -#line 606 "../Slice/Grammar.y" +#line 606 "Grammar.y" { ;} break; case 65: -#line 614 "../Slice/Grammar.y" +#line 614 "Grammar.y" { - TypePtr type = TypeStringTokPtr::dynamicCast(yyvsp[0])->v.first; - string name = TypeStringTokPtr::dynamicCast(yyvsp[0])->v.second; + TypePtr type = TypeStringTokPtr::dynamicCast((yyvsp[(1) - (1)]))->v.first; + string name = TypeStringTokPtr::dynamicCast((yyvsp[(1) - (1)]))->v.second; ClassDefPtr cl = ClassDefPtr::dynamicCast(unit->currentContainer()); DataMemberPtr dm; if(cl) @@ -2067,71 +2398,71 @@ yyreduce: dm = ex->createDataMember(name, type); } unit->currentContainer()->checkIntroduced(name, dm); - yyval = dm; + (yyval) = dm; ;} break; case 66: -#line 637 "../Slice/Grammar.y" +#line 637 "Grammar.y" { - TypePtr type = TypePtr::dynamicCast(yyvsp[-1]); - string name = StringTokPtr::dynamicCast(yyvsp[0])->v; + TypePtr type = TypePtr::dynamicCast((yyvsp[(1) - (2)])); + string name = StringTokPtr::dynamicCast((yyvsp[(2) - (2)]))->v; ClassDefPtr cl = ClassDefPtr::dynamicCast(unit->currentContainer()); if(cl) { - yyval = cl->createDataMember(name, type); // Dummy + (yyval) = cl->createDataMember(name, type); // Dummy } StructPtr st = StructPtr::dynamicCast(unit->currentContainer()); if(st) { - yyval = st->createDataMember(name, type); // Dummy + (yyval) = st->createDataMember(name, type); // Dummy } ExceptionPtr ex = ExceptionPtr::dynamicCast(unit->currentContainer()); if(ex) { - yyval = ex->createDataMember(name, type); // Dummy + (yyval) = ex->createDataMember(name, type); // Dummy } - assert(yyval); + assert((yyval)); unit->error("keyword `" + name + "' cannot be used as data member name"); ;} break; case 67: -#line 659 "../Slice/Grammar.y" +#line 659 "Grammar.y" { - TypePtr type = TypePtr::dynamicCast(yyvsp[0]); + TypePtr type = TypePtr::dynamicCast((yyvsp[(1) - (1)])); ClassDefPtr cl = ClassDefPtr::dynamicCast(unit->currentContainer()); if(cl) { - yyval = cl->createDataMember(IceUtil::generateUUID(), type); // Dummy + (yyval) = cl->createDataMember(IceUtil::generateUUID(), type); // Dummy } StructPtr st = StructPtr::dynamicCast(unit->currentContainer()); if(st) { - yyval = st->createDataMember(IceUtil::generateUUID(), type); // Dummy + (yyval) = st->createDataMember(IceUtil::generateUUID(), type); // Dummy } ExceptionPtr ex = ExceptionPtr::dynamicCast(unit->currentContainer()); if(ex) { - yyval = ex->createDataMember(IceUtil::generateUUID(), type); // Dummy + (yyval) = ex->createDataMember(IceUtil::generateUUID(), type); // Dummy } - assert(yyval); + assert((yyval)); unit->error("missing data member name"); ;} break; case 69: -#line 686 "../Slice/Grammar.y" +#line 686 "Grammar.y" { - yyval = 0; + (yyval) = 0; ;} break; case 70: -#line 695 "../Slice/Grammar.y" +#line 695 "Grammar.y" { - TypePtr returnType = TypePtr::dynamicCast(yyvsp[-1]); - string name = StringTokPtr::dynamicCast(yyvsp[0])->v; + TypePtr returnType = TypePtr::dynamicCast((yyvsp[(1) - (2)])); + string name = StringTokPtr::dynamicCast((yyvsp[(2) - (2)]))->v; ClassDefPtr cl = ClassDefPtr::dynamicCast(unit->currentContainer()); if(cl) { @@ -2140,25 +2471,25 @@ yyreduce: { cl->checkIntroduced(name, op); unit->pushContainer(op); - yyval = op; + (yyval) = op; } else { - yyval = 0; + (yyval) = 0; } } else { - yyval = 0; + (yyval) = 0; } ;} break; case 71: -#line 719 "../Slice/Grammar.y" +#line 719 "Grammar.y" { - TypePtr returnType = TypePtr::dynamicCast(yyvsp[-1]); - string name = StringTokPtr::dynamicCast(yyvsp[0])->v; + TypePtr returnType = TypePtr::dynamicCast((yyvsp[(2) - (3)])); + string name = StringTokPtr::dynamicCast((yyvsp[(3) - (3)]))->v; ClassDefPtr cl = ClassDefPtr::dynamicCast(unit->currentContainer()); if(cl) { @@ -2184,25 +2515,25 @@ yyreduce: } unit->warning(msg); - yyval = op; + (yyval) = op; } else { - yyval = 0; + (yyval) = 0; } } else { - yyval = 0; + (yyval) = 0; } ;} break; case 72: -#line 760 "../Slice/Grammar.y" +#line 760 "Grammar.y" { - TypePtr returnType = TypePtr::dynamicCast(yyvsp[-1]); - string name = StringTokPtr::dynamicCast(yyvsp[0])->v; + TypePtr returnType = TypePtr::dynamicCast((yyvsp[(2) - (3)])); + string name = StringTokPtr::dynamicCast((yyvsp[(3) - (3)]))->v; ClassDefPtr cl = ClassDefPtr::dynamicCast(unit->currentContainer()); if(cl) { @@ -2211,25 +2542,25 @@ yyreduce: { cl->checkIntroduced(name, op); unit->pushContainer(op); - yyval = op; + (yyval) = op; } else { - yyval = 0; + (yyval) = 0; } } else { - yyval = 0; + (yyval) = 0; } ;} break; case 73: -#line 784 "../Slice/Grammar.y" +#line 784 "Grammar.y" { - TypePtr returnType = TypePtr::dynamicCast(yyvsp[-1]); - string name = StringTokPtr::dynamicCast(yyvsp[0])->v; + TypePtr returnType = TypePtr::dynamicCast((yyvsp[(1) - (2)])); + string name = StringTokPtr::dynamicCast((yyvsp[(2) - (2)]))->v; ClassDefPtr cl = ClassDefPtr::dynamicCast(unit->currentContainer()); if(cl) { @@ -2238,25 +2569,25 @@ yyreduce: { unit->pushContainer(op); unit->error("keyword `" + name + "' cannot be used as operation name"); - yyval = op; // Dummy + (yyval) = op; // Dummy } else { - yyval = 0; + (yyval) = 0; } } else { - yyval = 0; + (yyval) = 0; } ;} break; case 74: -#line 808 "../Slice/Grammar.y" +#line 808 "Grammar.y" { - TypePtr returnType = TypePtr::dynamicCast(yyvsp[-1]); - string name = StringTokPtr::dynamicCast(yyvsp[0])->v; + TypePtr returnType = TypePtr::dynamicCast((yyvsp[(2) - (3)])); + string name = StringTokPtr::dynamicCast((yyvsp[(3) - (3)]))->v; ClassDefPtr cl = ClassDefPtr::dynamicCast(unit->currentContainer()); if(cl) { @@ -2265,25 +2596,25 @@ yyreduce: { unit->pushContainer(op); unit->error("keyword `" + name + "' cannot be used as operation name"); - yyval = op; // Dummy + (yyval) = op; // Dummy } else { - yyval = 0; + (yyval) = 0; } } else { - yyval = 0; + (yyval) = 0; } ;} break; case 75: -#line 832 "../Slice/Grammar.y" +#line 832 "Grammar.y" { - TypePtr returnType = TypePtr::dynamicCast(yyvsp[-1]); - string name = StringTokPtr::dynamicCast(yyvsp[0])->v; + TypePtr returnType = TypePtr::dynamicCast((yyvsp[(2) - (3)])); + string name = StringTokPtr::dynamicCast((yyvsp[(3) - (3)]))->v; ClassDefPtr cl = ClassDefPtr::dynamicCast(unit->currentContainer()); if(cl) { @@ -2292,7 +2623,7 @@ yyreduce: { unit->pushContainer(op); unit->error("keyword `" + name + "' cannot be used as operation name"); - yyval = op; // Dummy + (yyval) = op; // Dummy } else { @@ -2301,31 +2632,31 @@ yyreduce: } else { - yyval = 0; + (yyval) = 0; } ;} break; case 76: -#line 861 "../Slice/Grammar.y" +#line 861 "Grammar.y" { - if(yyvsp[-2]) + if((yyvsp[(1) - (3)])) { unit->popContainer(); - yyval = yyvsp[-2]; + (yyval) = (yyvsp[(1) - (3)]); } else { - yyval = 0; + (yyval) = 0; } ;} break; case 77: -#line 873 "../Slice/Grammar.y" +#line 873 "Grammar.y" { - OperationPtr op = OperationPtr::dynamicCast(yyvsp[-1]); - ExceptionListTokPtr el = ExceptionListTokPtr::dynamicCast(yyvsp[0]); + OperationPtr op = OperationPtr::dynamicCast((yyvsp[(4) - (5)])); + ExceptionListTokPtr el = ExceptionListTokPtr::dynamicCast((yyvsp[(5) - (5)])); assert(el); if(op) { @@ -2335,9 +2666,9 @@ yyreduce: break; case 78: -#line 883 "../Slice/Grammar.y" +#line 883 "Grammar.y" { - if(yyvsp[-2]) + if((yyvsp[(1) - (3)])) { unit->popContainer(); } @@ -2346,10 +2677,10 @@ yyreduce: break; case 79: -#line 891 "../Slice/Grammar.y" +#line 891 "Grammar.y" { - OperationPtr op = OperationPtr::dynamicCast(yyvsp[-1]); - ExceptionListTokPtr el = ExceptionListTokPtr::dynamicCast(yyvsp[0]); + OperationPtr op = OperationPtr::dynamicCast((yyvsp[(4) - (5)])); + ExceptionListTokPtr el = ExceptionListTokPtr::dynamicCast((yyvsp[(5) - (5)])); assert(el); if(op) { @@ -2359,74 +2690,74 @@ yyreduce: break; case 82: -#line 913 "../Slice/Grammar.y" +#line 913 "Grammar.y" { - yyval = yyvsp[0]; + (yyval) = (yyvsp[(2) - (2)]); ;} break; case 83: -#line 917 "../Slice/Grammar.y" +#line 917 "Grammar.y" { - StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); + StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(2) - (2)])); unit->error("keyword `" + ident->v + "' cannot be used as interface name"); - yyval = yyvsp[0]; // Dummy + (yyval) = (yyvsp[(2) - (2)]); // Dummy ;} break; case 84: -#line 928 "../Slice/Grammar.y" +#line 928 "Grammar.y" { - BoolTokPtr local = BoolTokPtr::dynamicCast(yyvsp[-1]); - StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); + BoolTokPtr local = BoolTokPtr::dynamicCast((yyvsp[(1) - (2)])); + StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(2) - (2)])); ContainerPtr cont = unit->currentContainer(); ClassDeclPtr cl = cont->createClassDecl(ident->v, true, local->v); cont->checkIntroduced(ident->v, cl); - yyval = cl; + (yyval) = cl; ;} break; case 85: -#line 942 "../Slice/Grammar.y" +#line 942 "Grammar.y" { - BoolTokPtr local = BoolTokPtr::dynamicCast(yyvsp[-2]); - StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[-1]); + BoolTokPtr local = BoolTokPtr::dynamicCast((yyvsp[(1) - (3)])); + StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(2) - (3)])); ContainerPtr cont = unit->currentContainer(); - ClassListTokPtr bases = ClassListTokPtr::dynamicCast(yyvsp[0]); + ClassListTokPtr bases = ClassListTokPtr::dynamicCast((yyvsp[(3) - (3)])); ClassDefPtr cl = cont->createClassDef(ident->v, true, bases->v, local->v); if(cl) { cont->checkIntroduced(ident->v, cl); unit->pushContainer(cl); - yyval = cl; + (yyval) = cl; } else { - yyval = 0; + (yyval) = 0; } ;} break; case 86: -#line 960 "../Slice/Grammar.y" +#line 960 "Grammar.y" { - if(yyvsp[-3]) + if((yyvsp[(4) - (7)])) { unit->popContainer(); - yyval = yyvsp[-3]; + (yyval) = (yyvsp[(4) - (7)]); } else { - yyval = 0; + (yyval) = 0; } ;} break; case 87: -#line 977 "../Slice/Grammar.y" +#line 977 "Grammar.y" { - ClassListTokPtr intfs = ClassListTokPtr::dynamicCast(yyvsp[0]); - StringTokPtr scoped = StringTokPtr::dynamicCast(yyvsp[-2]); + ClassListTokPtr intfs = ClassListTokPtr::dynamicCast((yyvsp[(3) - (3)])); + StringTokPtr scoped = StringTokPtr::dynamicCast((yyvsp[(1) - (3)])); ContainerPtr cont = unit->currentContainer(); TypeList types = cont->lookupType(scoped->v); if(!types.empty()) @@ -2456,15 +2787,15 @@ yyreduce: } } } - yyval = intfs; + (yyval) = intfs; ;} break; case 88: -#line 1012 "../Slice/Grammar.y" +#line 1012 "Grammar.y" { ClassListTokPtr intfs = new ClassListTok; - StringTokPtr scoped = StringTokPtr::dynamicCast(yyvsp[0]); + StringTokPtr scoped = StringTokPtr::dynamicCast((yyvsp[(1) - (1)])); ContainerPtr cont = unit->currentContainer(); TypeList types = cont->lookupType(scoped->v); if(!types.empty()) @@ -2494,37 +2825,37 @@ yyreduce: } } } - yyval = intfs; + (yyval) = intfs; ;} break; case 89: -#line 1047 "../Slice/Grammar.y" +#line 1047 "Grammar.y" { unit->error("illegal inheritance from type Object"); - yyval = new ClassListTok; // Dummy + (yyval) = new ClassListTok; // Dummy ;} break; case 90: -#line 1057 "../Slice/Grammar.y" +#line 1057 "Grammar.y" { - yyval = yyvsp[0]; + (yyval) = (yyvsp[(2) - (2)]); ;} break; case 91: -#line 1061 "../Slice/Grammar.y" +#line 1061 "Grammar.y" { - yyval = new ClassListTok; + (yyval) = new ClassListTok; ;} break; case 92: -#line 1070 "../Slice/Grammar.y" +#line 1070 "Grammar.y" { - StringListTokPtr metaData = StringListTokPtr::dynamicCast(yyvsp[-3]); - ContainedPtr contained = ContainedPtr::dynamicCast(yyvsp[-2]); + StringListTokPtr metaData = StringListTokPtr::dynamicCast((yyvsp[(1) - (4)])); + ContainedPtr contained = ContainedPtr::dynamicCast((yyvsp[(2) - (4)])); if(contained && !metaData->v.empty()) { contained->setMetaData(metaData->v); @@ -2533,48 +2864,48 @@ yyreduce: break; case 93: -#line 1079 "../Slice/Grammar.y" +#line 1079 "Grammar.y" { ;} break; case 94: -#line 1082 "../Slice/Grammar.y" +#line 1082 "Grammar.y" { unit->error("`;' missing after definition"); ;} break; case 95: -#line 1086 "../Slice/Grammar.y" +#line 1086 "Grammar.y" { ;} break; case 97: -#line 1100 "../Slice/Grammar.y" +#line 1100 "Grammar.y" { - ExceptionPtr exception = ExceptionPtr::dynamicCast(yyvsp[-2]); - ExceptionListTokPtr exceptionList = ExceptionListTokPtr::dynamicCast(yyvsp[0]); + ExceptionPtr exception = ExceptionPtr::dynamicCast((yyvsp[(1) - (3)])); + ExceptionListTokPtr exceptionList = ExceptionListTokPtr::dynamicCast((yyvsp[(3) - (3)])); exceptionList->v.push_front(exception); - yyval = exceptionList; + (yyval) = exceptionList; ;} break; case 98: -#line 1107 "../Slice/Grammar.y" +#line 1107 "Grammar.y" { - ExceptionPtr exception = ExceptionPtr::dynamicCast(yyvsp[0]); + ExceptionPtr exception = ExceptionPtr::dynamicCast((yyvsp[(1) - (1)])); ExceptionListTokPtr exceptionList = new ExceptionListTok; exceptionList->v.push_front(exception); - yyval = exceptionList; + (yyval) = exceptionList; ;} break; case 99: -#line 1119 "../Slice/Grammar.y" +#line 1119 "Grammar.y" { - StringTokPtr scoped = StringTokPtr::dynamicCast(yyvsp[0]); + StringTokPtr scoped = StringTokPtr::dynamicCast((yyvsp[(1) - (1)])); ContainerPtr cont = unit->currentContainer(); ExceptionPtr exception = cont->lookupException(scoped->v); if(!exception) @@ -2582,150 +2913,150 @@ yyreduce: exception = cont->createException(IceUtil::generateUUID(), 0, false, Dummy); // Dummy } cont->checkIntroduced(scoped->v, exception); - yyval = exception; + (yyval) = exception; ;} break; case 100: -#line 1131 "../Slice/Grammar.y" +#line 1131 "Grammar.y" { - StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); + StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(1) - (1)])); unit->error("keyword `" + ident->v + "' cannot be used as exception name"); - yyval = unit->currentContainer()->createException(IceUtil::generateUUID(), 0, false, Dummy); // Dummy + (yyval) = unit->currentContainer()->createException(IceUtil::generateUUID(), 0, false, Dummy); // Dummy ;} break; case 101: -#line 1142 "../Slice/Grammar.y" +#line 1142 "Grammar.y" { - BoolTokPtr local = BoolTokPtr::dynamicCast(yyvsp[-6]); - StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); - StringListTokPtr metaData = StringListTokPtr::dynamicCast(yyvsp[-3]); - TypePtr type = TypePtr::dynamicCast(yyvsp[-2]); + BoolTokPtr local = BoolTokPtr::dynamicCast((yyvsp[(1) - (7)])); + StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(7) - (7)])); + StringListTokPtr metaData = StringListTokPtr::dynamicCast((yyvsp[(4) - (7)])); + TypePtr type = TypePtr::dynamicCast((yyvsp[(5) - (7)])); ContainerPtr cont = unit->currentContainer(); - yyval = cont->createSequence(ident->v, type, metaData->v, local->v); + (yyval) = cont->createSequence(ident->v, type, metaData->v, local->v); ;} break; case 102: -#line 1151 "../Slice/Grammar.y" +#line 1151 "Grammar.y" { - BoolTokPtr local = BoolTokPtr::dynamicCast(yyvsp[-6]); - StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); - StringListTokPtr metaData = StringListTokPtr::dynamicCast(yyvsp[-3]); - TypePtr type = TypePtr::dynamicCast(yyvsp[-2]); + BoolTokPtr local = BoolTokPtr::dynamicCast((yyvsp[(1) - (7)])); + StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(7) - (7)])); + StringListTokPtr metaData = StringListTokPtr::dynamicCast((yyvsp[(4) - (7)])); + TypePtr type = TypePtr::dynamicCast((yyvsp[(5) - (7)])); ContainerPtr cont = unit->currentContainer(); - yyval = cont->createSequence(ident->v, type, metaData->v, local->v); // Dummy + (yyval) = cont->createSequence(ident->v, type, metaData->v, local->v); // Dummy unit->error("keyword `" + ident->v + "' cannot be used as sequence name"); ;} break; case 103: -#line 1166 "../Slice/Grammar.y" - { - BoolTokPtr local = BoolTokPtr::dynamicCast(yyvsp[-9]); - StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); - StringListTokPtr keyMetaData = StringListTokPtr::dynamicCast(yyvsp[-6]); - TypePtr keyType = TypePtr::dynamicCast(yyvsp[-5]); - StringListTokPtr valueMetaData = StringListTokPtr::dynamicCast(yyvsp[-3]); - TypePtr valueType = TypePtr::dynamicCast(yyvsp[-2]); +#line 1166 "Grammar.y" + { + BoolTokPtr local = BoolTokPtr::dynamicCast((yyvsp[(1) - (10)])); + StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(10) - (10)])); + StringListTokPtr keyMetaData = StringListTokPtr::dynamicCast((yyvsp[(4) - (10)])); + TypePtr keyType = TypePtr::dynamicCast((yyvsp[(5) - (10)])); + StringListTokPtr valueMetaData = StringListTokPtr::dynamicCast((yyvsp[(7) - (10)])); + TypePtr valueType = TypePtr::dynamicCast((yyvsp[(8) - (10)])); ContainerPtr cont = unit->currentContainer(); - yyval = cont->createDictionary(ident->v, keyType, keyMetaData->v, valueType, valueMetaData->v, local->v); + (yyval) = cont->createDictionary(ident->v, keyType, keyMetaData->v, valueType, valueMetaData->v, local->v); ;} break; case 104: -#line 1177 "../Slice/Grammar.y" - { - BoolTokPtr local = BoolTokPtr::dynamicCast(yyvsp[-9]); - StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); - StringListTokPtr keyMetaData = StringListTokPtr::dynamicCast(yyvsp[-6]); - TypePtr keyType = TypePtr::dynamicCast(yyvsp[-5]); - StringListTokPtr valueMetaData = StringListTokPtr::dynamicCast(yyvsp[-3]); - TypePtr valueType = TypePtr::dynamicCast(yyvsp[-2]); +#line 1177 "Grammar.y" + { + BoolTokPtr local = BoolTokPtr::dynamicCast((yyvsp[(1) - (10)])); + StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(10) - (10)])); + StringListTokPtr keyMetaData = StringListTokPtr::dynamicCast((yyvsp[(4) - (10)])); + TypePtr keyType = TypePtr::dynamicCast((yyvsp[(5) - (10)])); + StringListTokPtr valueMetaData = StringListTokPtr::dynamicCast((yyvsp[(7) - (10)])); + TypePtr valueType = TypePtr::dynamicCast((yyvsp[(8) - (10)])); ContainerPtr cont = unit->currentContainer(); - yyval = cont->createDictionary(ident->v, keyType, keyMetaData->v, valueType, valueMetaData->v, local->v); // Dummy + (yyval) = cont->createDictionary(ident->v, keyType, keyMetaData->v, valueType, valueMetaData->v, local->v); // Dummy unit->error("keyword `" + ident->v + "' cannot be used as dictionary name"); ;} break; case 105: -#line 1194 "../Slice/Grammar.y" +#line 1194 "Grammar.y" { - yyval = yyvsp[0]; + (yyval) = (yyvsp[(2) - (2)]); ;} break; case 106: -#line 1198 "../Slice/Grammar.y" +#line 1198 "Grammar.y" { - StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); + StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(2) - (2)])); unit->error("keyword `" + ident->v + "' cannot be used as enumeration name"); - yyval = yyvsp[0]; // Dummy + (yyval) = (yyvsp[(2) - (2)]); // Dummy ;} break; case 107: -#line 1209 "../Slice/Grammar.y" +#line 1209 "Grammar.y" { - BoolTokPtr local = BoolTokPtr::dynamicCast(yyvsp[-1]); - StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); + BoolTokPtr local = BoolTokPtr::dynamicCast((yyvsp[(1) - (2)])); + StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(2) - (2)])); ContainerPtr cont = unit->currentContainer(); EnumPtr en = cont->createEnum(ident->v, local->v); cont->checkIntroduced(ident->v, en); - yyval = en; + (yyval) = en; ;} break; case 108: -#line 1218 "../Slice/Grammar.y" +#line 1218 "Grammar.y" { - EnumPtr en = EnumPtr::dynamicCast(yyvsp[-3]); + EnumPtr en = EnumPtr::dynamicCast((yyvsp[(3) - (6)])); if(en) { - EnumeratorListTokPtr enumerators = EnumeratorListTokPtr::dynamicCast(yyvsp[-1]); + EnumeratorListTokPtr enumerators = EnumeratorListTokPtr::dynamicCast((yyvsp[(5) - (6)])); if(enumerators->v.empty()) { unit->error("enum `" + en->name() + "' must have at least one enumerator"); } en->setEnumerators(enumerators->v); // Dummy } - yyval = yyvsp[-3]; + (yyval) = (yyvsp[(3) - (6)]); ;} break; case 109: -#line 1233 "../Slice/Grammar.y" +#line 1233 "Grammar.y" { unit->error("missing enumeration name"); - BoolTokPtr local = BoolTokPtr::dynamicCast(yyvsp[-4]); + BoolTokPtr local = BoolTokPtr::dynamicCast((yyvsp[(1) - (5)])); ContainerPtr cont = unit->currentContainer(); EnumPtr en = cont->createEnum(IceUtil::generateUUID(), local->v, Dummy); // Dummy - EnumeratorListTokPtr enumerators = EnumeratorListTokPtr::dynamicCast(yyvsp[-1]); + EnumeratorListTokPtr enumerators = EnumeratorListTokPtr::dynamicCast((yyvsp[(4) - (5)])); en->setEnumerators(enumerators->v); // Dummy - yyval = en; + (yyval) = en; ;} break; case 110: -#line 1248 "../Slice/Grammar.y" +#line 1248 "Grammar.y" { - EnumeratorListTokPtr ens = EnumeratorListTokPtr::dynamicCast(yyvsp[-2]); - ens->v.splice(ens->v.end(), EnumeratorListTokPtr::dynamicCast(yyvsp[0])->v); - yyval = ens; + EnumeratorListTokPtr ens = EnumeratorListTokPtr::dynamicCast((yyvsp[(1) - (3)])); + ens->v.splice(ens->v.end(), EnumeratorListTokPtr::dynamicCast((yyvsp[(3) - (3)]))->v); + (yyval) = ens; ;} break; case 111: -#line 1254 "../Slice/Grammar.y" +#line 1254 "Grammar.y" { ;} break; case 112: -#line 1262 "../Slice/Grammar.y" +#line 1262 "Grammar.y" { - StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); + StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(1) - (1)])); EnumeratorListTokPtr ens = new EnumeratorListTok; ContainerPtr cont = unit->currentContainer(); EnumeratorPtr en = cont->createEnumerator(ident->v); @@ -2733,57 +3064,57 @@ yyreduce: { ens->v.push_front(en); } - yyval = ens; + (yyval) = ens; ;} break; case 113: -#line 1274 "../Slice/Grammar.y" +#line 1274 "Grammar.y" { - StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); + StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(1) - (1)])); unit->error("keyword `" + ident->v + "' cannot be used as enumerator"); EnumeratorListTokPtr ens = new EnumeratorListTok; // Dummy - yyval = ens; + (yyval) = ens; ;} break; case 114: -#line 1281 "../Slice/Grammar.y" +#line 1281 "Grammar.y" { EnumeratorListTokPtr ens = new EnumeratorListTok; - yyval = ens; // Dummy + (yyval) = ens; // Dummy ;} break; case 115: -#line 1291 "../Slice/Grammar.y" +#line 1291 "Grammar.y" { BoolTokPtr out = new BoolTok; out->v = true; - yyval = out; + (yyval) = out; ;} break; case 116: -#line 1297 "../Slice/Grammar.y" +#line 1297 "Grammar.y" { BoolTokPtr out = new BoolTok; out->v = false; - yyval = out; + (yyval) = out; ;} break; case 117: -#line 1308 "../Slice/Grammar.y" +#line 1308 "Grammar.y" { ;} break; case 118: -#line 1311 "../Slice/Grammar.y" +#line 1311 "Grammar.y" { - BoolTokPtr isOutParam = BoolTokPtr::dynamicCast(yyvsp[-2]); - TypeStringTokPtr tsp = TypeStringTokPtr::dynamicCast(yyvsp[0]); + BoolTokPtr isOutParam = BoolTokPtr::dynamicCast((yyvsp[(1) - (3)])); + TypeStringTokPtr tsp = TypeStringTokPtr::dynamicCast((yyvsp[(3) - (3)])); TypePtr type = tsp->v.first; string ident = tsp->v.second; OperationPtr op = OperationPtr::dynamicCast(unit->currentContainer()); @@ -2791,7 +3122,7 @@ yyreduce: { ParamDeclPtr pd = op->createParamDecl(ident, type, isOutParam->v); unit->currentContainer()->checkIntroduced(ident, pd); - StringListTokPtr metaData = StringListTokPtr::dynamicCast(yyvsp[-1]); + StringListTokPtr metaData = StringListTokPtr::dynamicCast((yyvsp[(2) - (3)])); if(!metaData->v.empty()) { pd->setMetaData(metaData->v); @@ -2801,10 +3132,10 @@ yyreduce: break; case 119: -#line 1329 "../Slice/Grammar.y" +#line 1329 "Grammar.y" { - BoolTokPtr isOutParam = BoolTokPtr::dynamicCast(yyvsp[-2]); - TypeStringTokPtr tsp = TypeStringTokPtr::dynamicCast(yyvsp[0]); + BoolTokPtr isOutParam = BoolTokPtr::dynamicCast((yyvsp[(3) - (5)])); + TypeStringTokPtr tsp = TypeStringTokPtr::dynamicCast((yyvsp[(5) - (5)])); TypePtr type = tsp->v.first; string ident = tsp->v.second; OperationPtr op = OperationPtr::dynamicCast(unit->currentContainer()); @@ -2812,7 +3143,7 @@ yyreduce: { ParamDeclPtr pd = op->createParamDecl(ident, type, isOutParam->v); unit->currentContainer()->checkIntroduced(ident, pd); - StringListTokPtr metaData = StringListTokPtr::dynamicCast(yyvsp[-1]); + StringListTokPtr metaData = StringListTokPtr::dynamicCast((yyvsp[(4) - (5)])); if(!metaData->v.empty()) { pd->setMetaData(metaData->v); @@ -2822,11 +3153,11 @@ yyreduce: break; case 120: -#line 1347 "../Slice/Grammar.y" +#line 1347 "Grammar.y" { - BoolTokPtr isOutParam = BoolTokPtr::dynamicCast(yyvsp[-3]); - TypePtr type = TypePtr::dynamicCast(yyvsp[-1]); - StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); + BoolTokPtr isOutParam = BoolTokPtr::dynamicCast((yyvsp[(1) - (4)])); + TypePtr type = TypePtr::dynamicCast((yyvsp[(3) - (4)])); + StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(4) - (4)])); OperationPtr op = OperationPtr::dynamicCast(unit->currentContainer()); if(op) { @@ -2837,11 +3168,11 @@ yyreduce: break; case 121: -#line 1359 "../Slice/Grammar.y" +#line 1359 "Grammar.y" { - BoolTokPtr isOutParam = BoolTokPtr::dynamicCast(yyvsp[-3]); - TypePtr type = TypePtr::dynamicCast(yyvsp[-1]); - StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); + BoolTokPtr isOutParam = BoolTokPtr::dynamicCast((yyvsp[(3) - (6)])); + TypePtr type = TypePtr::dynamicCast((yyvsp[(5) - (6)])); + StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(6) - (6)])); OperationPtr op = OperationPtr::dynamicCast(unit->currentContainer()); if(op) { @@ -2852,10 +3183,10 @@ yyreduce: break; case 122: -#line 1371 "../Slice/Grammar.y" +#line 1371 "Grammar.y" { - BoolTokPtr isOutParam = BoolTokPtr::dynamicCast(yyvsp[-2]); - TypePtr type = TypePtr::dynamicCast(yyvsp[0]); + BoolTokPtr isOutParam = BoolTokPtr::dynamicCast((yyvsp[(1) - (3)])); + TypePtr type = TypePtr::dynamicCast((yyvsp[(3) - (3)])); OperationPtr op = OperationPtr::dynamicCast(unit->currentContainer()); if(op) { @@ -2866,10 +3197,10 @@ yyreduce: break; case 123: -#line 1382 "../Slice/Grammar.y" +#line 1382 "Grammar.y" { - BoolTokPtr isOutParam = BoolTokPtr::dynamicCast(yyvsp[-2]); - TypePtr type = TypePtr::dynamicCast(yyvsp[0]); + BoolTokPtr isOutParam = BoolTokPtr::dynamicCast((yyvsp[(3) - (5)])); + TypePtr type = TypePtr::dynamicCast((yyvsp[(5) - (5)])); OperationPtr op = OperationPtr::dynamicCast(unit->currentContainer()); if(op) { @@ -2880,126 +3211,126 @@ yyreduce: break; case 124: -#line 1398 "../Slice/Grammar.y" +#line 1398 "Grammar.y" { - yyval = yyvsp[0]; + (yyval) = (yyvsp[(2) - (2)]); ;} break; case 125: -#line 1402 "../Slice/Grammar.y" +#line 1402 "Grammar.y" { - yyval = new ExceptionListTok; + (yyval) = new ExceptionListTok; ;} break; case 126: -#line 1411 "../Slice/Grammar.y" +#line 1411 "Grammar.y" { ;} break; case 127: -#line 1414 "../Slice/Grammar.y" +#line 1414 "Grammar.y" { - StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); + StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(2) - (2)])); ident->v = "::" + ident->v; - yyval = ident; + (yyval) = ident; ;} break; case 128: -#line 1420 "../Slice/Grammar.y" +#line 1420 "Grammar.y" { - StringTokPtr scoped = StringTokPtr::dynamicCast(yyvsp[-2]); - StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); + StringTokPtr scoped = StringTokPtr::dynamicCast((yyvsp[(1) - (3)])); + StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(3) - (3)])); scoped->v += "::"; scoped->v += ident->v; - yyval = scoped; + (yyval) = scoped; ;} break; case 129: -#line 1433 "../Slice/Grammar.y" +#line 1433 "Grammar.y" { - yyval = unit->builtin(Builtin::KindByte); + (yyval) = unit->builtin(Builtin::KindByte); ;} break; case 130: -#line 1437 "../Slice/Grammar.y" +#line 1437 "Grammar.y" { - yyval = unit->builtin(Builtin::KindBool); + (yyval) = unit->builtin(Builtin::KindBool); ;} break; case 131: -#line 1441 "../Slice/Grammar.y" +#line 1441 "Grammar.y" { - yyval = unit->builtin(Builtin::KindShort); + (yyval) = unit->builtin(Builtin::KindShort); ;} break; case 132: -#line 1445 "../Slice/Grammar.y" +#line 1445 "Grammar.y" { - yyval = unit->builtin(Builtin::KindInt); + (yyval) = unit->builtin(Builtin::KindInt); ;} break; case 133: -#line 1449 "../Slice/Grammar.y" +#line 1449 "Grammar.y" { - yyval = unit->builtin(Builtin::KindLong); + (yyval) = unit->builtin(Builtin::KindLong); ;} break; case 134: -#line 1453 "../Slice/Grammar.y" +#line 1453 "Grammar.y" { - yyval = unit->builtin(Builtin::KindFloat); + (yyval) = unit->builtin(Builtin::KindFloat); ;} break; case 135: -#line 1457 "../Slice/Grammar.y" +#line 1457 "Grammar.y" { - yyval = unit->builtin(Builtin::KindDouble); + (yyval) = unit->builtin(Builtin::KindDouble); ;} break; case 136: -#line 1461 "../Slice/Grammar.y" +#line 1461 "Grammar.y" { - yyval = unit->builtin(Builtin::KindString); + (yyval) = unit->builtin(Builtin::KindString); ;} break; case 137: -#line 1465 "../Slice/Grammar.y" +#line 1465 "Grammar.y" { - yyval = unit->builtin(Builtin::KindObject); + (yyval) = unit->builtin(Builtin::KindObject); ;} break; case 138: -#line 1469 "../Slice/Grammar.y" +#line 1469 "Grammar.y" { - yyval = unit->builtin(Builtin::KindObjectProxy); + (yyval) = unit->builtin(Builtin::KindObjectProxy); ;} break; case 139: -#line 1473 "../Slice/Grammar.y" +#line 1473 "Grammar.y" { - yyval = unit->builtin(Builtin::KindLocalObject); + (yyval) = unit->builtin(Builtin::KindLocalObject); ;} break; case 140: -#line 1477 "../Slice/Grammar.y" +#line 1477 "Grammar.y" { - StringTokPtr scoped = StringTokPtr::dynamicCast(yyvsp[0]); + StringTokPtr scoped = StringTokPtr::dynamicCast((yyvsp[(1) - (1)])); ContainerPtr cont = unit->currentContainer(); if(cont) { @@ -3009,19 +3340,19 @@ yyreduce: YYERROR; // Can't continue, jump to next yyerrok } cont->checkIntroduced(scoped->v); - yyval = types.front(); + (yyval) = types.front(); } else { - yyval = 0; + (yyval) = 0; } ;} break; case 141: -#line 1496 "../Slice/Grammar.y" +#line 1496 "Grammar.y" { - StringTokPtr scoped = StringTokPtr::dynamicCast(yyvsp[-1]); + StringTokPtr scoped = StringTokPtr::dynamicCast((yyvsp[(1) - (2)])); ContainerPtr cont = unit->currentContainer(); if(cont) { @@ -3048,73 +3379,73 @@ yyreduce: } *p = new Proxy(cl); } - yyval = types.front(); + (yyval) = types.front(); } else { - yyval = 0; + (yyval) = 0; } ;} break; case 142: -#line 1537 "../Slice/Grammar.y" +#line 1537 "Grammar.y" { - StringTokPtr str1 = StringTokPtr::dynamicCast(yyvsp[-1]); - StringTokPtr str2 = StringTokPtr::dynamicCast(yyvsp[0]); + StringTokPtr str1 = StringTokPtr::dynamicCast((yyvsp[(1) - (2)])); + StringTokPtr str2 = StringTokPtr::dynamicCast((yyvsp[(2) - (2)])); str1->v += str2->v; ;} break; case 143: -#line 1543 "../Slice/Grammar.y" +#line 1543 "Grammar.y" { ;} break; case 144: -#line 1551 "../Slice/Grammar.y" +#line 1551 "Grammar.y" { - StringTokPtr str = StringTokPtr::dynamicCast(yyvsp[0]); - StringListTokPtr stringList = StringListTokPtr::dynamicCast(yyvsp[-2]); + StringTokPtr str = StringTokPtr::dynamicCast((yyvsp[(3) - (3)])); + StringListTokPtr stringList = StringListTokPtr::dynamicCast((yyvsp[(1) - (3)])); stringList->v.push_back(str->v); - yyval = stringList; + (yyval) = stringList; ;} break; case 145: -#line 1558 "../Slice/Grammar.y" +#line 1558 "Grammar.y" { - StringTokPtr str = StringTokPtr::dynamicCast(yyvsp[0]); + StringTokPtr str = StringTokPtr::dynamicCast((yyvsp[(1) - (1)])); StringListTokPtr stringList = new StringListTok; stringList->v.push_back(str->v); - yyval = stringList; + (yyval) = stringList; ;} break; case 146: -#line 1570 "../Slice/Grammar.y" +#line 1570 "Grammar.y" { BoolTokPtr local = new BoolTok; local->v = true; - yyval = local; + (yyval) = local; ;} break; case 147: -#line 1576 "../Slice/Grammar.y" +#line 1576 "Grammar.y" { BoolTokPtr local = new BoolTok; local->v = false; - yyval = local; + (yyval) = local; ;} break; case 148: -#line 1587 "../Slice/Grammar.y" +#line 1587 "Grammar.y" { BuiltinPtr type = unit->builtin(Builtin::KindLong); - IntegerTokPtr intVal = IntegerTokPtr::dynamicCast(yyvsp[0]); + IntegerTokPtr intVal = IntegerTokPtr::dynamicCast((yyvsp[(1) - (1)])); ostringstream sstr; sstr << intVal->v; ConstDefTokPtr def = new ConstDefTok; @@ -3122,15 +3453,15 @@ yyreduce: def->v.value = type; def->v.valueAsString = sstr.str(); def->v.valueAsLiteral = intVal->literal; - yyval = def; + (yyval) = def; ;} break; case 149: -#line 1600 "../Slice/Grammar.y" +#line 1600 "Grammar.y" { BuiltinPtr type = unit->builtin(Builtin::KindDouble); - FloatingTokPtr floatVal = FloatingTokPtr::dynamicCast(yyvsp[0]); + FloatingTokPtr floatVal = FloatingTokPtr::dynamicCast((yyvsp[(1) - (1)])); ostringstream sstr; sstr << floatVal->v; ConstDefTokPtr def = new ConstDefTok; @@ -3138,14 +3469,14 @@ yyreduce: def->v.value = type; def->v.valueAsString = sstr.str(); def->v.valueAsLiteral = floatVal->literal; - yyval = def; + (yyval) = def; ;} break; case 150: -#line 1613 "../Slice/Grammar.y" +#line 1613 "Grammar.y" { - StringTokPtr scoped = StringTokPtr::dynamicCast(yyvsp[0]); + StringTokPtr scoped = StringTokPtr::dynamicCast((yyvsp[(1) - (1)])); ConstDefTokPtr def = new ConstDefTok; ContainedList cl = unit->currentContainer()->lookupContained(scoped->v); if(cl.empty()) @@ -3176,261 +3507,260 @@ yyreduce: def->v.valueAsString = scoped->v; def->v.valueAsLiteral = scoped->v; } - yyval = def; + (yyval) = def; ;} break; case 151: -#line 1648 "../Slice/Grammar.y" +#line 1648 "Grammar.y" { BuiltinPtr type = unit->builtin(Builtin::KindString); - StringTokPtr literal = StringTokPtr::dynamicCast(yyvsp[0]); + StringTokPtr literal = StringTokPtr::dynamicCast((yyvsp[(1) - (1)])); ConstDefTokPtr def = new ConstDefTok; def->v.type = type; def->v.value = type; def->v.valueAsString = literal->v; def->v.valueAsLiteral = literal->literal; - yyval = def; + (yyval) = def; ;} break; case 152: -#line 1659 "../Slice/Grammar.y" +#line 1659 "Grammar.y" { BuiltinPtr type = unit->builtin(Builtin::KindBool); - StringTokPtr literal = StringTokPtr::dynamicCast(yyvsp[0]); + StringTokPtr literal = StringTokPtr::dynamicCast((yyvsp[(1) - (1)])); ConstDefTokPtr def = new ConstDefTok; def->v.type = type; def->v.value = type; def->v.valueAsString = literal->v; def->v.valueAsLiteral = "false"; - yyval = def; + (yyval) = def; ;} break; case 153: -#line 1670 "../Slice/Grammar.y" +#line 1670 "Grammar.y" { BuiltinPtr type = unit->builtin(Builtin::KindBool); - StringTokPtr literal = StringTokPtr::dynamicCast(yyvsp[0]); + StringTokPtr literal = StringTokPtr::dynamicCast((yyvsp[(1) - (1)])); ConstDefTokPtr def = new ConstDefTok; def->v.type = type; def->v.value = type; def->v.valueAsString = literal->v; def->v.valueAsLiteral = "true"; - yyval = def; + (yyval) = def; ;} break; case 154: -#line 1686 "../Slice/Grammar.y" +#line 1686 "Grammar.y" { - StringListTokPtr metaData = StringListTokPtr::dynamicCast(yyvsp[-4]); - TypePtr const_type = TypePtr::dynamicCast(yyvsp[-3]); - StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[-2]); - ConstDefTokPtr value = ConstDefTokPtr::dynamicCast(yyvsp[0]); - yyval = unit->currentContainer()->createConst(ident->v, const_type, metaData->v, + StringListTokPtr metaData = StringListTokPtr::dynamicCast((yyvsp[(2) - (6)])); + TypePtr const_type = TypePtr::dynamicCast((yyvsp[(3) - (6)])); + StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(4) - (6)])); + ConstDefTokPtr value = ConstDefTokPtr::dynamicCast((yyvsp[(6) - (6)])); + (yyval) = unit->currentContainer()->createConst(ident->v, const_type, metaData->v, value->v.value, value->v.valueAsString, value->v.valueAsLiteral); ;} break; case 155: -#line 1695 "../Slice/Grammar.y" +#line 1695 "Grammar.y" { - StringListTokPtr metaData = StringListTokPtr::dynamicCast(yyvsp[-3]); - TypePtr const_type = TypePtr::dynamicCast(yyvsp[-2]); - ConstDefTokPtr value = ConstDefTokPtr::dynamicCast(yyvsp[0]); + StringListTokPtr metaData = StringListTokPtr::dynamicCast((yyvsp[(2) - (5)])); + TypePtr const_type = TypePtr::dynamicCast((yyvsp[(3) - (5)])); + ConstDefTokPtr value = ConstDefTokPtr::dynamicCast((yyvsp[(5) - (5)])); unit->error("missing constant name"); - yyval = unit->currentContainer()->createConst(IceUtil::generateUUID(), const_type, metaData->v, + (yyval) = unit->currentContainer()->createConst(IceUtil::generateUUID(), const_type, metaData->v, value->v.value, value->v.valueAsString, value->v.valueAsLiteral, Dummy); // Dummy ;} break; case 156: -#line 1710 "../Slice/Grammar.y" +#line 1710 "Grammar.y" { ;} break; case 157: -#line 1713 "../Slice/Grammar.y" +#line 1713 "Grammar.y" { ;} break; case 158: -#line 1716 "../Slice/Grammar.y" +#line 1716 "Grammar.y" { ;} break; case 159: -#line 1719 "../Slice/Grammar.y" +#line 1719 "Grammar.y" { ;} break; case 160: -#line 1722 "../Slice/Grammar.y" +#line 1722 "Grammar.y" { ;} break; case 161: -#line 1725 "../Slice/Grammar.y" +#line 1725 "Grammar.y" { ;} break; case 162: -#line 1728 "../Slice/Grammar.y" +#line 1728 "Grammar.y" { ;} break; case 163: -#line 1731 "../Slice/Grammar.y" +#line 1731 "Grammar.y" { ;} break; case 164: -#line 1734 "../Slice/Grammar.y" +#line 1734 "Grammar.y" { ;} break; case 165: -#line 1737 "../Slice/Grammar.y" +#line 1737 "Grammar.y" { ;} break; case 166: -#line 1740 "../Slice/Grammar.y" +#line 1740 "Grammar.y" { ;} break; case 167: -#line 1743 "../Slice/Grammar.y" +#line 1743 "Grammar.y" { ;} break; case 168: -#line 1746 "../Slice/Grammar.y" +#line 1746 "Grammar.y" { ;} break; case 169: -#line 1749 "../Slice/Grammar.y" +#line 1749 "Grammar.y" { ;} break; case 170: -#line 1752 "../Slice/Grammar.y" +#line 1752 "Grammar.y" { ;} break; case 171: -#line 1755 "../Slice/Grammar.y" +#line 1755 "Grammar.y" { ;} break; case 172: -#line 1758 "../Slice/Grammar.y" +#line 1758 "Grammar.y" { ;} break; case 173: -#line 1761 "../Slice/Grammar.y" +#line 1761 "Grammar.y" { ;} break; case 174: -#line 1764 "../Slice/Grammar.y" +#line 1764 "Grammar.y" { ;} break; case 175: -#line 1767 "../Slice/Grammar.y" +#line 1767 "Grammar.y" { ;} break; case 176: -#line 1770 "../Slice/Grammar.y" +#line 1770 "Grammar.y" { ;} break; case 177: -#line 1773 "../Slice/Grammar.y" +#line 1773 "Grammar.y" { ;} break; case 178: -#line 1776 "../Slice/Grammar.y" +#line 1776 "Grammar.y" { ;} break; case 179: -#line 1779 "../Slice/Grammar.y" +#line 1779 "Grammar.y" { ;} break; case 180: -#line 1782 "../Slice/Grammar.y" +#line 1782 "Grammar.y" { ;} break; case 181: -#line 1785 "../Slice/Grammar.y" +#line 1785 "Grammar.y" { ;} break; case 182: -#line 1788 "../Slice/Grammar.y" +#line 1788 "Grammar.y" { ;} break; case 183: -#line 1791 "../Slice/Grammar.y" +#line 1791 "Grammar.y" { ;} break; case 184: -#line 1794 "../Slice/Grammar.y" +#line 1794 "Grammar.y" { ;} break; +/* Line 1267 of yacc.c. */ +#line 3758 "Grammar.tab.c" + default: break; } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); -/* Line 1000 of yacc.c. */ -#line 3429 "Grammar.tab.c" - - yyvsp -= yylen; - yyssp -= yylen; - - + YYPOPSTACK (yylen); + yylen = 0; YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; @@ -3459,99 +3789,65 @@ yyerrlab: if (!yyerrstatus) { ++yynerrs; -#if YYERROR_VERBOSE - yyn = yypact[yystate]; - - if (YYPACT_NINF < yyn && yyn < YYLAST) - { - YYSIZE_T yysize = 0; - int yytype = YYTRANSLATE (yychar); - const char* yyprefix; - char *yymsg; - int yyx; - - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yycount = 0; - - yyprefix = ", expecting "; - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) +#if ! YYERROR_VERBOSE + yyerror (YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else { - yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]); - yycount += 1; - if (yycount == 5) - { - yysize = 0; - break; - } + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; } - yysize += (sizeof ("syntax error, unexpected ") - + yystrlen (yytname[yytype])); - yymsg = (char *) YYSTACK_ALLOC (yysize); - if (yymsg != 0) - { - char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); - yyp = yystpcpy (yyp, yytname[yytype]); + } - if (yycount < 5) - { - yyprefix = ", expecting "; - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - { - yyp = yystpcpy (yyp, yyprefix); - yyp = yystpcpy (yyp, yytname[yyx]); - yyprefix = " or "; - } - } - yyerror (yymsg); - YYSTACK_FREE (yymsg); - } - else - yyerror ("syntax error; also virtual memory exhausted"); - } - else -#endif /* YYERROR_VERBOSE */ - yyerror ("syntax error"); + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (yymsg); + } + else + { + yyerror (YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif } if (yyerrstatus == 3) { - /* If just tried and failed to reuse lookahead token after an + /* If just tried and failed to reuse look-ahead token after an error, discard it. */ if (yychar <= YYEOF) - { - /* If at end of input, pop the error token, - then the rest of the stack, then return failure. */ + { + /* Return failure if at end of input. */ if (yychar == YYEOF) - for (;;) - { - YYPOPSTACK; - if (yyssp == yyss) - YYABORT; - YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); - yydestruct (yystos[*yyssp], yyvsp); - } - } + YYABORT; + } else { - YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); - yydestruct (yytoken, &yylval); + yydestruct ("Error: discarding", + yytoken, &yylval); yychar = YYEMPTY; - } } - /* Else will try to reuse lookahead token after shifting the error + /* Else will try to reuse look-ahead token after shifting the error token. */ goto yyerrlab1; @@ -3561,15 +3857,17 @@ yyerrlab: `---------------------------------------------------*/ yyerrorlab: -#ifdef __GNUC__ - /* Pacify GCC when the user code never invokes YYERROR and the label - yyerrorlab therefore never appears in user code. */ - if (0) + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) goto yyerrorlab; -#endif - yyvsp -= yylen; - yyssp -= yylen; + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); yystate = *yyssp; goto yyerrlab1; @@ -3598,9 +3896,10 @@ yyerrlab1: if (yyssp == yyss) YYABORT; - YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); - yydestruct (yystos[yystate], yyvsp); - YYPOPSTACK; + + yydestruct ("Error: popping", + yystos[yystate], yyvsp); + YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); } @@ -3608,11 +3907,12 @@ yyerrlab1: if (yyn == YYFINAL) YYACCEPT; - YYDPRINTF ((stderr, "Shifting error token, ")); - *++yyvsp = yylval; + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + yystate = yyn; goto yynewstate; @@ -3632,24 +3932,42 @@ yyabortlab: goto yyreturn; #ifndef yyoverflow -/*----------------------------------------------. -| yyoverflowlab -- parser overflow comes here. | -`----------------------------------------------*/ -yyoverflowlab: - yyerror ("parser stack overflow"); +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (YY_("memory exhausted")); yyresult = 2; /* Fall through. */ #endif yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp); + YYPOPSTACK (1); + } #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); #endif - return yyresult; +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); } -#line 1798 "../Slice/Grammar.y" +#line 1798 "Grammar.y" diff --git a/cpp/src/Slice/Grammar.h b/cpp/src/Slice/Grammar.h index 08d77ed6fa6..a7ad3a24642 100644 --- a/cpp/src/Slice/Grammar.h +++ b/cpp/src/Slice/Grammar.h @@ -1,7 +1,9 @@ -/* A Bison parser, made by GNU Bison 1.875c. */ +/* A Bison parser, made by GNU Bison 2.3. */ -/* Skeleton parser for Yacc-like parsing with Bison, - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -15,13 +17,21 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ /* Tokens. */ #ifndef YYTOKENTYPE @@ -72,6 +82,7 @@ BAD_CHAR = 298 }; #endif +/* Tokens. */ #define ICE_MODULE 258 #define ICE_CLASS 259 #define ICE_INTERFACE 260 @@ -117,7 +128,7 @@ -#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef int YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 @@ -126,5 +137,3 @@ typedef int YYSTYPE; - - diff --git a/cpp/src/Slice/Grammar.y b/cpp/src/Slice/Grammar.y index cc682a336ad..6e338ee3f73 100644 --- a/cpp/src/Slice/Grammar.y +++ b/cpp/src/Slice/Grammar.y @@ -149,7 +149,6 @@ definitions { contained->setMetaData(metaData->v); } - unit->setSeenDefinition(); } ';' definitions | error ';' @@ -228,6 +227,7 @@ module_def // ---------------------------------------------------------------------- : ICE_MODULE ICE_IDENTIFIER { + unit->setSeenDefinition(); StringTokPtr ident = StringTokPtr::dynamicCast($2); ContainerPtr cont = unit->currentContainer(); ModulePtr module = cont->createModule(ident->v); diff --git a/cpp/src/Slice/JavaUtil.cpp b/cpp/src/Slice/JavaUtil.cpp index b67f36055a4..e1ca7fdbba0 100644 --- a/cpp/src/Slice/JavaUtil.cpp +++ b/cpp/src/Slice/JavaUtil.cpp @@ -10,6 +10,7 @@ #include <IceUtil/DisableWarnings.h> #include <Slice/JavaUtil.h> #include <Slice/FileTracker.h> +#include <Slice/Util.h> #include <IceUtil/Functional.h> #include <IceUtil/DisableWarnings.h> @@ -371,25 +372,44 @@ Slice::JavaGenerator::convertScopedName(const string& scoped, const string& pref } string +Slice::JavaGenerator::getPackagePrefix(const ContainedPtr& cont) const +{ + UnitPtr unit = cont->container()->unit(); + string file = cont->file(); + assert(!file.empty()); + + map<string, string>::const_iterator p = _filePackagePrefix.find(file); + if(p != _filePackagePrefix.end()) + { + return p->second; + } + + static const string prefix = "java:package:"; + DefinitionContextPtr dc = unit->findDefinitionContext(file); + assert(dc); + string q = dc->findMetaData(prefix); + if(!q.empty()) + { + q = q.substr(prefix.size()); + } + _filePackagePrefix[file] = q; + return q; +} + +string Slice::JavaGenerator::getPackage(const ContainedPtr& cont) const { string scope = convertScopedName(cont->scope()); - - DefinitionContextPtr dc = cont->definitionContext(); - if(dc) + string prefix = getPackagePrefix(cont); + if(!prefix.empty()) { - static const string prefix = "java:package:"; - string package = dc->findMetaData(prefix); - if(!package.empty()) + if(!scope.empty()) { - if(!scope.empty()) - { - return package.substr(prefix.size()) + "." + scope; - } - else - { - return package.substr(prefix.size()); - } + return prefix + "." + scope; + } + else + { + return prefix; } } @@ -550,6 +570,22 @@ Slice::JavaGenerator::typeToString(const TypePtr& type, } else { + BuiltinPtr builtin = BuiltinPtr::dynamicCast(seq->type()); + if(builtin && builtin->kind() == Builtin::KindByte) + { + string prefix = "java:serializable:"; + string meta; + if(seq->findMetaData(prefix, meta)) + { + return string("Ice.Holder<") + meta.substr(prefix.size()) + " >"; + } + prefix = "java:protobuf:"; + if(seq->findMetaData(prefix, meta)) + { + return string("Ice.Holder<") + meta.substr(prefix.size()) + " >"; + } + } + // // Only use the type's generated holder if the instance and // formal types match. @@ -594,6 +630,22 @@ Slice::JavaGenerator::typeToString(const TypePtr& type, } else { + BuiltinPtr builtin = BuiltinPtr::dynamicCast(seq->type()); + if(builtin && builtin->kind() == Builtin::KindByte) + { + string prefix = "java:serializable:"; + string meta; + if(seq->findMetaData(prefix, meta)) + { + return meta.substr(prefix.size()); + } + prefix = "java:protobuf:"; + if(seq->findMetaData(prefix, meta)) + { + return meta.substr(prefix.size()); + } + } + string instanceType, formalType; getSequenceTypes(seq, package, metaData, instanceType, formalType); return formal ? formalType : instanceType; @@ -1240,15 +1292,64 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out, { string stream = marshal ? "__os" : "__is"; string v = param; + bool java2 = seq->definitionContext()->findMetaData(_java2MetaData) == _java2MetaData; + + // + // If the sequence is a byte sequence, check if there's the serializable or protobuf metadata to + // get rid of these two easy cases first. + // + BuiltinPtr builtin = BuiltinPtr::dynamicCast(seq->type()); + if(builtin && builtin->kind() == Builtin::KindByte) + { + string meta; + static const string protobuf = "java:protobuf:"; + static const string serializable = "java:serializable:"; + if(seq->findMetaData(serializable, meta)) + { + if(marshal) + { + out << nl << stream << ".writeSerializable(" << v << ");"; + } + else + { + string type = typeToString(seq, TypeModeIn, package); + out << nl << v << " = (" << type << ")" << stream << ".readSerializable();"; + } + return; + } + else if(seq->findMetaData(protobuf, meta)) + { + if(marshal) + { + out << nl << "if(!" << v << ".isInitialized())"; + out << sb; + out << nl << "throw new Ice.MarshalException(\"type not fully initialized\");"; + out << eb; + out << nl << stream << ".writeByteSeq(" << v << ".toByteArray());"; + } + else + { + string type = typeToString(seq, TypeModeIn, package); + out << nl << "try"; + out << sb; + out << nl << v << " = " << type << ".parseFrom(" << stream << ".readByteSeq());"; + out << eb; + out << nl << "catch(com.google.protobuf.InvalidProtocolBufferException __ex)"; + out << sb; + out << nl << "Ice.MarshalException __mex = new Ice.MarshalException();"; + out << nl << "__mex.initCause(__ex);"; + out << nl << "throw __mex;"; + out << eb; + } + return; + } + } - bool java2 = false; bool customType = false; string instanceType; if(_featureProfile != Slice::IceE) { - java2 = seq->definitionContext()->findMetaData(_java2MetaData) == _java2MetaData; - // // We have to determine whether it's possible to use the // type's generated helper class for this marshal/unmarshal @@ -1299,7 +1400,7 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out, while(s) { // - // Stop if the inner sequence type has a custom type. + // Stop if the inner sequence type has a custom, serializable or protobuf type. // if(hasTypeMetaData(s) && _featureProfile != Slice::IceE) { @@ -2495,10 +2596,60 @@ Slice::JavaGenerator::writeStreamSequenceMarshalUnmarshalCode(Output& out, { string stream = marshal ? "__outS" : "__inS"; string v = param; - bool java2 = seq->definitionContext()->findMetaData(_java2MetaData) == _java2MetaData; // + // If the sequence is a byte sequence, check if there's the serializable or protobuf metadata to + // get rid of these two easy cases first. + // + BuiltinPtr builtin = BuiltinPtr::dynamicCast(seq->type()); + if(builtin && builtin->kind() == Builtin::KindByte) + { + string meta; + static const string protobuf = "java:protobuf:"; + static const string serializable = "java:serializable:"; + if(seq->findMetaData(serializable, meta)) + { + if(marshal) + { + out << nl << stream << ".writeSerializable(" << v << ");"; + } + else + { + string type = typeToString(seq, TypeModeIn, package); + out << nl << v << " = (" << type << ")" << stream << ".readSerializable();"; + } + return; + } + else if(seq->findMetaData(protobuf, meta)) + { + if(marshal) + { + out << nl << "if(!" << v << ".isInitialized())"; + out << sb; + out << nl << "throw new Ice.MarshalException(\"type not fully initialized\");"; + out << eb; + out << nl << stream << ".writeByteSeq(" << v << ".toByteArray());"; + } + else + { + string type = meta.substr(protobuf.size()); + out << nl << "try"; + out << sb; + out << nl << v << " = " << type << ".parseFrom(" << stream << ".readByteSeq());"; + out << eb; + out << nl << "catch(com.google.protobuf.InvalidProtocolBufferException __ex)"; + out << sb; + out << nl << "Ice.MarshalException __mex = new Ice.MarshalException();"; + out << nl << "__mex.initCause(__ex);"; + out << nl << "throw __mex;"; + out << eb; + } + return; + } + } + + // // We have to determine whether it's possible to use the // type's generated helper class for this marshal/unmarshal // task. Since the user may have specified a custom type in @@ -2547,7 +2698,7 @@ Slice::JavaGenerator::writeStreamSequenceMarshalUnmarshalCode(Output& out, while(s) { // - // Stop if the inner sequence type has a custom type. + // Stop if the inner sequence type has a custom, serializable or protobuf type. // if(hasTypeMetaData(s)) { @@ -3144,6 +3295,18 @@ Slice::JavaGenerator::hasTypeMetaData(const TypePtr& type, const StringList& loc { return true; } + else if(str.find("java:protobuf:") == 0 || str.find("java:serializable:") == 0) + { + SequencePtr seq = SequencePtr::dynamicCast(cont); + if(seq) + { + BuiltinPtr builtin = BuiltinPtr::dynamicCast(seq->type()); + if(builtin && builtin->kind() == Builtin::KindByte) + { + return true; + } + } + } } } @@ -3391,51 +3554,62 @@ Slice::JavaGenerator::validateMetaData(const UnitPtr& u) } bool -Slice::JavaGenerator::MetaDataVisitor::visitModuleStart(const ModulePtr& p) +Slice::JavaGenerator::MetaDataVisitor::visitUnitStart(const UnitPtr& p) { + static const string prefix = "java:"; + // - // Validate global metadata. + // Validate global metadata in the top-level file and all included files. // - DefinitionContextPtr dc = p->definitionContext(); - assert(dc); - StringList globalMetaData = dc->getMetaData(); - string file = dc->filename(); - static const string prefix = "java:"; - for(StringList::const_iterator q = globalMetaData.begin(); q != globalMetaData.end(); ++q) + StringList files = p->allFiles(); + + for(StringList::iterator q = files.begin(); q != files.end(); ++q) { - string s = *q; - if(_history.count(s) == 0) + string file = *q; + DefinitionContextPtr dc = p->findDefinitionContext(file); + assert(dc); + StringList globalMetaData = dc->getMetaData(); + for(StringList::const_iterator r = globalMetaData.begin(); r != globalMetaData.end(); ++r) { - if(s.find(prefix) == 0) + string s = *r; + if(_history.count(s) == 0) { - bool ok = false; - - static const string packagePrefix = "java:package:"; - if(s.find(packagePrefix) == 0 && s.size() > packagePrefix.size()) - { - ok = true; - } - else if(s == _java2MetaData) + if(s.find(prefix) == 0) { - ok = true; - } - else if(s == _java5MetaData) - { - ok = true; - } + bool ok = false; - if(!ok) - { - cerr << file << ": warning: ignoring invalid global metadata `" << s << "'" << endl; + static const string packagePrefix = "java:package:"; + if(s.find(packagePrefix) == 0 && s.size() > packagePrefix.size()) + { + ok = true; + } + else if(s == _java2MetaData) + { + ok = true; + } + else if(s == _java5MetaData) + { + ok = true; + } + + if(!ok) + { + emitWarning(file, "", "ignoring invalid global metadata `" + s + "'"); + } } + _history.insert(s); } - _history.insert(s); } } + return true; +} +bool +Slice::JavaGenerator::MetaDataVisitor::visitModuleStart(const ModulePtr& p) +{ StringList metaData = getMetaData(p); - validateType(p, metaData, p->definitionContext()->filename(), p->line()); - validateGetSet(p, metaData, p->definitionContext()->filename(), p->line()); + validateType(p, metaData, p->file(), p->line()); + validateGetSet(p, metaData, p->file(), p->line()); return true; } @@ -3443,16 +3617,16 @@ void Slice::JavaGenerator::MetaDataVisitor::visitClassDecl(const ClassDeclPtr& p) { StringList metaData = getMetaData(p); - validateType(p, metaData, p->definitionContext()->filename(), p->line()); - validateGetSet(p, metaData, p->definitionContext()->filename(), p->line()); + validateType(p, metaData, p->file(), p->line()); + validateGetSet(p, metaData, p->file(), p->line()); } bool Slice::JavaGenerator::MetaDataVisitor::visitClassDefStart(const ClassDefPtr& p) { StringList metaData = getMetaData(p); - validateType(p, metaData, p->definitionContext()->filename(), p->line()); - validateGetSet(p, metaData, p->definitionContext()->filename(), p->line()); + validateType(p, metaData, p->file(), p->line()); + validateGetSet(p, metaData, p->file(), p->line()); return true; } @@ -3460,8 +3634,8 @@ bool Slice::JavaGenerator::MetaDataVisitor::visitExceptionStart(const ExceptionPtr& p) { StringList metaData = getMetaData(p); - validateType(p, metaData, p->definitionContext()->filename(), p->line()); - validateGetSet(p, metaData, p->definitionContext()->filename(), p->line()); + validateType(p, metaData, p->file(), p->line()); + validateGetSet(p, metaData, p->file(), p->line()); return true; } @@ -3469,8 +3643,8 @@ bool Slice::JavaGenerator::MetaDataVisitor::visitStructStart(const StructPtr& p) { StringList metaData = getMetaData(p); - validateType(p, metaData, p->definitionContext()->filename(), p->line()); - validateGetSet(p, metaData, p->definitionContext()->filename(), p->line()); + validateType(p, metaData, p->file(), p->line()); + validateGetSet(p, metaData, p->file(), p->line()); return true; } @@ -3482,10 +3656,11 @@ Slice::JavaGenerator::MetaDataVisitor::visitOperation(const OperationPtr& p) ClassDefPtr cl = ClassDefPtr::dynamicCast(p->container()); if(!cl->isLocal()) { - cerr << p->definitionContext()->filename() << ":" << p->line() - << ": warning: metadata directive `UserException' applies only to local operations " - << "but enclosing " << (cl->isInterface() ? "interface" : "class") << "`" << cl->name() - << "' is not local" << endl; + ostringstream os; + os << "ignoring invalid metadata `UserException': directive applies only to local operations " + << "but enclosing " << (cl->isInterface() ? "interface" : "class") << " `" << cl->name() + << "' is not local"; + emitWarning(p->file(), p->line(), os.str()); } } StringList metaData = getMetaData(p); @@ -3498,15 +3673,15 @@ Slice::JavaGenerator::MetaDataVisitor::visitOperation(const OperationPtr& p) { if(q->find("java:type:", 0) == 0) { - cerr << p->definitionContext()->filename() << ":" << p->line() - << ": warning: invalid metadata for operation" << endl; + emitWarning(p->file(), p->line(), "ignoring invalid metadata `" + *q + + "' for operation with void return type"); break; } } } else { - validateType(returnType, metaData, p->definitionContext()->filename(), p->line()); + validateType(returnType, metaData, p->file(), p->line()); } } @@ -3514,62 +3689,86 @@ Slice::JavaGenerator::MetaDataVisitor::visitOperation(const OperationPtr& p) for(ParamDeclList::iterator q = params.begin(); q != params.end(); ++q) { metaData = getMetaData(*q); - validateType((*q)->type(), metaData, p->definitionContext()->filename(), (*q)->line()); + validateType((*q)->type(), metaData, p->file(), (*q)->line()); } - validateGetSet(p, metaData, p->definitionContext()->filename(), p->line()); + validateGetSet(p, metaData, p->file(), p->line()); } void Slice::JavaGenerator::MetaDataVisitor::visitDataMember(const DataMemberPtr& p) { StringList metaData = getMetaData(p); - validateType(p->type(), metaData, p->definitionContext()->filename(), p->line()); - validateGetSet(p, metaData, p->definitionContext()->filename(), p->line()); + validateType(p->type(), metaData, p->file(), p->line()); + validateGetSet(p, metaData, p->file(), p->line()); } void Slice::JavaGenerator::MetaDataVisitor::visitSequence(const SequencePtr& p) { + static const string protobuf = "java:protobuf:"; + static const string serializable = "java:serializable:"; StringList metaData = getMetaData(p); - validateType(p, metaData, p->definitionContext()->filename(), p->line()); - validateGetSet(p, metaData, p->definitionContext()->filename(), p->line()); + const string file = p->file(); + const string line = p->line(); + for(StringList::const_iterator q = metaData.begin(); q != metaData.end(); ) + { + string s = *q++; + if(_history.count(s) == 0) // Don't complain about the same metadata more than once. + { + if(s.find(protobuf) == 0 || s.find(serializable) == 0) + { + // + // Remove from list so validateType does not try to handle as well. + // + metaData.remove(s); + + BuiltinPtr builtin = BuiltinPtr::dynamicCast(p->type()); + if(!builtin || builtin->kind() != Builtin::KindByte) + { + _history.insert(s); + emitWarning(file, line, "ignoring invalid metadata `" + s + "': " + + "this metadata can only be used with a byte sequence"); + } + } + } + } + + validateType(p, metaData, file, line); + validateGetSet(p, metaData, file, line); } void Slice::JavaGenerator::MetaDataVisitor::visitDictionary(const DictionaryPtr& p) { StringList metaData = getMetaData(p); - validateType(p, metaData, p->definitionContext()->filename(), p->line()); - validateGetSet(p, metaData, p->definitionContext()->filename(), p->line()); + validateType(p, metaData, p->file(), p->line()); + validateGetSet(p, metaData, p->file(), p->line()); } void Slice::JavaGenerator::MetaDataVisitor::visitEnum(const EnumPtr& p) { StringList metaData = getMetaData(p); - validateType(p, metaData, p->definitionContext()->filename(), p->line()); - validateGetSet(p, metaData, p->definitionContext()->filename(), p->line()); + validateType(p, metaData, p->file(), p->line()); + validateGetSet(p, metaData, p->file(), p->line()); } void Slice::JavaGenerator::MetaDataVisitor::visitConst(const ConstPtr& p) { StringList metaData = getMetaData(p); - validateType(p, metaData, p->definitionContext()->filename(), p->line()); - validateGetSet(p, metaData, p->definitionContext()->filename(), p->line()); + validateType(p, metaData, p->file(), p->line()); + validateGetSet(p, metaData, p->file(), p->line()); } StringList Slice::JavaGenerator::MetaDataVisitor::getMetaData(const ContainedPtr& cont) { - StringList metaData = cont->getMetaData(); - DefinitionContextPtr dc = cont->definitionContext(); - assert(dc); - string file = dc->filename(); + static const string prefix = "java:"; + StringList metaData = cont->getMetaData(); StringList result; - static const string prefix = "java:"; for(StringList::const_iterator p = metaData.begin(); p != metaData.end(); ++p) { @@ -3596,8 +3795,18 @@ Slice::JavaGenerator::MetaDataVisitor::getMetaData(const ContainedPtr& cont) result.push_back(s); continue; } + else if(s.substr(prefix.size(), pos - prefix.size()) == "serializable") + { + result.push_back(s); + continue; + } + else if(s.substr(prefix.size(), pos - prefix.size()) == "protobuf") + { + result.push_back(s); + continue; + } - cerr << file << ":" << cont->line() << ": warning: ignoring invalid metadata `" << s << "'" << endl; + emitWarning(cont->file(), cont->line(), "ignoring invalid metadata `" + s + "'"); } _history.insert(s); @@ -3630,7 +3839,14 @@ Slice::JavaGenerator::MetaDataVisitor::validateType(const SyntaxTreeBasePtr& p, assert(b); str = b->typeId(); } - cerr << file << ":" << line << ": warning: invalid metadata for " << str << endl; + emitWarning(file, line, "invalid metadata for " + str); + } + else if(i->find("java:protobuf:") == 0 || i->find("java:serializable:") == 0) + { + // + // Only valid in sequence defintion which is checked in visitSequence + // + emitWarning(file, line, "ignoring invalid metadata `" + *i + "'"); } } } @@ -3660,7 +3876,7 @@ Slice::JavaGenerator::MetaDataVisitor::validateGetSet(const SyntaxTreeBasePtr& p assert(b); str = b->typeId(); } - cerr << file << ":" << line << ": warning: invalid metadata for " << str << endl; + emitWarning(file, line, "invalid metadata for " + str); } } } diff --git a/cpp/src/Slice/Makefile.mak b/cpp/src/Slice/Makefile.mak index ad3e5a89611..dd76c272482 100644 --- a/cpp/src/Slice/Makefile.mak +++ b/cpp/src/Slice/Makefile.mak @@ -40,7 +40,7 @@ CPPFLAGS = -I.. -Idummyinclude $(CPPFLAGS) -DSLICE_API_EXPORTS -DWIN32_LEAN_AND PDBFLAGS = /pdb:$(DLLNAME:.dll=.pdb)
!endif
-!if "$(CPP_COMPILER)" == "BCC2007"
+!if "$(BCPLUSPLUS)" == "yes"
RES_FILE = ,, Slice.res
!else
RES_FILE = Slice.res
@@ -88,7 +88,7 @@ install:: all copy $(DLLNAME) $(install_bindir)
-!if "$(CPP_COMPILER)" == "BCC2007" && "$(OPTIMIZE)" != "yes"
+!if "$(BCPLUSPLUS)" == "yes" && "$(OPTIMIZE)" != "yes"
install:: all
copy $(DLLNAME:.dll=.tds) $(install_bindir)
diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp index 5d682503ec3..d2725b13c24 100644 --- a/cpp/src/Slice/Parser.cpp +++ b/cpp/src/Slice/Parser.cpp @@ -1351,6 +1351,13 @@ Slice::Container::lookupException(const string& scoped, bool printError) return exceptions.front(); } +UnitPtr +Slice::Container::unit() const +{ + return SyntaxTreeBase::unit(); +} + + ModuleList Slice::Container::modules() const { @@ -4714,8 +4721,7 @@ Slice::Operation::attributes() const } if(i == 2) { - cerr << definitionContext()->filename() << ":" << line() - << ": warning: invalid freeze metadata for operation" << endl; + emitWarning(definitionContext()->filename(), line(), "invalid freeze metadata for operation"); } else { @@ -4736,8 +4742,7 @@ Slice::Operation::attributes() const { if(result != 0 && (i == int(Supports) || i == int(Never))) { - cerr << definitionContext()->filename() << ":" << line() - << ": warning: invalid freeze metadata for operation" << endl; + emitWarning(definitionContext()->filename(), line(), "invalid freeze metadata for operation"); } else { @@ -4751,8 +4756,7 @@ Slice::Operation::attributes() const if(i == 4) { - cerr << definitionContext()->filename() << ":" << line() - << ": warning: invalid freeze metadata for operation" << endl; + emitWarning(definitionContext()->filename(), line(), "invalid freeze metadata for operation"); // // Set default @@ -5004,6 +5008,12 @@ Slice::Unit::currentFile() const } } +string +Slice::Unit::topLevelFile() const +{ + return _topLevelFile; +} + int Slice::Unit::currentLine() const { @@ -5057,23 +5067,13 @@ Slice::Unit::scanPosition(const char* s) } } - // - // Cache full paths to avoid too many full path computations. - // - map<string, string>::const_iterator p = _fullPaths.find(currentFile); - if(p == _fullPaths.end()) - { - p = _fullPaths.insert(make_pair(currentFile, fullPath(currentFile))).first; - } - currentFile = p->second; - enum LineType { File, Push, Pop }; LineType type = File; if(_currentLine == 0) { - if(currentFile != _topLevelFile) + if(_currentIncludeLevel > 0 || currentFile != _topLevelFile) { type = Push; line.erase(idx); @@ -5123,6 +5123,7 @@ Slice::Unit::scanPosition(const char* s) DefinitionContextPtr dc = currentDefinitionContext(); assert(dc); dc->setFilename(currentFile); + _definitionContextMap.insert(make_pair(currentFile, dc)); } } @@ -5150,6 +5151,9 @@ Slice::Unit::addGlobalMetaData(const StringList& metaData) } else { + // + // Append the global metadata to any existing metadata (e.g., default global metadata). + // StringList l = dc->getMetaData(); copy(metaData.begin(), metaData.end(), back_inserter(l)); dc->setMetaData(l); @@ -5167,36 +5171,27 @@ Slice::Unit::setSeenDefinition() void Slice::Unit::error(const char* s) { - string file = currentFile(); - if(!file.empty()) - { - cerr << file << ':' << _currentLine << ": "; - } - cerr << s << endl; + emitError(currentFile(), _currentLine, s); _errors++; } void Slice::Unit::error(const string& s) { - error(s.c_str()); + emitError(currentFile(), _currentLine, s); + _errors++; } void Slice::Unit::warning(const char* s) const { - string file = currentFile(); - if(!file.empty()) - { - cerr << file << ':' << _currentLine << ": "; - } - cerr << "warning: " << s << endl; + emitWarning(currentFile(), _currentLine, s); } void Slice::Unit::warning(const string& s) const { - warning(s.c_str()); + emitWarning(currentFile(), _currentLine, s); } ContainerPtr @@ -5233,7 +5228,7 @@ Slice::Unit::currentDefinitionContext() const void Slice::Unit::pushDefinitionContext() { - _definitionContextStack.push(new DefinitionContext(_currentIncludeLevel, _defaultGlobalMetadata)); + _definitionContextStack.push(new DefinitionContext(_currentIncludeLevel, _defaultGlobalMetaData)); } void @@ -5243,6 +5238,17 @@ Slice::Unit::popDefinitionContext() _definitionContextStack.pop(); } +DefinitionContextPtr +Slice::Unit::findDefinitionContext(const string& file) const +{ + map<string, DefinitionContextPtr>::const_iterator p = _definitionContextMap.find(file); + if(p != _definitionContextMap.end()) + { + return p->second; + } + return 0; +} + void Slice::Unit::addContent(const ContainedPtr& contained) { @@ -5453,6 +5459,18 @@ Slice::Unit::includeFiles() const return _includeFiles; } +StringList +Slice::Unit::allFiles() const +{ + StringList result; + for(map<string, DefinitionContextPtr>::const_iterator p = _definitionContextMap.begin(); + p != _definitionContextMap.end(); ++p) + { + result.push_back(p->first); + } + return result; +} + int Slice::Unit::parse(const string& filename, FILE* file, bool debug, Slice::FeatureProfile profile) { @@ -5466,7 +5484,6 @@ Slice::Unit::parse(const string& filename, FILE* file, bool debug, Slice::Featur _currentIncludeLevel = 0; _featureProfile = profile; _topLevelFile = fullPath(filename); - _fullPaths[filename] = _topLevelFile; pushContainer(this); pushDefinitionContext(); @@ -5539,7 +5556,7 @@ Slice::Unit::Unit(bool ignRedefs, bool all, bool allowIcePrefix, bool caseSensit _all(all), _allowIcePrefix(allowIcePrefix), _caseSensitive(caseSensitive), - _defaultGlobalMetadata(defaultGlobalMetadata), + _defaultGlobalMetaData(defaultGlobalMetadata), _errors(0) { diff --git a/cpp/src/Slice/Preprocessor.cpp b/cpp/src/Slice/Preprocessor.cpp index 636c772b94d..29c968f9f93 100644 --- a/cpp/src/Slice/Preprocessor.cpp +++ b/cpp/src/Slice/Preprocessor.cpp @@ -44,11 +44,10 @@ extern "C" int mcpp_lib_main(int argc, char** argv); extern "C" void mcpp_use_mem_buffers(int tf); extern "C" char* mcpp_get_mem_buffer(Outdest od); -Slice::Preprocessor::Preprocessor(const string& path, const string& fileName, const vector<string>& args, const string& cppSourceExt) : +Slice::Preprocessor::Preprocessor(const string& path, const string& fileName, const vector<string>& args) : _path(path), _fileName(fileName), _args(args), - _cppSourceExt(cppSourceExt), _cppHandle(0) { } @@ -145,12 +144,16 @@ Slice::Preprocessor::preprocess(bool keepComments) delete[] argv; // - // Print errors to stderr. + // Display any errors. // char* err = mcpp_get_mem_buffer(Err); if(err) { - ::fputs(err, stderr); + vector<string> messages = filterMcppWarnings(err); + for(vector<string>::const_iterator i = messages.begin(); i != messages.end(); ++i) + { + emitRaw(i->c_str()); + } } if(status == 0) @@ -199,13 +202,14 @@ Slice::Preprocessor::preprocess(bool keepComments) } else { - cerr << "Could not open temporary file: "; + ostream& os = getErrorStream(); + os << _path << ": error: could not open temporary file: "; #ifdef _WIN32 - cerr << IceUtil::wstringToString(_cppFile); + os << IceUtil::wstringToString(_cppFile); #else - cerr << _cppFile; + os << _cppFile; #endif - cerr << endl; + os << endl; } } @@ -218,7 +222,8 @@ Slice::Preprocessor::preprocess(bool keepComments) } bool -Slice::Preprocessor::printMakefileDependencies(Language lang, const vector<string>& includePaths) +Slice::Preprocessor::printMakefileDependencies(Language lang, const vector<string>& includePaths, + const string& cppSourceExt) { if(!checkInputFile()) { @@ -253,7 +258,7 @@ Slice::Preprocessor::printMakefileDependencies(Language lang, const vector<strin char* err = mcpp_get_mem_buffer(Err); if(err) { - ::fputs(err, stderr); + emitRaw(err); } if(status != 0) @@ -299,7 +304,11 @@ Slice::Preprocessor::printMakefileDependencies(Language lang, const vector<strin string suffix = ".o:"; #endif pos = unprocessed.find(suffix) + suffix.size(); - string result = unprocessed.substr(0, pos); + string result; + if(lang != JavaXML) + { + result = unprocessed.substr(0, pos); + } vector<string> fullIncludePaths; vector<string>::const_iterator p; @@ -345,26 +354,47 @@ Slice::Preprocessor::printMakefileDependencies(Language lang, const vector<strin } } - // - // Escape spaces in the file name. - // - string::size_type space = 0; - while((space = file.find(" ", space)) != string::npos) + if(lang == JavaXML) { - file.replace(space, 1, "\\ "); - space += 2; + if(result.size() == 0) + { + result = " <source name=\"" + file + "\">"; + } + else + { + result += "\n <dependsOn name=\"" + file + "\"/>"; + } } + else + { + // + // Escape spaces in the file name. + // + string::size_type space = 0; + while((space = file.find(" ", space)) != string::npos) + { + file.replace(space, 1, "\\ "); + space += 2; + } - // - // Add to result - // - result += " \\\n " + file; + // + // Add to result + // + result += " \\\n " + file; + } pos = end; } - result += "\n"; + if(lang == JavaXML) + { + result += "\n </source>\n"; + } + else + { + result += "\n"; + } /* - * icecpp emits dependencies in any of the following formats, depending on the + * Emit dependencies in any of the following formats, depending on the * length of the filenames: * * x.o[bj]: /path/x.ice /path/y.ice @@ -396,10 +426,12 @@ Slice::Preprocessor::printMakefileDependencies(Language lang, const vector<strin string::size_type pos; while((pos = result.find(suffix)) != string::npos) { - result.replace(pos, suffix.size() - 1, "." + _cppSourceExt); + result.replace(pos, suffix.size() - 1, "." + cppSourceExt); } break; } + case JavaXML: + break; case Java: { // @@ -511,14 +543,14 @@ Slice::Preprocessor::checkInputFile() } if(suffix != ".ice") { - cerr << _path << ": input files must end with `.ice'" << endl; + getErrorStream() << _path << ": error: input files must end with `.ice'" << endl; return false; } ifstream test(_fileName.c_str()); if(!test) { - cerr << _path << ": cannot open `" << _fileName << "' for reading" << endl; + getErrorStream() << _path << ": error: cannot open `" << _fileName << "' for reading" << endl; return false; } test.close(); diff --git a/cpp/src/Slice/PythonUtil.cpp b/cpp/src/Slice/PythonUtil.cpp index cb9e024717a..34fb3bd9654 100644 --- a/cpp/src/Slice/PythonUtil.cpp +++ b/cpp/src/Slice/PythonUtil.cpp @@ -32,6 +32,7 @@ class MetaDataVisitor : public ParserVisitor { public: + virtual bool visitUnitStart(const UnitPtr&); virtual bool visitModuleStart(const ModulePtr&); virtual void visitClassDecl(const ClassDeclPtr&); virtual bool visitClassDefStart(const ClassDefPtr&); @@ -47,14 +48,9 @@ public: private: // - // Validates global metadata. - // - void validateGlobal(const DefinitionContextPtr&); - - // // Validates sequence metadata. // - void validateSequence(const DefinitionContextPtr&, const string&, const TypePtr&, const StringList&); + void validateSequence(const string&, const string&, const TypePtr&, const StringList&); // // Checks a definition that doesn't currently support Python metadata. @@ -153,6 +149,11 @@ private: }; typedef list<MemberInfo> MemberInfoList; + // + // Write a member assignment statement for a constructor. + // + void writeAssign(const MemberInfo&); + void collectClassMembers(const ClassDefPtr&, MemberInfoList&, bool); void collectExceptionMembers(const ExceptionPtr&, MemberInfoList&, bool); @@ -476,7 +477,7 @@ Slice::Python::CodeVisitor::visitClassDefStart(const ClassDefPtr& p) { if(!q->inherited) { - _out << nl << "self." << q->fixedName << " = " << q->fixedName;; + writeAssign(*q); } } } @@ -982,7 +983,7 @@ Slice::Python::CodeVisitor::visitExceptionStart(const ExceptionPtr& p) { if(!q->inherited) { - _out << nl << "self." << q->fixedName << " = " << q->fixedName;; + writeAssign(*q); } } } @@ -1101,7 +1102,7 @@ Slice::Python::CodeVisitor::visitStructStart(const StructPtr& p) _out.inc(); for(r = memberList.begin(); r != memberList.end(); ++r) { - _out << nl << "self." << r->fixedName << " = " << r->fixedName; + writeAssign(*r); } _out.dec(); @@ -1199,17 +1200,46 @@ Slice::Python::CodeVisitor::visitStructStart(const StructPtr& p) void Slice::Python::CodeVisitor::visitSequence(const SequencePtr& p) { + static const string protobuf = "python:protobuf:"; + StringList metaData = p->getMetaData(); + bool isCustom = false; + string customType; + for(StringList::const_iterator q = metaData.begin(); q != metaData.end(); ++q) + { + if(q->find(protobuf) == 0) + { + BuiltinPtr builtin = BuiltinPtr::dynamicCast(p->type()); + if(!builtin || builtin->kind() != Builtin::KindByte) + { + continue; + } + isCustom = true; + customType = q->substr(protobuf.size()); + break; + } + } + // // Emit the type information. // string scoped = p->scoped(); _out << sp << nl << "if not " << getDictLookup(p, "_t_") << ':'; _out.inc(); - _out << nl << "_M_" << getAbsolute(p, "_t_") << " = IcePy.defineSequence('" << scoped << "', "; - writeMetaData(p->getMetaData()); - _out << ", "; - writeType(p->type()); - _out << ")"; + if(isCustom) + { + string package = customType.substr(0, customType.find('.')); + _out << nl << "import " << package; + _out << nl << "_M_" << getAbsolute(p, "_t_") + << " = IcePy.defineCustom('" << scoped << "', " << customType << ")"; + } + else + { + _out << nl << "_M_" << getAbsolute(p, "_t_") << " = IcePy.defineSequence('" << scoped << "', "; + writeMetaData(metaData); + _out << ", "; + writeType(p->type()); + _out << ")"; + } _out.dec(); } @@ -1629,7 +1659,13 @@ Slice::Python::CodeVisitor::writeDefaultValue(const TypePtr& p) StructPtr st = StructPtr::dynamicCast(p); if(st) { - _out << getSymbol(st) << "()"; + // + // We cannot emit a call to the struct's constructor here because Python + // only evaluates this expression once (see bug 3676). Instead, we emit + // a marker that allows us to determine whether the application has + // supplied a value. + // + _out << "Ice._struct_marker"; return; } @@ -1701,6 +1737,30 @@ Slice::Python::CodeVisitor::writeMetaData(const StringList& meta) _out << ')'; } +void +Slice::Python::CodeVisitor::writeAssign(const MemberInfo& info) +{ + // + // Structures are treated differently (see bug 3676). + // + StructPtr st = StructPtr::dynamicCast(info.type); + if(st) + { + _out << nl << "if " << info.fixedName << " is Ice._struct_marker:"; + _out.inc(); + _out << nl << "self." << info.fixedName << " = " << getSymbol(st) << "()"; + _out.dec(); + _out << nl << "else:"; + _out.inc(); + _out << nl << "self." << info.fixedName << " = " << info.fixedName; + _out.dec(); + } + else + { + _out << nl << "self." << info.fixedName << " = " << info.fixedName; + } +} + string Slice::Python::CodeVisitor::getOperationMode(Slice::Operation::Mode mode) { @@ -1779,6 +1839,16 @@ Slice::Python::generate(const UnitPtr& un, bool all, bool checksum, const vector out << nl << "import Ice, IcePy, __builtin__"; + // + // For backward-compatibility with generated code from Ice 3.3.0, we add a definition + // of _struct_marker to the Ice module if necessary. + // + out << nl; + out << nl << "if not Ice.__dict__.has_key(\"_struct_marker\"):"; + out.inc(); + out << nl << "Ice._struct_marker = object()"; + out.dec(); + if(!all) { vector<string> paths = includePaths; @@ -1866,20 +1936,19 @@ Slice::Python::fixIdent(const string& ident) string Slice::Python::getPackageMetadata(const ContainedPtr& cont) { - string package; + UnitPtr unit = cont->container()->unit(); + string file = cont->file(); + assert(!file.empty()); - DefinitionContextPtr dc = cont->definitionContext(); - if(dc) + static const string prefix = "python:package:"; + DefinitionContextPtr dc = unit->findDefinitionContext(file); + assert(dc); + string q = dc->findMetaData(prefix); + if(!q.empty()) { - static const string prefix = "python:package:"; - string metadata = dc->findMetaData(prefix); - if(!metadata.empty()) - { - package = metadata.substr(prefix.size()); - } + q = q.substr(prefix.size()); } - - return package; + return q; } string @@ -1929,15 +1998,44 @@ Slice::Python::printHeader(IceUtilInternal::Output& out) } bool -Slice::Python::MetaDataVisitor::visitModuleStart(const ModulePtr& p) +Slice::Python::MetaDataVisitor::visitUnitStart(const UnitPtr& p) { - if(!ModulePtr::dynamicCast(p->container())) + static const string prefix = "python:"; + + // + // Validate global metadata in the top-level file and all included files. + // + StringList files = p->allFiles(); + + for(StringList::iterator q = files.begin(); q != files.end(); ++q) { - // - // We only need to validate global metadata for top-level modules. - // - validateGlobal(p->definitionContext()); + string file = *q; + DefinitionContextPtr dc = p->findDefinitionContext(file); + assert(dc); + StringList globalMetaData = dc->getMetaData(); + for(StringList::const_iterator r = globalMetaData.begin(); r != globalMetaData.end(); ++r) + { + string s = *r; + if(_history.count(s) == 0) + { + if(s.find(prefix) == 0) + { + static const string packagePrefix = "python:package:"; + if(s.find(packagePrefix) != 0 || s.size() == packagePrefix.size()) + { + emitWarning(file, "", "ignoring invalid global metadata `" + s + "'"); + } + } + _history.insert(s); + } + } } + return true; +} + +bool +Slice::Python::MetaDataVisitor::visitModuleStart(const ModulePtr& p) +{ reject(p); return true; } @@ -1972,32 +2070,52 @@ Slice::Python::MetaDataVisitor::visitStructStart(const StructPtr& p) void Slice::Python::MetaDataVisitor::visitOperation(const OperationPtr& p) { - DefinitionContextPtr dc = p->definitionContext(); - assert(dc); - TypePtr ret = p->returnType(); if(ret) { - validateSequence(dc, p->line(), ret, p->getMetaData()); + validateSequence(p->file(), p->line(), ret, p->getMetaData()); } ParamDeclList params = p->parameters(); for(ParamDeclList::iterator q = params.begin(); q != params.end(); ++q) { - validateSequence(dc, (*q)->line(), (*q)->type(), (*q)->getMetaData()); + validateSequence(p->file(), (*q)->line(), (*q)->type(), (*q)->getMetaData()); } } void Slice::Python::MetaDataVisitor::visitDataMember(const DataMemberPtr& p) { - validateSequence(p->definitionContext(), p->line(), p->type(), p->getMetaData()); + validateSequence(p->file(), p->line(), p->type(), p->getMetaData()); } void Slice::Python::MetaDataVisitor::visitSequence(const SequencePtr& p) { - validateSequence(p->definitionContext(), p->line(), p, p->getMetaData()); + static const string protobuf = "python:protobuf:"; + StringList metaData = p->getMetaData(); + const string file = p->file(); + const string line = p->line(); + for(StringList::const_iterator q = metaData.begin(); q != metaData.end(); ) + { + string s = *q++; + if(s.find(protobuf) == 0) + { + // + // Remove from list so validateSequence does not try to handle as well. + // + metaData.remove(s); + + BuiltinPtr builtin = BuiltinPtr::dynamicCast(p->type()); + if(!builtin || builtin->kind() != Builtin::KindByte) + { + emitWarning(file, line, "ignoring invalid metadata `" + s + ": " + + "`protobuf' encoding must be a byte sequence"); + } + } + } + + validateSequence(file, line, p, metaData); } void @@ -2019,32 +2137,7 @@ Slice::Python::MetaDataVisitor::visitConst(const ConstPtr& p) } void -Slice::Python::MetaDataVisitor::validateGlobal(const DefinitionContextPtr& dc) -{ - StringList globalMetaData = dc->getMetaData(); - - static const string prefix = "python:"; - - for(StringList::const_iterator p = globalMetaData.begin(); p != globalMetaData.end(); ++p) - { - string s = *p; - if(_history.count(s) == 0) - { - if(s.find(prefix) == 0) - { - static const string packagePrefix = "python:package:"; - if(s.find(packagePrefix) != 0 || s.size() == packagePrefix.size()) - { - cerr << dc->filename() << ": warning: ignoring invalid global metadata `" << s << "'" << endl; - } - } - _history.insert(s); - } - } -} - -void -Slice::Python::MetaDataVisitor::validateSequence(const DefinitionContextPtr& dc, const string& line, +Slice::Python::MetaDataVisitor::validateSequence(const string& file, const string& line, const TypePtr& type, const StringList& meta) { static const string prefix = "python:"; @@ -2067,7 +2160,7 @@ Slice::Python::MetaDataVisitor::validateSequence(const DefinitionContextPtr& dc, } } } - cerr << dc->filename() << ":" << line << ": warning: ignoring metadata `" << s << "'" << endl; + emitWarning(file, line, "ignoring invalid metadata `" + s + "'"); } } } @@ -2083,9 +2176,7 @@ Slice::Python::MetaDataVisitor::reject(const ContainedPtr& cont) { if(p->find(prefix) == 0) { - DefinitionContextPtr dc = cont->definitionContext(); - assert(dc); - cerr << dc->filename() << ":" << cont->line() << ": warning: ignoring metadata `" << *p << "'" << endl; + emitWarning(cont->file(), cont->line(), "ignoring invalid metadata `" + *p + "'"); } } } diff --git a/cpp/src/Slice/RubyUtil.cpp b/cpp/src/Slice/RubyUtil.cpp index 3227446ee82..86869339cab 100644 --- a/cpp/src/Slice/RubyUtil.cpp +++ b/cpp/src/Slice/RubyUtil.cpp @@ -1021,6 +1021,17 @@ Slice::Ruby::CodeVisitor::visitStructStart(const StructPtr& p) _out << nl << "end"; // + // eql? + // + // This method is used to determine the equality of keys in a Hash object. + // + _out << sp << nl << "def eql?(other)"; + _out.inc(); + _out << nl << "return other.class == self.class && other == self"; + _out.dec(); + _out << nl << "end"; + + // // inspect // _out << sp << nl << "def inspect"; diff --git a/cpp/src/Slice/Util.cpp b/cpp/src/Slice/Util.cpp index cf2e77ed32f..dffbef6523b 100644 --- a/cpp/src/Slice/Util.cpp +++ b/cpp/src/Slice/Util.cpp @@ -10,6 +10,7 @@ #include <Slice/Util.h> #include <IceUtil/Unicode.h> #include <IceUtil/FileUtil.h> +#include <IceUtil/StringUtil.h> #include <climits> #include <unistd.h> // For readlink() @@ -27,7 +28,18 @@ normalizePath(const string& path) string result = path; replace(result.begin(), result.end(), '\\', '/'); string::size_type pos; - while((pos = result.find("//")) != string::npos) + string::size_type startReplace = 0; +#ifdef _WIN32 + // + // For UNC paths we need to ensure they are in the format that is + // returned by MCPP. IE. "//MACHINE/PATH" + // + if(result.find("//") == 0) + { + startReplace = 2; + } +#endif + while((pos = result.find("//", startReplace)) != string::npos) { result.replace(pos, 2, "/"); } @@ -172,3 +184,156 @@ Slice::changeInclude(const string& orig, const vector<string>& includePaths) return result; } +static ostream* errorStream = &cerr; + +void +Slice::setErrorStream(ostream& stream) +{ + errorStream = &stream; +} + +ostream& +Slice::getErrorStream() +{ + return *errorStream; +} + +void +Slice::emitError(const string& file, int line, const string& message) +{ + if(!file.empty()) + { + *errorStream << file; + if(line != -1) + { + *errorStream << ':' << line; + } + *errorStream << ": "; + } + *errorStream << message << endl; +} + +void +Slice::emitWarning(const string& file, int line, const string& message) +{ + if(!file.empty()) + { + *errorStream << file; + if(line != -1) + { + *errorStream << ':' << line; + } + *errorStream << ": "; + } + *errorStream << "warning: " << message << endl; +} + +void +Slice::emitError(const string& file, const std::string& line, const string& message) +{ + if(!file.empty()) + { + *errorStream << file; + if(!line.empty()) + { + *errorStream << ':' << line; + } + *errorStream << ": "; + } + *errorStream << message << endl; +} + +void +Slice::emitWarning(const string& file, const std::string& line, const string& message) +{ + if(!file.empty()) + { + *errorStream << file; + if(!line.empty()) + { + *errorStream << ':' << line; + } + *errorStream << ": "; + } + *errorStream << "warning: " << message << endl; +} + +void +Slice::emitRaw(const char* message) +{ + *errorStream << message << flush; +} + +vector<string> +Slice::filterMcppWarnings(const string& message) +{ + static const char* messages[] = + { + "Converted [CR+LF] to [LF]", + "no newline, supplemented newline", + 0 + }; + + static const string warningPrefix = "warning:"; + static const string fromPrefix = "from"; + static const string separators = "\n\t "; + + vector<string> in; + vector<string> out; + IceUtilInternal::splitString(message, "\n", in); + bool skipped; + for(vector<string>::const_iterator i = in.begin(); i != in.end(); i++) + { + skipped = false; + + if(i->find(warningPrefix) != string::npos) + { + for(int j = 0; messages[j] != 0; ++j) + { + if(i->find(messages[j]) != string::npos) + { + // This line should be skipped it contains the unwanted mcpp warning + // next line should also be skipped it contains the slice line that + // produces the skipped warning + i++; + skipped = true; + // + // Check if next lines are still the same warning + // + i++; + while(i != in.end()) + { + string token = *i; + string::size_type index = token.find_first_not_of(separators); + if(index != string::npos) + { + token = token.substr(index); + } + if(token.find(fromPrefix) != 0) + { + // + // First line not of this warning + // + i--; + break; + } + else + { + i++; + } + } + break; + } + } + if(i == in.end()) + { + break; + } + } + if(!skipped) + { + out.push_back(*i + "\n"); + } + } + return out; +} |