boolean contained() { boolean result = false; IdlSymbol enc = getEnclosingSymbol(); while (enc != null) { if (enc instanceof Interface) { result = true; break; } enc = enc.getEnclosingSymbol(); } if (logger.isDebugEnabled()) logger.debug("ConstDecl.contained()? " + full_name() + " returns " + result); return result; }
/** Constructs a new OpDecl with the given characteristics. */ public OpDecl( IdlSymbol myInterface, int opAttribute, TypeSpec opTypeSpec, String name, List paramDecls, RaisesExpr raisesExpr) { super(new_num()); this.myInterface = myInterface; this.opAttribute = opAttribute; this.opTypeSpec = opTypeSpec; this.name = name; this.paramDecls = new Vector(paramDecls); this.raisesExpr = raisesExpr; setEnclosingSymbol(myInterface); this.pack_name = myInterface.full_name(); }
public void parse() { if (enclosing_symbol == null) throw new RuntimeException("Compiler Error: enclosing symbol in parse is null!"); myInterface = enclosing_symbol; if (opAttribute == ONEWAY) { if (!raisesExpr.empty()) parser.error("Oneway operation " + full_name() + " may not define a raises clause.", token); if (!(opTypeSpec.typeSpec() instanceof VoidTypeSpec)) parser.error( "Oneway operation " + full_name() + " may only define void as return type.", token); } try { NameTable.define(full_name(), IDLTypes.OPERATION); } catch (NameAlreadyDefined nad) { parser.error("Operation " + full_name() + " already defined", token); } for (Enumeration e = paramDecls.elements(); e.hasMoreElements(); ) { ParamDecl param = (ParamDecl) e.nextElement(); if (parser.strict_identifiers) { String typeN = (param.paramTypeSpec.typeName().indexOf(".") < 0 ? param.paramTypeSpec.typeName() : param .paramTypeSpec .typeName() .substring(param.paramTypeSpec.typeName().lastIndexOf(".") + 1)); if ((parser.strict_names && typeN.toUpperCase().equals(param.simple_declarator.toString().toUpperCase())) || typeN.equals(param.simple_declarator.toString())) { parser.error( "In operation " + full_name() + " argument " + param.simple_declarator + " clashes with type " + param.paramTypeSpec.typeName()); } } param.parse(); try { NameTable.define(full_name() + "." + param.simple_declarator.name(), IDLTypes.ARGUMENT); } catch (NameAlreadyDefined nad) { parser.error( "Argument " + param.simple_declarator.name() + " already defined in operation " + full_name(), token); } if (param.paramAttribute != ParamDecl.MODE_IN) { // for out and inout params myInterface.addImportedNameHolder(param.paramTypeSpec.holderName()); } if (!(param.paramTypeSpec.typeSpec() instanceof BaseType)) { if (logger.isInfoEnabled()) logger.info("classname: " + param.paramTypeSpec.typeSpec().getClass().getName()); myInterface.addImportedName( param.paramTypeSpec.typeSpec().full_name(), param.paramTypeSpec.typeSpec()); } if (param.paramTypeSpec.typeSpec() instanceof ConstrTypeSpec && ((ConstrTypeSpec) param.paramTypeSpec.typeSpec()).c_type_spec instanceof StructType && ((StructType) ((ConstrTypeSpec) param.paramTypeSpec.typeSpec()).c_type_spec).exc == true) { parser.error("Can't pass an exception as a parameter."); } } if (opTypeSpec.typeSpec() instanceof ScopedName) { TypeSpec ts = ((ScopedName) opTypeSpec.typeSpec()).resolvedTypeSpec(); if (ts != null) opTypeSpec = ts; myInterface.addImportedName(opTypeSpec.typeName()); } raisesExpr.parse(); }