Esempio n. 1
0
 public override void ToString(NodeWriter writer)
 {
     writer.OpenNode("func");
     writer.WriteFunctionName(this);
     for (var i = 0; i < Parameters.Count; i++)
     {
         var param = Parameters[i];
         writer.OpenNode("param");
         if (Execution != null)
         {
             writer.EnsureSpace();
             writer.Write($"${param.Name}");
         }
         writer.WriteValue(param.Type);
         writer.CloseNode();
     }
     if (Signature.Return != WasmType.BlockType)
     {
         writer.OpenNode("result");
         writer.WriteValue(Signature.Return);
         writer.CloseNode();
     }
     if (Execution != null)
     {
         writer.EnsureNewLine();
         foreach (var local in Variables)
         {
             local.ToString(writer);
         }
         Execution.ToString(writer);
         writer.EnsureNewLine();
     }
     writer.CloseNode();
 }
Esempio n. 2
0
        public override void ToString(NodeWriter writer)
        {
            writer.EnsureNewLine();
            writer.OpenNode("call_indirect");

            if (Arguments.Count > 0)
            {
                writer.EnsureNewLine();
            }
            else
            {
                writer.EnsureSpace();
            }

            Element.ToString(writer);

            foreach (var arg in Arguments)
            {
                writer.EnsureNewLine();
                arg.ToString(writer);
            }

            if (Arguments.Count > 0)
            {
                writer.EnsureNewLine();
            }
            writer.CloseNode();
        }
Esempio n. 3
0
 public override void ToString(NodeWriter writer)
 {
     writer.OpenNode($"get_local");
     writer.EnsureSpace();
     writer.Write($"${Variable.Name}");
     writer.CloseNode();
 }
Esempio n. 4
0
 public override void ToString(NodeWriter writer)
 {
     writer.OpenNode($"i64.const");
     writer.EnsureSpace();
     writer.Write(Value);
     writer.CloseNode();
 }
Esempio n. 5
0
        public override void ToString(NodeWriter writer)
        {
            writer.EnsureNewLine();
            writer.OpenNode("global");
            writer.EnsureSpace();
            writer.Write($"${Name}");
            writer.EnsureSpace();

            writer.Write("(");
            if (Mutable)
            {
                writer.Write("mut ");
            }
            writer.WriteValue(Type);
            writer.Write(")");

            if (Init != null && !Init.Empty)
            {
                writer.EnsureNewLine();
                Init.ToString(writer);
                writer.EnsureNewLine();
            }

            writer.CloseNode();
        }
Esempio n. 6
0
 public override void ToString(NodeWriter writer)
 {
     writer.EnsureNewLine();
     writer.OpenNode("nop");
     writer.CloseNode();
     writer.EnsureNewLine();
 }
Esempio n. 7
0
 public override void ToString(NodeWriter writer)
 {
     writer.EnsureNewLine();
     writer.OpenNode("br");
     writer.WriteLabelName(Target);
     writer.CloseNode();
     writer.EnsureNewLine();
 }
Esempio n. 8
0
 public sealed override void ToString(NodeWriter writer)
 {
     writer.EnsureNewLine();
     writer.OpenNode(NodeName);
     writer.EnsureSpace();
     Expression.ToString(writer);
     writer.CloseNode();
 }
Esempio n. 9
0
 public override void ToString(NodeWriter writer)
 {
     writer.EnsureNewLine();
     writer.OpenNode("local");
     writer.EnsureSpace();
     writer.WriteVariableName(this);
     writer.WriteValue(Type);
     writer.CloseNode();
     writer.EnsureNewLine();
 }
Esempio n. 10
0
 public override void ToString(NodeWriter writer)
 {
     writer.EnsureNewLine();
     writer.OpenNode("set_local");
     writer.WriteVariableName(Variable);
     writer.EnsureSpace();
     Value.ToString(writer);
     writer.CloseNode();
     writer.EnsureNewLine();
 }
Esempio n. 11
0
 public override void ToString(NodeWriter writer)
 {
     writer.EnsureNewLine();
     writer.OpenNode("set_global");
     writer.EnsureSpace();
     writer.Write($"${Variable.Name}");
     writer.EnsureSpace();
     Value.ToString(writer);
     writer.CloseNode();
     writer.EnsureNewLine();
 }
Esempio n. 12
0
 public override void ToString(NodeWriter writer)
 {
     writer.EnsureNewLine();
     writer.OpenNode("block");
     writer.WriteValueOrVoid(ResultType);
     writer.WriteLabelName(Nodes.Label);
     writer.EnsureNewLine();
     Nodes.ToString(writer);
     writer.CloseNode();
     writer.EnsureNewLine();
 }
Esempio n. 13
0
 public override void ToString(NodeWriter writer)
 {
     writer.EnsureNewLine();
     writer.OpenNode("return");
     if (Expression != null)
     {
         writer.EnsureSpace();
         Expression.ToString(writer);
     }
     writer.CloseNode();
     writer.EnsureNewLine();
 }
Esempio n. 14
0
        public sealed override void ToString(NodeWriter writer)
        {
            writer.EnsureNewLine();
            writer.OpenNode(NodeName);
            writer.Write(FormatImmediate());

            writer.EnsureNewLine();
            Address.ToString(writer);

            writer.EnsureNewLine();
            writer.CloseNode();
            writer.EnsureNewLine();
        }
Esempio n. 15
0
 public override void ToString(NodeWriter writer)
 {
     writer.EnsureNewLine();
     writer.OpenNode("br_table");
     foreach (var target in Targets)
     {
         writer.EnsureNewLine();
         writer.WriteLabelName(target);
     }
     writer.EnsureNewLine();
     writer.WriteLabelName(DefaultTarget);
     writer.CloseNode();
     //todo: syntax?
 }
Esempio n. 16
0
 public override void ToString(NodeWriter writer)
 {
     writer.EnsureNewLine();
     writer.OpenNode("call");
     writer.WriteFunctionName(Function);
     foreach (var arg in Arguments)
     {
         writer.EnsureNewLine();
         arg.ToString(writer);
     }
     if (Arguments.Count > 0)
     {
         writer.EnsureNewLine();
     }
     writer.CloseNode();
     writer.EnsureNewLine();
 }
Esempio n. 17
0
        public override void ToString(NodeWriter writer)
        {
            writer.OpenNode("module");

            foreach (var import in Imports)
            {
                import.ToString(writer);
            }

            foreach (var global in Globals)
            {
                global.ToString(writer);
            }

            foreach (var func in Functions)
            {
                writer.EnsureNewLine();
                func.ToString(writer);
            }

            writer.EnsureNewLine();
            writer.CloseNode();
        }
Esempio n. 18
0
        public override void ToString(NodeWriter writer)
        {
            writer.EnsureNewLine();
            writer.OpenNode("if");

            writer.WriteLabelName(_then.Label);
            writer.WriteValueOrVoid(Signature);

            writer.EnsureNewLine();
            Condition.ToString(writer);

            writer.EnsureNewLine();
            Then.ToString(writer);
            writer.EnsureNewLine();

            if (Else != null)
            {
                new ElseNode(_else).ToString(writer);
                writer.EnsureNewLine();
            }

            writer.CloseNode();
            writer.EnsureNewLine();
        }