Example #1
0
 public void Append(CSTWriter w)
 {
     w.Append('B');
     w.Append(Id);
     w.Append(':');
     w.EndLine();
     w.Indented
         (w2 =>
     {
         if (Sources.Count > 0)
         {
             w2.Append("(* from ");
             for (var i = 0; i < Sources.Count; i++)
             {
                 if (i > 0)
                 {
                     w2.Append(", ");
                 }
                 w2.Append("B");
                 w2.Append(Sources[i].Id);
             }
             w2.Append(" *)");
             w2.EndLine();
         }
         for (var i = 0; i < Block.Body.Count; i++)
         {
             Block.Body[i].Append(w2);
             w2.EndLine();
         }
         AppendLast(w);
         w2.EndLine();
     });
 }
Example #2
0
 public override void Append(CSTWriter w)
 {
     Array.Append(w, 1);
     w.Append('[');
     Index.Append(w, 0);
     w.Append(']');
 }
Example #3
0
 public void Append(CSTWriter w)
 {
     foreach (var customAttribute in CustomAttributes)
     {
         customAttribute.Append(w);
         w.EndLine();
     }
     w.Append("assembly ");
     Name.Append(w);
     w.Append(" {");
     w.EndLine();
     w.Indented(w2 => {
         foreach (var sn in References)
         {
             w2.Append(".reference ");
             sn.Append(w2);
             w2.EndLine();
         }
         if (EntryPoint != null)
         {
             w2.Append(".entry ");
             EntryPoint.Append(w2);
             w2.EndLine();
         }
         foreach (var namedTypeDef in Types)
         {
             namedTypeDef.AppendDefinition(w2);
             w2.EndLine();
         }
     });
     w.Append('}');
 }
Example #4
0
        public void Append(CSTWriter w)
        {
            switch (w.Style)
            {
            case WriterStyle.ReflectionName:
            {
                w.AppendName(Types[Types.Count - 1]);
                break;
            }

            case WriterStyle.ReflectionFullName:
            case WriterStyle.Uniform:
            case WriterStyle.Debug:
            {
                if (!string.IsNullOrEmpty(Namespace))
                {
                    w.AppendName(Namespace);
                    w.Append('.');
                }
                for (var i = 0; i < Types.Count; i++)
                {
                    if (i > 0)
                    {
                        w.Append('+');
                    }
                    w.AppendName(Types[i]);
                }
                break;
            }
            }
        }
Example #5
0
        public override void AppendModifiers(CSTWriter w)
        {
            switch (CodeFlavor)
            {
            case MethodCodeFlavor.Managed:
                break;

            case MethodCodeFlavor.ManagedExtern:
                w.Append("extern ");
                break;

            case MethodCodeFlavor.Native:
                w.Append("native ");
                break;

            case MethodCodeFlavor.Runtime:
                w.Append("runtime ");
                break;

            case MethodCodeFlavor.ForwardRef:
                w.Append("forwardref ");
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            if (HasNewSlot)
            {
                w.Append("newslot ");
            }
            if (IsSyncronized)
            {
                w.Append("syncronized ");
            }
            if (NoInlining)
            {
                w.Append("noinline ");
            }
            if (IsInitLocals)
            {
                w.Append("initlocals ");
            }
            switch (MethodStyle)
            {
            case MethodStyle.Normal:
            case MethodStyle.Constructor:
                break;

            case MethodStyle.Virtual:
                w.Append("virtual ");
                break;

            case MethodStyle.Abstract:
                w.Append("abstract ");
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Example #6
0
 public override void AppendLast(CSTWriter w)
 {
     w.Append("POP STACK ");
     w.Append(StackPopCount);
     w.Append(" LEAVE B");
     w.Append(Target.Id);
 }
Example #7
0
 public override void Append(CSTWriter w)
 {
     w.Append("box(");
     Box.Append(w, 0);
     w.Append(':');
     ValueType.Append(w);
     w.Append(')');
 }
Example #8
0
 public override void Append(CSTWriter w)
 {
     w.Append("CATCH ");
     w.Append("(* ");
     Type.Append(w);
     w.Append(" *) B");
     w.Append(Body.Id);
 }
Example #9
0
 public override void AppendLast(CSTWriter w)
 {
     w.Append("BRANCH ");
     Test.Append(w);
     w.Append(" B");
     w.Append(Target.Id);
     w.Append(" ELSE B");
     w.Append(Fallthrough.Id);
 }
Example #10
0
 public override void AppendLast(CSTWriter w)
 {
     w.Append("TRY B");
     w.Append(Body.Id);
     foreach (var h in Handlers)
     {
         w.Append(' ');
         h.Append(w);
     }
 }
Example #11
0
 public override void AppendDefinition(CSTWriter w)
 {
     base.AppendDefinition(w);
     w.Append(':');
     FieldType.Append(w);
     if (Init != null)
     {
         w.Append('=');
         Init.Append(w);
     }
 }
Example #12
0
        public override void Append(CSTWriter w, IImSeq <TypeRef> methodTypeArguments)
        {
            if (methodTypeArguments != null)
            {
                throw new InvalidOperationException("signature does not accept type arguments");
            }

            w.Append("field ");
            w.AppendName(Name);
            w.Append(':');
            FieldType.Append(w);
        }
Example #13
0
 public override void Append(CSTWriter w)
 {
     w.Append('[');
     for (var i = 0; i < Data.Length; i++)
     {
         if (i > 0)
         {
             w.Append(',');
         }
         w.Append(Data[i]);
     }
     w.Append(']');
 }
Example #14
0
        public override void Append(CSTWriter w)
        {
            switch (ParameterFlavor)
            {
            case ParameterFlavor.Type:
                w.Append('!');
                break;

            case ParameterFlavor.Method:
                w.Append("!!");
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            w.Append(Index.ToString());
        }
Example #15
0
        public void Append(CSTWriter w)
        {
            w.Append('[');
            Type.Append(w);
            w.Append('(');
            var first = true;

            foreach (var o in PositionalProperties)
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    w.Append(',');
                }
                w.AppendQuotedObject(o);
            }
            foreach (var kv in NamedProperties)
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    w.Append(',');
                }
                w.Append(kv.Key);
                w.Append('=');
                w.AppendQuotedObject(kv.Value);
            }
            w.Append(")]");
        }
