예제 #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();
 }
예제 #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();
        }
예제 #3
0
 public override void ToString(NodeWriter writer)
 {
     writer.OpenNode($"get_local");
     writer.EnsureSpace();
     writer.Write($"${Variable.Name}");
     writer.CloseNode();
 }
예제 #4
0
 public override void ToString(NodeWriter writer)
 {
     writer.OpenNode($"i64.const");
     writer.EnsureSpace();
     writer.Write(Value);
     writer.CloseNode();
 }
예제 #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();
        }
예제 #6
0
 public override void ToString(NodeWriter writer)
 {
     writer.EnsureNewLine();
     writer.OpenNode("nop");
     writer.CloseNode();
     writer.EnsureNewLine();
 }
예제 #7
0
 public override void ToString(NodeWriter writer)
 {
     writer.EnsureNewLine();
     writer.OpenNode("br");
     writer.WriteLabelName(Target);
     writer.CloseNode();
     writer.EnsureNewLine();
 }
예제 #8
0
 public sealed override void ToString(NodeWriter writer)
 {
     writer.EnsureNewLine();
     writer.OpenNode(NodeName);
     writer.EnsureSpace();
     Expression.ToString(writer);
     writer.CloseNode();
 }
예제 #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();
 }
예제 #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();
 }
예제 #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();
 }
예제 #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();
 }
예제 #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();
 }
예제 #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();
        }
예제 #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?
 }
예제 #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();
 }
예제 #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();
        }
예제 #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();
        }