コード例 #1
0
        WasmNodeResult IWasmOpcodeVisitor <WasmNodeArg, WasmNodeResult> .Visit(GrowMemoryOpcode opcode, WasmNodeArg arg)
        {
            var value = arg.Pop();

            arg.Push(new GrowMemoryNode(value));
            return(null);
        }
コード例 #2
0
        WasmNodeResult IWasmOpcodeVisitor <WasmNodeArg, WasmNodeResult> .Visit(I64TruncUF64Opcode opcode, WasmNodeArg arg)
        {
            var operand = arg.Pop();

            arg.Push(new I64TruncUF64Node(operand));
            return(null);
        }
コード例 #3
0
        WasmNodeResult IWasmOpcodeVisitor <WasmNodeArg, WasmNodeResult> .Visit(F64SqrtOpcode opcode, WasmNodeArg arg)
        {
            var expr = arg.Pop();

            arg.Push(new F64SqrtNode(expr));
            return(null);
        }
コード例 #4
0
        WasmNodeResult IWasmOpcodeVisitor <WasmNodeArg, WasmNodeResult> .Visit(F32ConvertUI64Opcode opcode, WasmNodeArg arg)
        {
            var operand = arg.Pop();

            arg.Push(new F32ConvertUI64Node(operand));
            return(null);
        }
コード例 #5
0
        WasmNodeResult IWasmOpcodeVisitor <WasmNodeArg, WasmNodeResult> .Visit(I64Load8UOpcode opcode, WasmNodeArg arg)
        {
            var address = arg.Pop();

            arg.Push(new I64Load8UNode(opcode.Immediate, address));
            return(null);
        }
コード例 #6
0
        WasmNodeResult IWasmOpcodeVisitor <WasmNodeArg, WasmNodeResult> .Visit(I64ExtendUI32Opcode opcode, WasmNodeArg arg)
        {
            var operand = arg.Pop();

            arg.Push(new I64ExtendUI32Node(operand));
            return(null);
        }
コード例 #7
0
        WasmNodeResult IWasmOpcodeVisitor <WasmNodeArg, WasmNodeResult> .Visit(F64PromoteF32Opcode opcode, WasmNodeArg arg)
        {
            var operand = arg.Pop();

            arg.Push(new F64PromoteF32Node(operand));
            return(null);
        }
コード例 #8
0
        WasmNodeResult IWasmOpcodeVisitor <WasmNodeArg, WasmNodeResult> .Visit(F64ReinterpretI64Opcode opcode, WasmNodeArg arg)
        {
            var operand = arg.Pop();

            arg.Push(new F64ReinterpretI64Node(operand));
            return(null);
        }
コード例 #9
0
        WasmNodeResult IWasmOpcodeVisitor <WasmNodeArg, WasmNodeResult> .Visit(I32ReinterpretF32Opcode opcode, WasmNodeArg arg)
        {
            var operand = arg.Pop();

            arg.Push(new I32ReinterpretF32Node(operand));
            return(null);
        }
コード例 #10
0
        WasmNodeResult IWasmOpcodeVisitor <WasmNodeArg, WasmNodeResult> .Visit(I32EqzOpcode opcode, WasmNodeArg arg)
        {
            var expr = arg.Pop();

            arg.Push(new I32EqzNode(expr));
            return(null);
        }
コード例 #11
0
        WasmNodeResult IWasmOpcodeVisitor <WasmNodeArg, WasmNodeResult> .Visit(DropOpcode opcode, WasmNodeArg arg)
        {
            var op = arg.Pop();

            arg.Push(new DropNode(op));
            return(null);
        }
コード例 #12
0
        WasmNodeResult IWasmOpcodeVisitor <WasmNodeArg, WasmNodeResult> .Visit(BlockOpcode opcode, WasmNodeArg arg)
        {
            var blockNode = new BlockNode(opcode.Signature);

            arg.Push(blockNode);
            arg.PushBlock(blockNode.Nodes);
            return(null);
        }
コード例 #13
0
        WasmNodeResult IWasmOpcodeVisitor <WasmNodeArg, WasmNodeResult> .Visit(F64CopySignOpcode opcode, WasmNodeArg arg)
        {
            var right = arg.Pop();
            var left  = arg.Pop();

            arg.Push(new F64CopySignNode(left, right));
            return(null);
        }
コード例 #14
0
        WasmNodeResult IWasmOpcodeVisitor <WasmNodeArg, WasmNodeResult> .Visit(SetGlobalOpcode opcode, WasmNodeArg arg)
        {
            var expr     = arg.Pop();
            var variable = arg.ResolveGlobal(opcode.GlobalIndex);

            arg.Push(new SetGlobalNode(variable, expr));
            return(null);
        }
コード例 #15
0
        WasmNodeResult IWasmOpcodeVisitor <WasmNodeArg, WasmNodeResult> .Visit(BrOpcode opcode, WasmNodeArg arg)
        {
            var label = arg.ResolveLabel(opcode.RelativeDepth);
            var node  = new BrNode(label);

            arg.Push(node);
            return(null);
        }
コード例 #16
0
        WasmNodeResult IWasmOpcodeVisitor <WasmNodeArg, WasmNodeResult> .Visit(I32Store16Opcode opcode, WasmNodeArg arg)
        {
            var value   = arg.Pop();
            var address = arg.Pop();

            arg.Push(new I32Store16Node(opcode.Immediate, address, value));
            return(null);
        }
コード例 #17
0
        WasmNodeResult IWasmOpcodeVisitor <WasmNodeArg, WasmNodeResult> .Visit(I32GeuOpcode opcode, WasmNodeArg arg)
        {
            var right = arg.Pop();
            var left  = arg.Pop();

            arg.Push(new I32GeuNode(left, right));
            return(null);
        }
