Ejemplo n.º 1
0
            private int ParseCode(string[] codeLines, int i, GateSharkCode topCode)
            {
                for (; i < codeLines.Length; ++i)
                {
                    string[] lineParts = codeLines[i].Split(' ');

                    uint leftCode = BitConverter.ToUInt32(Utilities.GetByteArrayFromByteString(lineParts[0]), 0);
                    uint rightCode = BitConverter.ToUInt32(Utilities.GetByteArrayFromByteString(lineParts[1]), 0);

                    OperationType opType = (OperationType)(leftCode & 0xF0000000);
                    if (opType == OperationType.DTypeTest)
                    {
                        opType = (OperationType)(leftCode & 0xFF000000);
                    }

                    GateSharkCodeOperation operation = new GateSharkCodeOperation();
                    operation.operationType = opType;
                    operation.leftCode = leftCode;
                    operation.rightCode = rightCode;

                    switch (opType)
                    {
                        case OperationType.ConditionalGreaterThan4Byte:
                        case OperationType.ConditionalLessThan4Byte:
                        case OperationType.ConditionalEqual4Byte:
                        case OperationType.ConditionalNotEqual4Byte:
                        case OperationType.ConditionalGreaterThan2Byte:
                        case OperationType.ConditionalLessThan2Byte:
                        case OperationType.ConditionalEqual2Byte:
                        case OperationType.ConditionalNotEqual2Byte:
                        case OperationType.ButtonStateRequire:
                            i = operation.ParseCode(codeLines, ++i, topCode);
                            break;
                        case OperationType.WriteRange:
                            break;
                        case OperationType.EndConditional:
                            switch (this.operationType)
                            {
                                case OperationType.ConditionalGreaterThan4Byte:
                                case OperationType.ConditionalLessThan4Byte:
                                case OperationType.ConditionalEqual4Byte:
                                case OperationType.ConditionalNotEqual4Byte:
                                case OperationType.ConditionalGreaterThan2Byte:
                                case OperationType.ConditionalLessThan2Byte:
                                case OperationType.ConditionalEqual2Byte:
                                case OperationType.ConditionalNotEqual2Byte:
                                    return i;
                            }
                            break;
                        case OperationType.EndRepeat:
                            if (this.operationType == OperationType.WriteRange)
                            {
                                return i;
                            }
                            break;
                        case OperationType.ResetState:

                            return i;
                    }
                }
                return i;
            }
Ejemplo n.º 2
0
            private int ParseCode(string[] codeLines, int i, GateSharkCode topCode)
            {
                for (; i < codeLines.Length; ++i)
                {
                    string[] lineParts = codeLines[i].Split(' ');

                    uint leftCode  = BitConverter.ToUInt32(Utilities.GetByteArrayFromByteString(lineParts[0]), 0);
                    uint rightCode = BitConverter.ToUInt32(Utilities.GetByteArrayFromByteString(lineParts[1]), 0);

                    OperationType opType = (OperationType)(leftCode & 0xF0000000);
                    if (opType == OperationType.DTypeTest)
                    {
                        opType = (OperationType)(leftCode & 0xFF000000);
                    }

                    GateSharkCodeOperation operation = new GateSharkCodeOperation();
                    operation.operationType = opType;
                    operation.leftCode      = leftCode;
                    operation.rightCode     = rightCode;

                    switch (opType)
                    {
                    case OperationType.ConditionalGreaterThan4Byte:
                    case OperationType.ConditionalLessThan4Byte:
                    case OperationType.ConditionalEqual4Byte:
                    case OperationType.ConditionalNotEqual4Byte:
                    case OperationType.ConditionalGreaterThan2Byte:
                    case OperationType.ConditionalLessThan2Byte:
                    case OperationType.ConditionalEqual2Byte:
                    case OperationType.ConditionalNotEqual2Byte:
                    case OperationType.ButtonStateRequire:
                        i = operation.ParseCode(codeLines, ++i, topCode);
                        break;

                    case OperationType.WriteRange:
                        break;

                    case OperationType.EndConditional:
                        switch (this.operationType)
                        {
                        case OperationType.ConditionalGreaterThan4Byte:
                        case OperationType.ConditionalLessThan4Byte:
                        case OperationType.ConditionalEqual4Byte:
                        case OperationType.ConditionalNotEqual4Byte:
                        case OperationType.ConditionalGreaterThan2Byte:
                        case OperationType.ConditionalLessThan2Byte:
                        case OperationType.ConditionalEqual2Byte:
                        case OperationType.ConditionalNotEqual2Byte:
                            return(i);
                        }
                        break;

                    case OperationType.EndRepeat:
                        if (this.operationType == OperationType.WriteRange)
                        {
                            return(i);
                        }
                        break;

                    case OperationType.ResetState:

                        return(i);
                    }
                }
                return(i);
            }
Ejemplo n.º 3
0
 public void ParseCode(string code, GateSharkCode topCode)
 {
     string[] codeLines = code.Split(new string[] { "\r\n", "\n", "\r" }, StringSplitOptions.RemoveEmptyEntries);
     ParseCode(codeLines, 0, topCode);
 }
Ejemplo n.º 4
0
 public void ParseCode(string code, GateSharkCode topCode)
 {
     string[] codeLines = code.Split(new string[] { "\r\n", "\n", "\r" }, StringSplitOptions.RemoveEmptyEntries);
     ParseCode(codeLines, 0, topCode);
 }