Пример #1
0
        private UmlMember GetMember( string name, string signature, ModifiersNode mod, UmlKind kind, UmlClass cl )
        {
            UmlMember member = null;

            if( cl.Members == null )
                cl.Members = new ArrayList();
            else
                foreach( UmlMember m in cl.Members )
                    if( m.signature.Equals( signature ) ) {
                        member = m;
                        break;
                    }

            recreate:
            if( member == null ) {
                switch( kind ) {
                    case UmlKind.Constant:	member = new UmlConstant(); break;
                    case UmlKind.Field:		member = new UmlField(); break;
                    case UmlKind.Method:	member = new UmlMethod(); break;
                    case UmlKind.Property:	member = new UmlProperty(); break;
                    case UmlKind.Event:		member = new UmlEvent(); break;
                    case UmlKind.Indexer:	member = new UmlIndexer(); break;
                    case UmlKind.Operator:	member = new UmlOperator(); break;
                    case UmlKind.Constructor:member = new UmlConstructor(); break;
                    case UmlKind.Destructor:member = new UmlDestructor(); break;
                }
                System.Diagnostics.Debug.Assert( member != null, "unknown Member kind" );
                member.signature = signature;
                member.name = name;
                cl.Members.Add( member );
            } else {
                if( member.Kind != kind ) {
                    cl.Members.Remove( member );
                    member = null;
                    goto recreate;
                }

                member.Deleted = false;
            }

            member.visibility = cl.Kind == UmlKind.Interface ? UmlVisibility.Public : UmlVisibility.Private;
            if( mod != null ) {
                if( (mod.value & (int)Modifiers.Internal) != 0 && (mod.value & (int)Modifiers.Protected) != 0 )
                    member.visibility = UmlVisibility.ProtectedInternal;
                else if( (mod.value & (int)Modifiers.Internal) != 0 )
                    member.visibility = UmlVisibility.Internal;
                else if( (mod.value & (int)Modifiers.Protected) != 0 )
                    member.visibility = UmlVisibility.Protected;
                else if( (mod.value & (int)Modifiers.Public) != 0 )
                    member.visibility = UmlVisibility.Public;
                else if( (mod.value & (int)Modifiers.Private) != 0 )
                    member.visibility = UmlVisibility.Private;

                if( (mod.value & (int)Modifiers.Static) != 0 )
                    member.IsStatic = true;
                if( (mod.value & (int)Modifiers.Abstract) != 0 )
                    member.IsAbstract = true;
            }

            return member;
        }
Пример #2
0
 internal static PropertyNode Property( ListNode attributes, ModifiersNode modifiers, TypeNode type, IdentNode name, ListNode accessors, Symbol s )
 {
     PropertyNode res = new PropertyNode();
     res.kind = Kind.Property;
     res.start = s.pos;
     res.end = s.endpos;
     res.attributes = attributes;
     res.modifiers = modifiers;
     res.type = type;
     res.name = name;
     res.accessors = accessors;
     return res;
 }
Пример #3
0
 internal static ModifiersNode SumModifiers( ModifiersNode m1, ModifiersNode m2 )
 {
     m1.end = m2.end;
     m1.value |= m2.value;
     m1.start_pos.AddRange( m2.start_pos );
     return m1;
 }
Пример #4
0
 internal static MethodDecl Operator( ModifiersNode mod, TypeNode type, IdentNode name, ParameterNode op1, ParameterNode op2, Symbol s )
 {
     ListNode ln = new ListNode();
     ln.nodes = new ArrayList();
     ln.nodes.Add( op1 );
     if( op2 != null )
         ln.nodes.Add( op2 );
     ln.start = op1.start;
     ln.end = op2 != null ? op2.end : op1.end;
     ln.kind = Kind.List;
     return Method( name == null ? Kind.ConversionOperator : op2 == null ? Kind.UnaryOperator : Kind.BinaryOperator, null, mod, name, type, ln, null, null, s );
 }
Пример #5
0
 internal static ParameterNode Parameter( ListNode attributes, ModifiersNode modifiers, TypeNode type, IdentNode name, Symbol s )
 {
     ParameterNode res = new ParameterNode();
     res.kind = Kind.Param;
     res.start = s.pos;
     res.end = s.endpos;
     res.attributes = attributes;
     res.modifiers = modifiers;
     res.type = type;
     res.name = name;
     return res;
 }
