void buildPackageDocumentation(String packageName, PackageDeclarationNode packageDeclaration) {
     var comment = ParserHelper.decodeDocumentation(context.Text, packageDeclaration.DocumentationOffset,
             packageDeclaration.DocumentationLength);
     memberKind = null;
     node = packageDeclaration;
     appendDocumentation("N:" + packageName, comment);
 }
 void buildMethodDocumentation(MethodInfo method, TypeMemberNode methodDeclaration) {
     var comment = ParserHelper.decodeDocumentation(context.Text, methodDeclaration.DocumentationOffset,
             methodDeclaration.DocumentationLength);
     memberKind = MemberKind.Method;
     this.method = method;
     node = methodDeclaration;
     appendDocumentation(getIdString(method), comment);
 }
 void buildFieldDocumentation(FieldInfo field, TypeMemberNode fieldDeclaration) {
     var comment = ParserHelper.decodeDocumentation(context.Text, fieldDeclaration.DocumentationOffset,
             fieldDeclaration.DocumentationLength);
     memberKind = MemberKind.Field;
     this.field = field;
     node = fieldDeclaration;
     appendDocumentation(getIdString(field), comment);
 }
 void buildTypeDocumentation(TypeInfo type, TypeMemberNode typeDeclaration) {
     var comment = ParserHelper.decodeDocumentation(context.Text, typeDeclaration.DocumentationOffset,
             typeDeclaration.DocumentationLength);
     memberKind = MemberKind.Type;
     this.type = type;
     node = typeDeclaration;
     appendDocumentation(getIdString(type), comment);
 }
Ejemplo n.º 5
0
 private TypeBuilder defineNestedType(TypeBuilder declaringClass, String className, String shortName, SyntaxNode node) {
     if (context.TypeSystem.typeExists(className)) {
         throw context.error(CompileErrorId.AlreadyDefinedType, node, className.replace('/', '.').replace('$', '.'));
     }
     var result = declaringClass.defineNestedType(shortName);
     context.TypeBuilders.add(result);
     return result;
 }
Ejemplo n.º 6
0
 private void setTypeParameters(MethodBuilder methodBuilder, List<SimpleNameTypeReferenceNode> typeParameters, SyntaxNode node) {
     if (typeParameters.size() > 0) {
         var genericParams = getTypeParameterNames(typeParameters);
         int i = 0;
         if (methodBuilder.GenericArguments.any()) {
             var it1 = genericParams.iterator();
             var it2 = methodBuilder.GenericArguments.iterator();
             while (it1.hasNext() && it2.hasNext()) {
                 if (!it1.next().equals(it2.next().FullName)) {
                     throw context.error(CompileErrorId.PartialTypeArgumentsMismatch, node,
                         BytecodeHelper.getDisplayName(methodBuilder.DeclaringType) + '.' + methodBuilder.Name);
                 }
                 i++;
             }
             if (it2.hasNext()) {
                 throw context.error(CompileErrorId.PartialTypeArgumentsMismatch, node,
                     BytecodeHelper.getDisplayName(methodBuilder.DeclaringType) + '.' + methodBuilder.Name);
             }
         }
         for (; i < genericParams.size(); i++) {
             methodBuilder.addGenericArgument(genericParams[i]);
         }
     }
 }
Ejemplo n.º 7
0
        private TypeBuilder defineType(String name, SyntaxNode node) {
			if (context.TypeSystem.typeExists(name)) {
				throw context.error(CompileErrorId.AlreadyDefinedType, node, name.replace('/', '.').replace('$', '.'));
			}
			var result = context.TypeSystem.defineType(name);
			context.TypeBuilders.add(result);
			return result;
        }
Ejemplo n.º 8
0
 private void checkAccessors(EnumSet<Modifier> modifiers, AccessorDeclarationNode get, AccessorDeclarationNode set, SyntaxNode node) {
     if (get != null && set != null) {
         if (!get.Modifiers.isEmpty() && !set.Modifiers.isEmpty()) {
             context.addError(CompileErrorId.IllegalGetOrSetModifiers, node);
         }
         if ((get.Body == null) != (set.Body == null)) {
             context.addError(CompileErrorId.IllegalGetOrSetBody, node);
         }
     } else if (get != null) {
         if (!get.Modifiers.isEmpty()) {
             context.addError(CompileErrorId.IllegalGetOrSetModifiers, node);
         }
         if (!modifiers.contains(Modifier.Abstract) && get.Body == null) {
             context.addError(CompileErrorId.IllegalGetOrSetBody, node);
         }
     } else {
         if (!set.Modifiers.isEmpty()) {
             context.addError(CompileErrorId.IllegalGetOrSetModifiers, node);
         }
         if (!modifiers.contains(Modifier.Abstract) && set.Body == null) {
             context.addError(CompileErrorId.IllegalGetOrSetBody, node);
         }
     }
 }
