Example #1
0
/* Production 87, chapter 3.4, corba 2.3.1 */
  public void op_dcl() {
 /*@bgen(jjtree) op_dcl */
  ASTop_dcl jjtn000 = new ASTop_dcl(this, IDLParserTreeConstants.JJTOP_DCL);
  bool jjtc000 = true;
  jjtree.openNodeScope(jjtn000);String ident = "";
  int opAttr = ASTop_dcl.OP_Attr_NONE;
    try {
      switch ((jj_ntk==-1)?jj_ntk_calc():jj_ntk) {
      case 77:
        opAttr = op_attribute();
        break;
      default:
        jj_la1[75] = jj_gen;
        ;
        break;
      }
      op_type_spec();
      ident = identifier();
      parameter_dcls();
      switch ((jj_ntk==-1)?jj_ntk_calc():jj_ntk) {
      case 81:
        raises_expr();
        break;
      default:
        jj_la1[76] = jj_gen;
        ;
        break;
      }
      switch ((jj_ntk==-1)?jj_ntk_calc():jj_ntk) {
      case 82:
        context_expr();
        break;
      default:
        jj_la1[77] = jj_gen;
        ;
        break;
      }
    jjtree.closeNodeScope(jjtn000, true);
    jjtc000 = false;
    jjtn000.setIdent(ident); /* set the identifier for this node */
    jjtn000.setOpAttr(opAttr);
    } catch (Exception jjte000) {
    if (jjtc000) {
      jjtree.clearNodeScope(jjtn000);
      jjtc000 = false;
    } else {
      jjtree.popNode();
    }
  {if (true) throw ;}
    } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
    }
  }
 /**
  * @see parser.IDLParserVisitor#visit(ASTop_dcl, Object)
  * @param data expected is an instance of BuildInfo, the operation is added to the type ((BuildInfo)data).getContainerType().
  */
 public Object visit(ASTop_dcl node, Object data) {
     CheckParameterForBuildInfo(data, node);
     BuildInfo buildInfo = (BuildInfo) data;
     
     // return type
     TypeContainer returnType = (TypeContainer)node.jjtGetChild(0).jjtAccept(this, buildInfo);        
     // parameters
     ParameterSpec[] parameters = (ParameterSpec[])node.jjtGetChild(1).jjtAccept(this, buildInfo);
     // name
     String methodName = IdlNaming.MapIdlNameToClsName(node.getIdent());
     String transmittedName = 
         IdlNaming.DetermineOperationTransmissionName(node.getIdent());
     // ready to create method
     TypeBuilder typeAtBuild = buildInfo.GetContainterType();
     MethodBuilder methodBuilder = 
         m_ilEmitHelper.AddMethod(typeAtBuild, methodName, transmittedName,
                                  parameters, returnType,
                                  MethodAttributes.Virtual | MethodAttributes.Abstract | MethodAttributes.Public |
                                  MethodAttributes.HideBySig | MethodAttributes.NewSlot);
     if (node.IsOneWay()) {
         AddOneWayAttribute(methodBuilder);
     }
     int currentChild = 2;
     if ((node.jjtGetNumChildren() > currentChild) && (node.jjtGetChild(currentChild) is ASTraises_expr)) {
         // has a raises expression, add attributes for allowed exceptions
         Type[] exceptionTypes = (Type[])node.jjtGetChild(2).jjtAccept(this, buildInfo);
         foreach (Type exceptionType in exceptionTypes) {
             methodBuilder.SetCustomAttribute(
                 new ThrowsIdlExceptionAttribute(exceptionType).CreateAttributeBuilder());
         }
         currentChild++;
     }        
     if ((node.jjtGetNumChildren() > currentChild) && (node.jjtGetChild(currentChild) is ASTcontext_expr)) {
         string[] contextElementAttrs = (string[])node.jjtGetChild(currentChild).jjtAccept(this, buildInfo);
         foreach (string contextElem in contextElementAttrs) {
             methodBuilder.SetCustomAttribute(
                 new ContextElementAttribute(contextElem).CreateAttributeBuilder());
         }
     }
     return null;
 }