Пример #6
0
 internal static MethodDecl Method( Kind k, ListNode attributes, ModifiersNode modifiers, IdentNode name, TypeNode return_type, ListNode parameters, StatementNode body, ConstructorInitializerNode base_init, Symbol s )
 {
     MethodDecl res = new MethodDecl();
     res.kind = k;
     res.start = s.pos;
     res.end = s.endpos;
     res.attributes = attributes;
     res.modifiers = modifiers;
     res.name = name;
     res.return_type = return_type;
     res.parameters = parameters;
     res.body = body;
     res.base_init = base_init;
     return res;
 }
Пример #7
0
 internal static ModifiersNode Modifiers( int value, Symbol s )
 {
     ModifiersNode res = new ModifiersNode();
     res.kind = Kind.Modifiers;
     res.start = s.pos;
     res.end = s.endpos;
     res.value = value;
     res.start_pos.Add( s.pos.offset );
     return res;
 }
Пример #8
0
 internal static FieldsDecl Fields( Kind k, ListNode attributes, ModifiersNode modifiers, TypeNode type, ListNode declarators, Symbol s )
 {
     FieldsDecl res = new FieldsDecl();
     res.kind = k;
     res.start = s.pos;
     res.end = s.endpos;
     res.attributes = attributes;
     res.modifiers = modifiers;
     res.type = type;
     res.declarators = declarators;
     return res;
 }
Пример #9
0
 internal static IndexerNode Indexer( ListNode attributes, ModifiersNode modifiers, TypeNode type, IdentNode name, ListNode formal_params, ListNode accessors, Symbol s )
 {
     IndexerNode res = new IndexerNode();
     res.kind = Kind.Indexer;
     res.start = s.pos;
     res.end = s.endpos;
     res.attributes = attributes;
     res.modifiers = modifiers;
     res.type = type;
     res.name = name;
     res.formal_params = formal_params;
     res.accessors = accessors;
     return res;
 }
Пример #10
0
 internal static EventNode Event( Kind k, ListNode attributes, ModifiersNode modifiers, TypeNode type, IdentNode name, ListNode accessors, ListNode vars, Symbol s )
 {
     EventNode res = new EventNode();
     res.kind = k;
     res.start = s.pos;
     res.end = s.endpos;
     res.attributes = attributes;
     res.modifiers = modifiers;
     res.type = type;
     res.name = name;
     res.accessors = accessors;
     res.vars = vars;
     return res;
 }
Пример #11
0
 internal static EnumDecl Enum( ListNode attributes, ModifiersNode modifiers, IdentNode name, TypeNode basetype, ListNode children, Symbol s )
 {
     EnumDecl res = new EnumDecl();
     res.kind = Kind.Enum;
     res.start = s.pos;
     res.end = s.endpos;
     res.attributes = attributes;
     res.modifiers = modifiers;
     res.name = name;
     res.basetype = basetype;
     res.children = children;
     return res;
 }
Пример #12
0
 internal static DelegateNode Delegate( ListNode attributes, ModifiersNode modifiers, IdentNode name, TypeNode return_type, ListNode parameters, Symbol s )
 {
     DelegateNode res = new DelegateNode();
     res.kind = Kind.Delegate;
     res.start = s.pos;
     res.end = s.endpos;
     res.attributes = attributes;
     res.modifiers = modifiers;
     res.name = name;
     res.return_type = return_type;
     res.parameters = parameters;
     return res;
 }
Пример #13
0
 internal static ClassDecl Class( Kind k, ListNode attributes, ModifiersNode modifiers, IdentNode name, ListNode inheritance, ListNode members, Symbol s )
 {
     ClassDecl res = new ClassDecl();
     res.kind = k;
     res.start = s.pos;
     res.end = s.endpos;
     res.attributes = attributes;
     res.modifiers = modifiers;
     res.name = name;
     res.inheritance = inheritance;
     res.members = members;
     return res;
 }
Пример #14
0
 internal static void AddModifier( ModifiersNode mod, int next, int next_offset, Symbol s )
 {
     mod.value |= next;
     mod.start_pos.Add( next_offset );
     mod.end = s.endpos;
 }