Ejemplo n.º 9
0
 private static void copyScannerState(SyntaxNode node1, SyntaxNode node2) {
     node2.Filename = node1.Filename;
     node2.Line = node1.Line;
     node2.Column = node1.Column;
     node2.DisabledWarnings = node1.DisabledWarnings;
     node2.StartPosition = node1.StartPosition;
     node2.EndPosition = node1.EndPosition;
 }
Ejemplo n.º 10
0
        private void setSavedScannerState(SyntaxNode node) {
            node.Filename = savedFilename;
            node.Line = savedLine;
            node.Column = savedColumn;
            node.DisabledWarnings = savedDisabledWarnings;
			if (node.StartPosition == -1) {
				node.StartPosition = savedStartPosition;
			}
        }
Ejemplo n.º 11
0
        private void setScannerState(SyntaxNode node) {
            node.Filename = scanner.Filename;
            node.Line = scanner.StartLine;
            node.Column = scanner.StartColumn;
            node.DisabledWarnings = scanner.CodeErrorManager.DisabledWarnings;
			if (node.StartPosition == -1) {
				node.StartPosition = scanner.StartPosition;
			}
        }
 bool resolveDelegate(TypeInfo type, ExpressionNode arg, ExpressionInfo targetInfo, SyntaxNode node) {
     var invokeMethod = getInvokeMethod(type);
     int nparams = invokeMethod.Parameters.count();
     var ainfo = arg.getUserData(typeof(ExpressionInfo));
     if (ainfo.Members == null) {
         return true;
     }
     MemberInfo foundMember = null;
     foreach (var member in ainfo.Members) {
         switch (member.MemberKind) {
         case Method:
             var meth = member.Method;
             if (meth.Parameters.count() != nparams || meth.IsVarargs != invokeMethod.IsVarargs) {
                 continue;
             }
             if (nparams == 0) {
                 if (foundMember != null) {
                     if (node != null) {
                         throw context.error(CompileErrorId.AmbiguousMembers, node,
                             BytecodeHelper.getDisplayName(member.DeclaringType) + "." + BytecodeHelper.getDisplayName(member.Method),
                             BytecodeHelper.getDisplayName(foundMember.DeclaringType) + "."
                             + BytecodeHelper.getDisplayName(foundMember.Method));
                     } else {
                         return false;
                     }
                 }
                 foundMember = member;
                 ainfo.Member = member;
                 if (meth.IsExcludedFromCompilation || CompilerHelper.shouldIgnoreCalls(context, meth)) {
                     if (node != null) {
                         throw context.error(CompileErrorId.NotGeneratedMethodUsage, node,
                             BytecodeHelper.getDisplayName(member.DeclaringType) + "." + BytecodeHelper.getDisplayName(member.Method));
                     } else {
                         return false;
                     }
                 }
                 if (targetInfo != null) {
                     targetInfo.Type = type;
                     targetInfo.Method = meth;
                 }
                 continue;
             }
             var it1 = meth.Parameters.iterator();
             var it2 = invokeMethod.Parameters.iterator();
             var sameParams = true;
             while (it1.hasNext()) {
                 if (it1.next().Type != it2.next().Type) {
                     sameParams = false;
                     break;
                 }
             }
             if (sameParams) {
                 if (foundMember != null) {
                     if (node != null) {
                         throw context.error(CompileErrorId.AmbiguousMembers, node,
                             BytecodeHelper.getDisplayName(member.DeclaringType) + "." + BytecodeHelper.getDisplayName(member.Method),
                             BytecodeHelper.getDisplayName(foundMember.DeclaringType) + "." + foundMember.Name);
                     } else {
                         return false;
                     }
                 }
                 foundMember = member;
                 ainfo.Member = member;
                 if (targetInfo != null) {
                     targetInfo.Type = type;
                     targetInfo.Method = meth;
                 }
                 continue;
             }
             break;
         case Local:
             ainfo.Member = member;
             return true;
         case Field:
         case Property:
             foundMember = member;
             ainfo.Member = member;
             break;
         }
     }
     if (foundMember != null) {
         return true;
     }
     if (node != null) {
         throw context.error(CompileErrorId.NoEligibleOverload, node, ainfo.Members.first().Name);
     } else {
         return false;
     }
 }