Example #1
0
        private void LoadClass( UmlTypeHolder scope, ClassDecl decl, UsingBlock usings )
        {
            // get cl from old classes, or create a new one
            UmlClass cl = null;
            foreach( UmlType ent in scope.Types ) {
                if( ent.name.Equals( decl.name.identifier ) && ent is UmlClass ) {
                    cl = (UmlClass)ent;
                    break;
                }
            }
            if( cl == null ) {
                cl = new UmlClass();
                scope.Types.Add( cl );
                added_classes.Add( cl );
            }

            // register class
            classes[cl] = decl;

            // fill with information
            switch( decl.kind ) {
                case Kind.Class:
                    cl.kind = UmlKind.Class; break;
                case Kind.Interface:
                    cl.kind = UmlKind.Interface; break;
                case Kind.Struct:
                    cl.kind = UmlKind.Struct; break;
            }
            cl.name = decl.name.identifier;
            cl.using_chain = usings;
            cl.Deleted = false;
            cl.IsAbstract = ( decl.modifiers != null && (decl.modifiers.value & (int)Modifiers.Abstract) != 0 );
            FillClassWithTypes( cl, decl );
        }
Example #2
0
        private void UpdateClass( UmlClass cl, ClassDecl classdecl )
        {
            if( classdecl.members != null )
                foreach( DeclNode decl in classdecl.members.nodes )
                    switch( decl.kind ) {
                        case Kind.Const:
                        case Kind.Fields:
                            FieldsDecl var = (FieldsDecl)decl;
                            string type = GetFullTypeName( GetTypeName( var.type ), cl );
                            string name;
                            foreach( Node n in var.declarators.nodes ) {
                                name = n is VariableNode ? ((VariableNode)n).name.identifier : n is ConstantNode ? ((ConstantNode)n).name.identifier : null;
                                UmlField f = (UmlField)GetMember( name, name, var.modifiers, decl.kind == Kind.Fields ? UmlKind.Field : UmlKind.Constant, cl );
                                f.Type = type;
                            }
                            break;
                        case Kind.UnaryOperator:
                        case Kind.BinaryOperator:
                        case Kind.Method:
                            MethodDecl meth = (MethodDecl)decl;
                            UmlKind uml_kind = decl.kind == Kind.Method ? UmlKind.Method : UmlKind.Operator;
                            UmlMethod m = (UmlMethod)GetMember( meth.name.identifier, GenerateSignature( meth.name.identifier, meth.parameters, cl, false ), meth.modifiers, uml_kind, cl );
                            m.ReturnType = GetFullTypeName( GetTypeName( meth.return_type ), cl );
                            m.Params = GetParameters( meth.parameters, cl );
                            break;
                        case Kind.Constructor:
                        case Kind.Destructor:
                            MethodDecl cdtor = (MethodDecl)decl;
                            name = decl.kind == Kind.Constructor ? cdtor.name.identifier : "~" + cdtor.name.identifier;
                            UmlMethod cdmemb = (UmlMethod)GetMember( name, GenerateSignature( name, cdtor.parameters, cl, false ), cdtor.modifiers, decl.kind == Kind.Constructor ? UmlKind.Constructor : UmlKind.Destructor, cl );
                            cdmemb.Params = GetParameters( cdtor.parameters, cl );
                            break;
                        case Kind.ConversionOperator:
                            meth = (MethodDecl)decl;
                            name = "operator " + GetFullTypeName( GetTypeName( meth.return_type ), cl );
                            UmlOperator op = (UmlOperator)GetMember( name, GenerateSignature( name, meth.parameters, cl, false ), meth.modifiers, UmlKind.Operator, cl );
                            op.Params = GetParameters( meth.parameters, cl );
                            break;
                        case Kind.Property:
                            PropertyNode prop = (PropertyNode)decl;
                            UmlProperty p = (UmlProperty)GetMember( prop.name.identifier, prop.name.identifier, prop.modifiers, UmlKind.Property, cl );
                            p.Type = GetFullTypeName( GetTypeName( prop.type ), cl );
                            p.Accessors = string.Empty;
                            if( prop.accessors != null )
                                foreach( AccessorNode an in prop.accessors.nodes )
                                    p.Accessors += an.name.identifier + ";";
                            break;
                        case Kind.EventVars:
                            UmlEvent ev;
                            EventNode evnt = (EventNode)decl;
                            type = GetFullTypeName( GetTypeName( evnt.type ), cl );
                            foreach( VariableNode n in evnt.vars.nodes ) {
                                ev = (UmlEvent)GetMember( n.name.identifier, n.name.identifier, evnt.modifiers, UmlKind.Event, cl );
                                ev.Type = type;
                                ev.Accessors = null;
                            }
                            break;
                        case Kind.EventWithAccessors:
                            evnt = (EventNode)decl;
                            ev = (UmlEvent)GetMember( evnt.name.identifier, evnt.name.identifier, evnt.modifiers, UmlKind.Event, cl );
                            ev.Type = GetFullTypeName( GetTypeName( evnt.type ), cl );
                            ev.Accessors = String.Empty;
                            if( evnt.accessors != null )
                                foreach( AccessorNode an in evnt.accessors.nodes )
                                    ev.Accessors += an.name.identifier + ";";
                            break;
                        case Kind.Indexer:
                            IndexerNode inode = (IndexerNode)decl;
                            UmlIndexer indx = (UmlIndexer)GetMember( inode.name.identifier, GenerateSignature( inode.name.identifier, inode.formal_params, cl, true ), inode.modifiers, UmlKind.Indexer, cl );
                            indx.ReturnType = GetFullTypeName( GetTypeName( inode.type ), cl );
                            indx.Params = GetParameters( inode.formal_params, cl );
                            break;
                        case Kind.Delegate:
                        case Kind.Enum:
                        case Kind.Class:
                        case Kind.Interface:
                        case Kind.Struct:
                            break;      // handled earlier
                        default:
                            System.Diagnostics.Debug.Fail( "unknown class member" );
                            break;
                    }

            // kill deleted
            if( cl.Members != null )
                for( int i = 0; i < cl.Members.Count; i++ ) {
                    UmlObject obj = (UmlObject)cl.Members[i];
                    if( obj.Deleted ) {
                        cl.Members.RemoveAt( i );
                        i--;
                    }
                }
        }
Example #3
0
 private void FillClassWithTypes( UmlClass cl, ClassDecl classdecl )
 {
     if( classdecl.members != null )
         foreach( DeclNode decl in classdecl.members.nodes )
             switch( decl.kind ) {
                 case Kind.Interface:
                 case Kind.Struct:
                 case Kind.Class:
                     LoadClass( cl, (ClassDecl)decl, null );
                     break;
                 case Kind.Delegate:
                     LoadDelegate( cl, (DelegateNode)decl, null );
                     break;
                 case Kind.Enum:
                     LoadEnum( cl, (EnumDecl)decl, null );
                     break;
             }
 }
Example #4
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;
 }