2007-10-12 Marek Safar <marek.safar@gmail.com>
[mono.git] / mcs / mcs / gen-treedump.cs
old mode 100755 (executable)
new mode 100644 (file)
index 42033f6..a4dbf32
@@ -55,11 +55,6 @@ namespace Generator {
                        output (s);
                }
 
-               string GetType (Type type)
-               {
-                       return type.Name;
-               }
-
                string GetParameter (Parameter par)
                {
                        Parameter.Modifier f = par.ModFlags;
@@ -75,7 +70,7 @@ namespace Generator {
                        case Parameter.Modifier.NONE:
                                mod = ""; break;
                        }
-                       return mod + GetType (par.Type) + " " + par.Name;
+                       return mod + par.Type + " " + par.Name;
                }
 
                string GetUnary (Unary u, int paren_level)
@@ -86,22 +81,22 @@ namespace Generator {
                        int prec = 0;
                        
                        switch (u.Oper){
-                       case Unary.Operator.Plus:
+                       case Unary.Operator.UnaryPlus:
                                prec = 10;
                                s = "+";
                                break;
                                
-                       case Unary.Operator.Minus:
+                       case Unary.Operator.UnaryNegation:
                                prec = 10;
                                s = "-";
                                break;
                                
-                       case Unary.Operator.Negate:
+                       case Unary.Operator.LogicalNot:
                                s = "!";
                                prec = 10;
                                break;
                                
-                       case Unary.Operator.BitComplement:
+                       case Unary.Operator.OnesComplement:
                                prec = 10;
                                s = "~";
                                break;
@@ -163,27 +158,27 @@ namespace Generator {
                                        prec = 9;
                                        op = "*"; break;
 
-                               case Binary.Operator.Divide:
+                               case Binary.Operator.Division:
                                        prec = 9;
                                        op = "/"; break;
                                
-                               case Binary.Operator.Modulo:
+                               case Binary.Operator.Modulus:
                                        prec = 9;
                                        op = "%"; break;
                                
-                               case Binary.Operator.Add:
+                               case Binary.Operator.Addition:
                                        prec = 8;
                                        op = "+"; break;
                                
-                               case Binary.Operator.Substract:
+                               case Binary.Operator.Subtraction:
                                        prec = 8;
                                        op = "-"; break;
                                
-                               case Binary.Operator.ShiftLeft:
+                               case Binary.Operator.LeftShift:
                                        prec = 7;
                                        op = "<<"; break;
                                
-                               case Binary.Operator.ShiftRight:
+                               case Binary.Operator.RightShift:
                                        prec = 7;
                                        op = ">>"; break;
                                
@@ -191,23 +186,23 @@ namespace Generator {
                                        prec = 6;
                                        op = "<"; break;
                                
-                               case Binary.Operator.GreatherThan:
+                               case Binary.Operator.GreaterThan:
                                        prec = 6;
                                        op = ">"; break;
                                
-                               case Binary.Operator.LessOrEqual:
+                               case Binary.Operator.LessThanOrEqual:
                                        prec = 6;
                                        op = "<="; break;
                                
-                               case Binary.Operator.GreatherOrEqual:
+                               case Binary.Operator.GreaterThanOrEqual:
                                        prec = 6;
                                        op = ">="; break;
                                
-                               case Binary.Operator.Equal:
+                               case Binary.Operator.Equality:
                                        prec = 5;
                                        op = "=="; break;
                                
-                               case Binary.Operator.NotEqual:
+                               case Binary.Operator.Inequality:
                                        prec = 5;
                                        op = "!="; break;
                                
@@ -243,7 +238,7 @@ namespace Generator {
 
                string GetCast (Cast c)
                {
-                       return "(" + c.TargetType.Name + ") (" + GetExpression (c.Expr, 0) + ")";
+                       return "(" + c.TargetType + ") (" + GetExpression (c.Expr, 0) + ")";
                }
 
                string GetConditional (Conditional c)
@@ -268,7 +263,7 @@ namespace Generator {
                                for (int i = 0; i < top; i++){
                                        Argument arg = (Argument) args [i];
                                                
-                                       switch (arg.Type){
+                                       switch (arg.ArgType){
                                                case Argument.AType.Ref:
                                                        r += "ref "; break;
                                                case Argument.AType.Out:
@@ -291,17 +286,17 @@ namespace Generator {
 
                string GetNew (New n)
                {
-                       return "new " + n.RequestedType.Name + GetArguments (n.Arguments);
+                       return "new " + n.RequestedType + GetArguments (n.Arguments);
                }
 
                string GetTypeOf (TypeOf t)
                {
-                       return "typeof (" + t.QueriedType.Name + ")";
+                       return "typeof (" + t.QueriedType + ")";
                }
 
                string GetSizeOf (SizeOf t)
                {
-                       return "sizeof (" + t.QueriedType.Name + ")";
+                       return "sizeof (" + t.QueriedType + ")";
                }
 
                string GetMemberAccess (MemberAccess m)
@@ -332,7 +327,7 @@ namespace Generator {
                        else
                                s += "UNHANDLED";
 
-                       s += GetType (p.ProbeType);
+                       s += p.ProbeType;
 
                        return s;
                }
@@ -397,15 +392,15 @@ namespace Generator {
                
                void GenerateParameters (Parameters pars)
                {
-                       ParameterCollection pfixed;
+                       Parameter [] pfixed;
                        Parameter parray;
 
                        pfixed = pars.FixedParameters;
 
                        if (pfixed != null){
-                               for (int i = 0; i < pfixed.Count; i++){
-                                       output (GetParameter ((Parameter) pfixed [i]));
-                                       if (i+1 != pfixed.Count)
+                               for (int i = 0; i < pfixed.Length; i++){
+                                       output (GetParameter (pfixed [i]));
+                                       if (i+1 != pfixed.Length)
                                                output (", ");
                                }
                        }
@@ -453,12 +448,12 @@ namespace Generator {
                void GenerateFor (For s)
                {
                        output ("for (");
-                       if (! (s.InitStatement is EmptyStatement))
+                       if (! (s.InitStatement == EmptyStatement.Value))
                                GenerateStatement (s.InitStatement, true, true, true);
                        output ("; ");
                        output (GetExpression (s.Test, 0));
                        output ("; ");
-                       if (! (s.InitStatement is EmptyStatement))
+                       if (! (s.Increment == EmptyStatement.Value))
                                GenerateStatement (s.Increment, true, true, true);
                        output (") ");
                        GenerateStatement (s.Statement, true, true, false);
@@ -532,7 +527,7 @@ namespace Generator {
                                output ("catch ");
                                
                                if (c.Type != null){
-                                       output ("(" + GetType (c.Type) +
+                                       output ("(" + c.Type +
                                                (c.Name != null ? " " + c.Name : "") + ")");
                                } 
                                GenerateBlock (c.Block, false, false);
@@ -594,7 +589,7 @@ namespace Generator {
                                output_newline ("break;");
                        else if (s is Continue)
                                output_newline ("continue;");
-                       else if (s is EmptyStatement)
+                       else if (s == EmptyStatement.Value)
                                output_newline ("/* empty statement */;");
                        else if (s is Block)
                                GenerateBlock ((Block) s, doPlacement, embedded);
@@ -636,10 +631,12 @@ namespace Generator {
 
                        if (b.Variables != null){
                                foreach (DictionaryEntry entry in b.Variables){
+                                       VariableInfo vi = (VariableInfo) entry.Value;
+                                       
                                        space ();
                                        output_newline (
-                                               (((CIR.TypeRef)entry.Value).Type).Name + " " +
-                                               (string)entry.Key + ";");
+                                               vi.Type + " " +
+                                               (string) entry.Key + ";");
                                }
                                newline ();
                        }
@@ -659,7 +656,7 @@ namespace Generator {
                void GenerateMethod (Method m)
                {
                        ioutput (GetModifiers (m.ModFlags) +
-                                GetType (m.ReturnType) + " " +
+                                m.ReturnType + " " +
                                 m.Name + " (");
                        GenerateParameters (m.Parameters);
                        output_newline (")");
@@ -669,20 +666,11 @@ namespace Generator {
                        newline ();
                }
 
-               void GenerateMethodGroup (MethodGroup mg)
-               {
-                       foreach (DictionaryEntry de in mg.Methods){
-                               Method m = (Method) de.Value;
-
-                               GenerateMethod (m);
-                       }
-               }
-               
                void GenerateInterfaceMethod (InterfaceMethod imethod)
                {
                        space ();
                        output (imethod.IsNew ? "new " : "");
-                       output (GetType (imethod.ReturnType) + " " + imethod.Name + " (");
+                       output (imethod.ReturnType + " " + imethod.Name + " (");
                        GenerateParameters (imethod.Parameters);
                        output (");");
                        newline ();
@@ -692,7 +680,7 @@ namespace Generator {
                {
                        space ();
                        output (iprop.IsNew ? "new " : "");
-                       output (GetType (iprop.Type) + " " + iprop.Name + " { ");
+                       output (iprop.Type + " " + iprop.Name + " { ");
                        if (iprop.HasGet) output ("get; ");
                        if (iprop.HasSet) output ("set; ");
                        output ("}");
@@ -703,7 +691,7 @@ namespace Generator {
                {
                        space ();
                        output ((ievent.IsNew ? "new " : "") + "event ");
-                       output (GetType (ievent.Type) + " " + ievent.Name + ";");
+                       output (ievent.Type + " " + ievent.Name + ";");
                        newline ();
                }
                
@@ -711,7 +699,7 @@ namespace Generator {
                {
                        space ();
                        output (iindexer.IsNew ? "new " : "");
-                       output (GetType (iindexer.Type) + " this [");
+                       output (iindexer.Type + " this [");
                        output (iindexer.Parameters + "] {");
                        if (iindexer.HasGet) output ("get; ");
                        if (iindexer.HasSet) output ("set; ");
@@ -768,7 +756,7 @@ namespace Generator {
                {
                        space ();
                        output (GetModifiers (f.ModFlags) + 
-                               GetType (f.Type) + " " + f.Name);
+                               f.Type + " " + f.Name);
                        if (f.Initializer != null){
                                if (f.Initializer is Expression)
                                        output (" = " + GetExpression ((Expression) f.Initializer, 0));
@@ -803,7 +791,7 @@ namespace Generator {
                void GenerateProperty (Property prop)
                {
                        space ();
-                       output (GetModifiers (prop.ModFlags) + GetType (prop.Type) +
+                       output (GetModifiers (prop.ModFlags) + prop.Type +
                                " " + prop.Name + " {");
                        newline ();
                        indent++;
@@ -852,12 +840,10 @@ namespace Generator {
                void GenerateTypeContainerData (TypeContainer tc)
                {
                        if (tc.Constants != null){
-                               foreach (DictionaryEntry cde in tc.Constants){
-                                       Constant c = tc.GetConstant ((string) cde.Key);
-
+                               foreach (Constant c in tc.Constants){
                                        space ();
 
-                                       output ("const " + c.ConstantType.Name + " " + c.name + " = " +
+                                       output ("const " + c.ConstantType + " " + c.Name + " = " +
                                                GetExpression (c.Expr, 0) + ";");
                                        newline ();
                                }
@@ -865,47 +851,34 @@ namespace Generator {
                        }
 
                        if (tc.Enums != null){
-                               foreach (DictionaryEntry ede in tc.Enums){
-                                       CIR.Enum e = (CIR.Enum) ede.Value;
-
+                               foreach (CIR.Enum e in tc.Enums)
                                        GenerateEnum (e);
-                               }
                        }
 
                        if (tc.Fields != null){
-                               foreach (DictionaryEntry de in tc.Fields){
-                                       Field f = (Field) de.Value;
-
+                               foreach (Field f in tc.Fields)
                                        GenerateField (f);
-                               }
                                newline ();
                        }
 
                        if (tc.Constructors != null){
-                               foreach (DictionaryEntry de in tc.Constructors){
-                                       Constructor c = (Constructor) de.Value;
-
+                               foreach (Constructor c in tc.Constructors)
                                        GenerateConstructor (c);
-                               }
+
                                newline ();
                                        
                        }
 
                        if (tc.Properties != null){
-                               foreach (DictionaryEntry de in tc.Properties){
-                                       Property prop = (Property) de.Value;
-
+                               foreach (Property prop in tc.Properties)
                                        GenerateProperty (prop);
-                               }
                        }
                        
                        GenerateFromTypes (tc);
                        
-                       if (tc.MethodGroups != null){
-                               foreach (DictionaryEntry de in tc.MethodGroups){
-                                       MethodGroup mg = (MethodGroup) de.Value;
-                                       
-                                       GenerateMethodGroup (mg);
+                       if (tc.Methods != null){
+                               foreach (Method m in tc.Methods){
+                                       GenerateMethod (m);
                                }
                        }
                }
@@ -925,7 +898,7 @@ namespace Generator {
                string ClassName (string name)
                {
                        return name;
-                       //return name.Substring (1 + name.LastIndexOf ("."));
+                       //return name.Substring (1 + name.LastIndexOf ('.'));
                }
 
                string GenBases (ArrayList bases)