diff options
author | Michi Henning <michi@zeroc.com> | 2002-07-17 10:35:39 +0000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2002-07-17 10:35:39 +0000 |
commit | 83572e33ee865827866d57d44695c4444ed2e972 (patch) | |
tree | 9f8af225c0c43032ea7ce82870eb61dbed70ee85 /cpp/src/slice2java/Gen.cpp | |
parent | Added sanity checks to make sure that the meaning of an identifier doesn't (diff) | |
download | ice-83572e33ee865827866d57d44695c4444ed2e972.tar.bz2 ice-83572e33ee865827866d57d44695c4444ed2e972.tar.xz ice-83572e33ee865827866d57d44695c4444ed2e972.zip |
Updated slice parser to put parameter declarations into their own scope.
That way, we can check whether meaning changes as identifiers are
introduced into parameter declarartions.
Changes were quite extensive because one thing dragged another behind it...
Got rid of some of the pesky parse errors caused by returning zero from
some creation operations. In general, it seems easier to, whenever
possible, to create a dummy instance of something that doesn't quite
parse or doesn't quite get through a semantic check. This avoids
calling YYERROR, which can make a big mess of the scope stack. (I got
stuck on this for quite a long time before I figured out what was going
on.)
Took the opportunity to get rid of the awkward parsing for parameter lists.
We now have only a single parameters non-terminal, which simplifies
things (and also got rid of the one remaining shift/reduce conflict in
the grammar).
Updated all the code generators to work with the new structure for the
syntax tree.
Kept a rather ugly hack in Grammar.y to still permit use of semicolons to
indicate out params. This will go with stable_39, so I don't mind that
it's ugly for now.
Diffstat (limited to 'cpp/src/slice2java/Gen.cpp')
-rw-r--r-- | cpp/src/slice2java/Gen.cpp | 78 |
1 files changed, 27 insertions, 51 deletions
diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp index d46c211cbe6..463738f197e 100644 --- a/cpp/src/slice2java/Gen.cpp +++ b/cpp/src/slice2java/Gen.cpp @@ -28,70 +28,35 @@ Slice::JavaVisitor::~JavaVisitor() string Slice::JavaVisitor::getParams(const OperationPtr& op, const string& scope) { - TypeStringList inParams = op->inputParameters(); - TypeStringList outParams = op->outputParameters(); - TypeStringList::const_iterator q; - string params; - - for(q = inParams.begin(); q != inParams.end(); ++q) - { - if(q != inParams.begin()) - { - params += ", "; - } - - string typeString = typeToString(q->first, TypeModeIn, scope); - params += typeString; - params += ' '; - params += fixKwd(q->second); - } - - for(q = outParams.begin(); q != outParams.end(); ++q) + ParamDeclList paramList = op->parameters(); + for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q) { - if(q != outParams.begin() || !inParams.empty()) + if(q != paramList.begin()) { params += ", "; } - - string typeString = typeToString(q->first, TypeModeOut, scope); + string typeString = typeToString((*q)->type(), (*q)->isOutParam() ? TypeModeOut : TypeModeIn, scope); params += typeString; params += ' '; - params += fixKwd(q->second); + params += fixKwd((*q)->name()); } - return params; } string Slice::JavaVisitor::getArgs(const OperationPtr& op, const string& scope) { - TypeStringList inParams = op->inputParameters(); - TypeStringList outParams = op->outputParameters(); - TypeStringList::const_iterator q; - string args; - - for(q = inParams.begin(); q != inParams.end(); ++q) + ParamDeclList paramList = op->parameters(); + for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q) { - if(q != inParams.begin()) + if(q != paramList.begin()) { args += ", "; } - - args += fixKwd(q->second); + args += fixKwd((*q)->name()); } - - for(q = outParams.begin(); q != outParams.end(); ++q) - { - if(q != outParams.begin() || !inParams.empty()) - { - args += ", "; - } - - args += fixKwd(q->second); - } - return args; } @@ -376,8 +341,15 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p) string retS = typeToString(ret, TypeModeReturn, scope); int iter; - TypeStringList inParams = op->inputParameters(); - TypeStringList outParams = op->outputParameters(); + TypeStringList inParams; + TypeStringList outParams; + ParamDeclList paramList = op->parameters(); + for(ParamDeclList::const_iterator pli = paramList.begin(); pli != paramList.end(); ++pli) + { + TypeStringList &listref = (*pli)->isOutParam() ? outParams : inParams; + listref.push_back(make_pair((*pli)->type(), (*pli)->name())); + } + TypeStringList::const_iterator q; ExceptionList throws = op->throws(); @@ -2929,8 +2901,15 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p) string retS = typeToString(ret, TypeModeReturn, scope); int iter; - TypeStringList inParams = op->inputParameters(); - TypeStringList outParams = op->outputParameters(); + TypeStringList inParams; + TypeStringList outParams; + ParamDeclList paramList = op->parameters(); + for(ParamDeclList::const_iterator pli = paramList.begin(); pli != paramList.end(); ++pli) + { + TypeStringList &listref = (*pli)->isOutParam() ? outParams : inParams; + listref.push_back(make_pair((*pli)->type(), (*pli)->name())); + } + TypeStringList::const_iterator q; ExceptionList throws = op->throws(); @@ -3099,9 +3078,6 @@ Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p) TypePtr ret = op->returnType(); string retS = typeToString(ret, TypeModeReturn, scope); - TypeStringList inParams = op->inputParameters(); - TypeStringList outParams = op->outputParameters(); - ExceptionList throws = op->throws(); throws.sort(); throws.unique(); |