Exemplo n.º 1
0
 private void defineDelegateMembers(DelegateDeclarationNode delegateDeclaration) {
     var typeBuilder = delegateDeclaration.getUserData(typeof(TypeBuilder));
     context.CurrentType = typeBuilder;
     setTypeParameters(typeBuilder, delegateDeclaration.TypeParameters, delegateDeclaration);
     try {
         context.MemberResolver.enterType(typeBuilder);
         
         // invoke()
         var methodBuilder = typeBuilder.defineMethod("invoke");
         methodBuilder.setReturnType(CompilerHelper.resolveTypeReference(context, typeBuilder.PackageName, delegateDeclaration.ReturnType));
         foreach (var p in delegateDeclaration.Parameters) {
             var pb = methodBuilder.addParameter(CompilerHelper.resolveTypeReference(context, typeBuilder.PackageName, p.Type));
             pb.setName(context.getIdentifier(p.NameOffset, p.NameLength));
         }
         methodBuilder.setAbstract(true);
         methodBuilder.setPublic(true);
         
         // TODO: async invoke
         
         // Constructor
         methodBuilder = typeBuilder.defineMethod("<init>");
         methodBuilder.setProtected(true);
         methodBuilder.setReturnType(context.TypeSystem.VoidType);
         var pb = methodBuilder.addParameter(context.TypeSystem.ObjectType);
         pb.setName("target");
     } finally {
         context.MemberResolver.leaveType();
     }
 }
Exemplo n.º 2
0
 private void setDelegateBaseTypes(DelegateDeclarationNode delegateDeclaration) {
     var typeBuilder = delegateDeclaration.getUserData(typeof(TypeBuilder));
     typeBuilder.setBaseType(context.getType("stab/lang/Delegate", delegateDeclaration));
 }