public String toStringArgs(final Object[] args) { boolean haveArgs = (args != null); if (haveArgs) { if (args.length < _paramNames.length) { haveArgs = false; } } String s = "func("; for (int i = 0; i < _paramNames.length; i++) { if (_paramNames[i] != null) { s += _paramNames[i] + ":"; } s += _paramTypes[i].typeName(); if (!haveArgs) { if (_paramHasDefault[i]) { if (_paramDefaults[i] != null) { String str = null; try { str = _paramDefaults[i].toString(); } catch (final java.lang.Exception e) { } if (str != null) { s += " =" + str; } else { s += " =?"; } } else { s += " =null"; } } } else { final Object a = args[i]; if (a != null) { String str = null; try { str = a.toString(); } catch (final java.lang.Exception e) { } if (str != null) { s += " =<" + str + ">"; } else { s += " =<?>"; } } else { s += " =<null>"; } } if (i != _paramNames.length - 1) { s += ", "; } } if (_returnType != null) { s += " -> " + _returnType.typeName(); } s += ")"; return s; }
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(); }
/** Parsing members means creating new members for definitions with more than one declarator. */ public void parse() { boolean clone_and_parse = true; if (extendVector == null) throw new RuntimeException("Compiler Error: extendVector not set!"); if (type_spec.typeSpec() instanceof ScopedName) { token = type_spec.typeSpec().get_token(); type_spec = ((ScopedName) type_spec.typeSpec()).resolvedTypeSpec(); clone_and_parse = false; if (type_spec instanceof ConstrTypeSpec) { if (((ConstrTypeSpec) type_spec.typeSpec()).c_type_spec instanceof StructType) { // System.out.println("Struct " + containing_struct.typeName() + " contains struct " + // ((ConstrTypeSpec)type_spec.typeSpec()).typeName()); if (((ConstrTypeSpec) type_spec.typeSpec()) .c_type_spec .typeName() .equals(containing_struct.typeName())) { parser.fatal_error( "Illegal recursion in struct (use sequence<" + containing_struct.typeName() + "> instead)", token); } } } } else if (type_spec.typeSpec() instanceof SequenceType) { TypeSpec ts = ((SequenceType) type_spec.typeSpec()).elementTypeSpec().typeSpec(); SequenceType seqTs = (SequenceType) type_spec.typeSpec(); while (ts instanceof SequenceType) { seqTs = (SequenceType) ts; ts = ((SequenceType) ts.typeSpec()).elementTypeSpec().typeSpec(); } // if( ts.typeName().equals( containing_struct.typeName()) || if (ScopedName.isRecursionScope(ts.typeName())) { seqTs.setRecursive(); } } else if (type_spec instanceof ConstrTypeSpec) { type_spec.parse(); } for (Enumeration e = declarators.v.elements(); e.hasMoreElements(); ) { Declarator d = (Declarator) e.nextElement(); // we don't parse the declarator itself // as that would result in its name getting defined // we define the declarator's name as a type name indirectly // through the cloned type specs. Member m = new Member(new_num()); m.declarator = d; TypeSpec ts = type_spec.typeSpec(); /* create a separate type spec copy for every declarator if the type spec is a new type definition, i.e. a struct, enum, union, sequence or the declarator is an array declarator */ // if( clone_and_parse && !(ts instanceof BaseType) ) if (clone_and_parse || d.d instanceof ArrayDeclarator) { /* arrays need special treatment */ if (d.d instanceof ArrayDeclarator) { ts = new ArrayTypeSpec(new_num(), ts, (ArrayDeclarator) d.d, pack_name); ts.parse(); } else if (!(ts instanceof BaseType)) { ts = (TypeSpec) ts.clone(); if (!(ts instanceof ConstrTypeSpec)) ts.set_name(d.name()); /* important: only parse type specs once (we do it for the last declarator only) */ if (!e.hasMoreElements()) ts.parse(); } } // else if (!(d.d instanceof ArrayDeclarator)) { try { NameTable.define(containing_struct + "." + d.name(), "declarator"); } catch (NameAlreadyDefined nad) { parser.error("Declarator " + d.name() + " already defined in scope.", token); } } /* if the type spec is a scoped name, it is already parsed and * the type name is defined */ // if( clone_and_parse ) // ts.parse(); m.type_spec = ts; m.pack_name = this.pack_name; m.name = this.name; extendVector.addElement(m); } declarators = null; }
public String typeName() { return type_spec.typeName(); }