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;
            }
示例#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);
            }
 public void ParseCode(string code)
 {
     operation = new GateSharkCodeOperation();
     operation.operationType = OperationType.TopLevelOperation;
     operation.ParseCode(code, this);
 }
示例#4
0
 public void ParseCode(string code)
 {
     operation = new GateSharkCodeOperation();
     operation.operationType = OperationType.TopLevelOperation;
     operation.ParseCode(code, this);
 }