Beispiel #1
0
        public static void HandleBranchOperator(object operation, CodeOutput sb)
        {
            var localBranch   = (LocalOperation)operation;
            var objList       = (BranchOperator)localBranch;
            var operationName = objList.Name;
            var jumpAddress   = objList.JumpTo;
            var localVar      = objList.CompareValue;
            var secondVar     = objList.SecondValue;

            switch (operationName)
            {
            case OpcodeBranchNames.BrTrue:
                HandleBrTrue(localVar, sb, jumpAddress);
                break;

            case OpcodeBranchNames.BrFalse:
                HandleBrFalse(localVar, sb, jumpAddress);
                break;

            case OpcodeBranchNames.Beq:
                CppHandleCompareBranches.HandleBeq(localVar, secondVar, sb, jumpAddress);
                break;

            case OpcodeBranchNames.Bge:
                CppHandleCompareBranches.HandleBge(localVar, secondVar, sb, jumpAddress);
                break;

            case OpcodeBranchNames.Bgt:
                CppHandleCompareBranches.HandleBgt(localVar, secondVar, sb, jumpAddress);
                break;

            case OpcodeBranchNames.Ble:
            case OpcodeBranchNames.BleUn:     //Should we treat unsigned differently ?
            case OpcodeBranchNames.BleUnS:
                CppHandleCompareBranches.HandleBle(localVar, secondVar, sb, jumpAddress);
                break;

            case OpcodeBranchNames.Blt:
            case OpcodeBranchNames.BltUn:
            case OpcodeBranchNames.BltUnS:
                CppHandleCompareBranches.HandleBlt(localVar, secondVar, sb, jumpAddress);
                break;

            case OpcodeBranchNames.Bne:
            case OpcodeBranchNames.BneUn:
                CppHandleCompareBranches.HandleBne(localVar, secondVar, sb, jumpAddress);
                break;

            default:
                throw new InvalidOperationException($"Operation '{operationName}' is not handled");
            }
        }
Beispiel #2
0
        public static void HandleBranchOperator(object operation, StringBuilder sb)
        {
            var localBranch   = (LocalOperation)operation;
            var objList       = (BranchOperator)localBranch.Value;
            var operationName = objList.Name;
            var jumpAddress   = objList.JumpTo;
            var localVar      = objList.CompareValue;
            var secondVar     = objList.SecondValue;

            switch (operationName)
            {
            case OpcodeBranchNames.BrTrue:
                HandleBrTrue(localVar, sb, jumpAddress);
                break;

            case OpcodeBranchNames.BrFalse:
                HandleBrFalse(localVar, sb, jumpAddress);
                break;

            case OpcodeBranchNames.Beq:
                CppHandleCompareBranches.HandleBeq(localVar, secondVar, sb, jumpAddress);
                break;

            case OpcodeBranchNames.Bge:
                CppHandleCompareBranches.HandleBge(localVar, secondVar, sb, jumpAddress);
                break;

            case OpcodeBranchNames.Bgt:
                CppHandleCompareBranches.HandleBgt(localVar, secondVar, sb, jumpAddress);
                break;

            case OpcodeBranchNames.Ble:
                CppHandleCompareBranches.HandleBle(localVar, secondVar, sb, jumpAddress);
                break;

            case OpcodeBranchNames.Blt:
                CppHandleCompareBranches.HandleBlt(localVar, secondVar, sb, jumpAddress);
                break;

            case OpcodeBranchNames.Bne:
            case OpcodeBranchNames.BneUn:
                CppHandleCompareBranches.HandleBne(localVar, secondVar, sb, jumpAddress);
                break;

            default:
                throw new InvalidOperationException(string.Format("Operation '{0}' is not handled", operationName));
            }
        }