コード例 #18
0
        WasmNodeResult IWasmOpcodeVisitor <WasmNodeArg, WasmNodeResult> .Visit(LoopOpcode opcode, WasmNodeArg arg)
        {
            var loopNode = new LoopNode(opcode.Signature);

            arg.Push(loopNode);
            arg.PushBlock(loopNode.Nodes);
            return(null);
        }
コード例 #19
0
        WasmNodeResult IWasmOpcodeVisitor <WasmNodeArg, WasmNodeResult> .Visit(SelectOpcode opcode, WasmNodeArg arg)
        {
            var condition = arg.Pop();
            var second    = arg.Pop();
            var first     = arg.Pop();

            arg.Push(new SelectNode(condition, first, second));
            return(null);
        }
コード例 #20
0
        WasmNodeResult IWasmOpcodeVisitor <WasmNodeArg, WasmNodeResult> .Visit(BrIfOpcode opcode, WasmNodeArg arg)
        {
            var label     = arg.ResolveLabel(opcode.RelativeDepth);
            var condition = arg.Pop();
            var node      = new BrIfNode(condition, label);

            arg.Push(node);
            return(null);
        }
コード例 #21
0
        WasmNodeResult IWasmOpcodeVisitor <WasmNodeArg, WasmNodeResult> .Visit(IfOpcode opcode, WasmNodeArg arg)
        {
            var condition = arg.Pop();
            var ifNode    = new IfNode(condition, opcode.Signature);
            var thenBlock = new NodesList(opcode.Signature);

            ifNode.Then = thenBlock;
            arg.Push(ifNode);
            arg.PushBlock(thenBlock);
            return(null);
        }
コード例 #22
0
        WasmNodeResult IWasmOpcodeVisitor <WasmNodeArg, WasmNodeResult> .Visit(ReturnOpcode opcode, WasmNodeArg arg)
        {
            var farg       = (WasmFunctionNodeArg)arg; //todo:
            var returnType = farg.Function.Signature.Return;

            switch (returnType)
            {
            case WasmType.I32:
            case WasmType.I64:
            case WasmType.F32:
            case WasmType.F64:
                var res = arg.Pop();
                arg.Push(new ReturnNode(res));
                break;

            default:
                arg.Push(new ReturnNode());
                break;
            }
            return(null);
        }
コード例 #23
0
        WasmNodeResult IWasmOpcodeVisitor <WasmNodeArg, WasmNodeResult> .Visit(CallOpcode opcode, WasmNodeArg arg)
        {
            var target = arg.Context.ResolveFunction(opcode.FunctionIndex);
            var node   = new CallNode(target);

            for (var i = target.Signature.Parameters.Count - 1; i >= 0; i--)
            {
                var param = arg.Pop();
                node.Arguments.Insert(0, param);
            }
            arg.Push(node);
            return(null);
        }
コード例 #24
0
        WasmNodeResult IWasmOpcodeVisitor <WasmNodeArg, WasmNodeResult> .Visit(CallIndirectOpcode opcode, WasmNodeArg arg)
        {
            var target  = arg.Context.ResolveType(opcode.TypeIndex);
            var element = arg.Pop();
            var node    = new CallIndirectNode(target, element);

            for (var i = target.Parameters.Count - 1; i >= 0; i--)
            {
                var param = arg.Pop();
                node.Arguments.Insert(0, param);
            }
            arg.Push(node);
            return(null);
        }
コード例 #25
0
        WasmNodeResult IWasmOpcodeVisitor <WasmNodeArg, WasmNodeResult> .Visit(BrTableOpcode opcode, WasmNodeArg arg)
        {
            var operand = arg.Pop();
            var node    = new BrTableNode(operand);

            foreach (var target in opcode.Targets)
            {
                var label = arg.ResolveLabel(target);
                node.Targets.Add(label);
            }
            node.DefaultTarget = arg.ResolveLabel(opcode.DefaultTarget);
            arg.Push(node);
            return(null);
        }
コード例 #26
0
        WasmNodeResult IWasmOpcodeVisitor <WasmNodeArg, WasmNodeResult> .Visit(ElseOpcode opcode, WasmNodeArg arg)
        {
            arg.PopBlock();
            var parentNode = arg.Pop();
            var ifNode     = parentNode as IfNode;

            if (ifNode == null)
            {
                throw new WasmNodeException("if node expected");
            }

            var elseBlock = new NodesList(ifNode.Signature);

            ifNode.Else = elseBlock;
            arg.Push(ifNode);
            arg.PushBlock(elseBlock);
            return(null);
        }
コード例 #27
0
 WasmNodeResult IWasmOpcodeVisitor <WasmNodeArg, WasmNodeResult> .Visit(UnreachableOpcode opcode, WasmNodeArg arg)
 {
     arg.Push(new UnreachableNode());
     return(null);
 }
コード例 #28
0
 WasmNodeResult IWasmOpcodeVisitor <WasmNodeArg, WasmNodeResult> .Visit(GetLocalOpcode opcode, WasmNodeArg arg)
 {
     arg.Push(new GetLocalNode(arg.ResolveLocal(opcode.LocalIndex)));
     return(null);
 }
コード例 #29
0
 WasmNodeResult IWasmOpcodeVisitor <WasmNodeArg, WasmNodeResult> .Visit(CurrentMemoryOpcode opcode, WasmNodeArg arg)
 {
     arg.Push(new CurrentMemoryNode());
     return(null);
 }
コード例 #30
0
 WasmNodeResult IWasmOpcodeVisitor <WasmNodeArg, WasmNodeResult> .Visit(I32ConstOpcode opcode, WasmNodeArg arg)
 {
     arg.Push(new I32ConstNode(opcode.Value));
     return(null);
 }