Example #16
0
 public void Append(CSTWriter w)
 {
     Type.Append(w);
     if (UpperBound != null)
     {
         w.Append("<:");
         UpperBound.Append(w);
     }
 }
Example #17
0
        //
        // Pretty printing
        //

        public virtual void AppendDefinition(CSTWriter w)
        {
            foreach (var annotation in CustomAttributes)
            {
                annotation.Append(w);
                w.EndLine();
            }
            AppendFlavor(w);
            w.Append(IsStatic ? "static " : "instance ");
            AppendModifiers(w);
            w.AppendName(Name);
        }
Example #18
0
 public void Append(CSTWriter w)
 {
     // Print from bottom to top to match argument order
     w.Append("{[");
     for (var i = Depth - 1; i >= 0; i--)
     {
         if (i < Depth - 1)
         {
             w.Append(',');
         }
         if (innerState.Value.Ids != null)
         {
             w.AppendName(innerState.Value.Ids[i].Value);
             w.Append(':');
         }
         innerState.Value.Stack[i].Append(w);
     }
     w.Append(']');
     if (!innerState.Value.ArgsLocalsState.IsBottom)
     {
         w.Append(' ');
         innerState.Value.ArgsLocalsState.Append(w);
     }
     w.Append('}');
 }
Example #19
0
 public override void Append(CSTWriter w)
 {
     if (Object == null)
     {
         Field.DefiningType.Append(w);
     }
     else
     {
         Object.Append(w, 1);
     }
     w.Append('.');
     w.AppendName(Field.Name);
 }
Example #20
0
        public void Append(CSTWriter w)
        {
            switch (w.Style)
            {
            case WriterStyle.ReflectionFullName:
            case WriterStyle.Uniform:
                w.Append('[');
                Assembly.Append(w);
                w.Append(']');
                Type.Append(w);
                break;

            case WriterStyle.ReflectionName:
                // no assembly
                Type.Append(w);
                break;

            case WriterStyle.Debug:
            {
                // elide *mscorlib, elide assembly version etc
                if (Assembly.Name == null)
                {
                    w.Append('[');
                    w.Append(AssemblyName.unavailableSimpleName);
                    w.Append(']');
                }
                else if (!Assembly.Name.Contains(Global.MSCorLibSimpleName))
                {
                    w.Append('[');
                    w.AppendName(Assembly.Name);
                    w.Append(']');
                }
                // shorten the built-in type names
                var nm = default(string);
                if (w.Global.TypeNameToAbbreviation.TryGetValue(Type, out nm) && nm != null)
                {
                    w.Append(nm);
                }
                else
                {
                    Type.Append(w);
                }
                break;
            }

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Example #21
0
 public override void AppendLast(CSTWriter w)
 {
     w.Append(Label.Value);
     w.Append(": ");
     w.Append("LOOP B");
     w.Append(Head.Id);
     w.Append(" BREAK TO B");
     w.Append(Break.Id);
 }
Example #22
0
 public override void AppendLast(CSTWriter w)
 {
     w.Append("POP HANDLER ");
     w.Append(HandlerPopCount);
     w.Append(" POP STACK ");
     w.Append(StackPopCount);
     w.Append(" LEAVE CATCH B");
     w.Append(Target.Id);
 }
Example #23
0
 public override void AppendLast(CSTWriter w)
 {
     w.Append("SWITCH [ ");
     for (var i = 0; i < CaseTargets.Count; i++)
     {
         if (i > 0)
         {
             w.Append(", ");
         }
         w.Append('B');
         w.Append(CaseTargets[i].Id);
     }
     if (CaseTargets.Count > 0)
     {
         w.Append(", ");
     }
     w.Append("DEFAULT B");
     w.Append(Fallthrough.Id);
     w.Append(" ]");
 }
Example #24
0
 public override void AppendDefinition(CSTWriter w)
 {
     base.AppendDefinition(w);
     w.Append(':');
     FieldType.Append(w);
     w.Append(" {");
     if (Get != null)
     {
         w.Append(" get { ");
         Get.Append(w);
         w.Append(" }");
     }
     if (Set != null)
     {
         w.Append(" set { ");
         Set.Append(w);
         w.Append(" }");
     }
     w.Append(" }");
 }
Example #25
0
 public override void AppendDefinition(CSTWriter w)
 {
     base.AppendDefinition(w);
     w.Append(':');
     HandlerType.Append(w);
     w.Append(" {");
     if (Add != null)
     {
         w.Append(" add { ");
         Add.Append(w);
         w.Append(" }");
     }
     if (Remove != null)
     {
         w.Append(" remove {");
         Remove.Append(w);
         w.Append(" }");
     }
     w.Append(" }");
 }
Example #26
0
 public void Append(CSTWriter w)
 {
     w.Append("method ");
     w.Append(CompEnv.Method.Name);
     w.Append('(');
     for (var i = 0; i < CompEnv.ValueParameterIds.Count; i++)
     {
         if (i > 0)
         {
             w.Append(", ");
         }
         CompEnv.ValueParameterIds[i].Append(w);
         w.Append(':');
         CompEnv.Method.ValueParameters[i].Type.Append(w);
     }
     w.Append("){");
     w.EndLine();
     w.Indented
         (w2 =>
     {
         foreach (var kv in CompEnv.Variables)
         {
             if (kv.Value.ArgLocal == ArgLocal.Local)
             {
                 w2.Append("var ");
                 kv.Value.Id.Append(w2);
                 w2.Append(':');
                 kv.Value.Type.Append(w2);
                 if (kv.Value.IsInit)
                 {
                     w2.Append("=default");
                 }
                 w2.Append(';');
                 w2.EndLine();
             }
         }
         Body.Append(w2);
     });
     w.Append('}');
     w.EndLine();
 }
Example #27
0
        public override void Append(CSTWriter w, IImSeq <TypeRef> methodTypeArguments)
        {
            if (methodTypeArguments != null)
            {
                throw new InvalidOperationException("signature does not accept type arguments");
            }

            w.Append("property ");
            w.Append(IsStatic ? "static " : "instance ");
            w.AppendName(Name);
            w.Append('(');
            for (var i = 0; i < Parameters.Count; i++)
            {
                if (i > 0)
                {
                    w.Append(',');
                }
                Parameters[i].Append(w);
            }
            w.Append(')');
            w.Append(':');
            Result.Append(w);
        }
Example #28
0
 public override void Append(CSTWriter w)
 {
     DefiningType.Append(w);
     w.Append("::");
     signature.Append(w, MethodTypeArguments);
 }
Example #29
0
        //
        // Pretty printing
        //

        public virtual void Append(CSTWriter w)
        {
            DefiningType.Append(w);
            w.Append("::");
            Signature.Append(w);
        }
Example #30
0
 public override void AppendFlavor(CSTWriter w)
 {
     w.Append("field ");
 }