Exemple #1
0
 /// <summary>
 /// Removes value at specified location and add it to the target location.  Will result in, for example:
 /// { "op": "move", "from": "/a/b/c", "path": "/a/b/d" }
 /// </summary>
 /// <param name="from">source location</param>
 /// <param name="path">target location</param>
 /// <returns></returns>
 public JsonPatchDocument Move([NotNull] string from, [NotNull] string path)
 {
     Operations.Add(new Operation("move", PathHelpers.NormalizePath(path), PathHelpers.NormalizePath(from)));
     return(this);
 }
        public void Zero()
        {
            int result = Operations.Add(10, -10);

            Assert.AreEqual(0, result);
        }
Exemple #3
0
 /// <summary>
 /// Remove value from end of list
 /// </summary>
 /// <typeparam name="TProp">value type</typeparam>
 /// <param name="path">target location</param>
 /// <returns></returns>
 public JsonPatchDocument <T> Remove <TProp>(Expression <Func <T, IList <TProp> > > path)
 {
     Operations.Add(new Operation <T>("remove", ExpressionHelpers.GetPath <T, IList <TProp> >(path).ToLower() + "/-", null));
     return(this);
 }
Exemple #4
0
        public void Add_Two_Numbers_LessThanZero_ReturnSum_a_b(int a, int b)
        {
            int res = Operations.Add(a, b);

            Assert.AreEqual(res, a + b);
        }
        public void NegativeResult()
        {
            int result = Operations.Add(5, -10);

            Assert.AreEqual(-5, result);
        }
Exemple #6
0
 public virtual void AddCommission()
 {
     Operations.Add("Commission payment to the agent");
     Console.WriteLine("Commission payment to the agent");
 }
Exemple #7
0
 public virtual void DropMail()
 {
     Operations.Add("Mail Sent");
     Console.WriteLine("Mail Sent");
 }
Exemple #8
0
 public void AddTest()
 {
     Assert.AreEqual(Operations.Add(1.0, 1.0), 2.0);
 }
Exemple #9
0
        public bool BackwalkInstruction(Instruction instr)
        {
            var ass = instr as Assignment;

            if (ass != null)
            {
                var regSrc = RegisterOf(ass.Src as Identifier);
                var binSrc = ass.Src as BinaryExpression;
                if (binSrc != null)
                {
                    if (RegisterOf(ass.Dst) == Index)
                    {
                        regSrc = RegisterOf(binSrc.Left as Identifier);
                        var immSrc = binSrc.Right as Constant;
                        if (binSrc.Operator == Operator.IAdd || binSrc.Operator == Operator.ISub)
                        {
                            Index = HandleAddition(Index, Index, regSrc, immSrc, binSrc.Operator == Operator.IAdd);
                            return(true);
                        }
                        if (binSrc.Operator == Operator.And)
                        {
                            if (immSrc != null && IsEvenPowerOfTwo(immSrc.ToInt32() + 1))
                            {
                                Operations.Add(new BackwalkOperation(BackwalkOperator.cmp, immSrc.ToInt32() + 1));
                            }
                            else
                            {
                                Index = null;
                            }
                            return(false);
                        }
                        if (binSrc.Operator is IMulOperator && immSrc != null)
                        {
                            var m = immSrc.ToInt32();
                            Operations.Add(new BackwalkOperation(BackwalkOperator.mul, m));
                            Stride *= m;
                            return(true);
                        }
                        if (binSrc.Operator is ShlOperator && immSrc != null)
                        {
                            var m = 1 << immSrc.ToInt32();
                            Operations.Add(new BackwalkOperation(BackwalkOperator.mul, m));
                            Stride *= m;
                            return(true);
                        }
                    }
                    if (Index != null &&
                        binSrc.Operator == Operator.Xor &&
                        binSrc.Left == ass.Dst &&
                        binSrc.Right == ass.Dst &&
                        RegisterOf(ass.Dst) == Index.GetSubregister(8, 8))
                    {
                        Operations.Add(new BackwalkOperation(BackwalkOperator.and, 0xFF));
                        Index = Index.GetSubregister(0, 8);
                    }
                }

                var cof = ass.Src as ConditionOf;
                if (cof != null && UsedFlagIdentifier != null)
                {
                    var grfDef = (ass.Dst.Storage as FlagGroupStorage).FlagGroupBits;
                    var grfUse = (UsedFlagIdentifier.Storage as FlagGroupStorage).FlagGroupBits;
                    if ((grfDef & grfUse) == 0)
                    {
                        return(true);
                    }
                    var binCmp = cof.Expression as BinaryExpression;
                    if (binCmp != null &&
                        (binCmp.Operator is ISubOperator ||
                         binCmp.Operator is USubOperator))
                    {
                        var idLeft = RegisterOf(binCmp.Left  as Identifier);
                        if (idLeft != null &&
                            (idLeft == Index || idLeft == Index.GetPart(PrimitiveType.Byte)) ||
                            (IndexExpression != null && IndexExpression.ToString() == idLeft.ToString()))   //$HACK: sleazy, but we don't appear to have an expression comparer
                        {
                            var immSrc = binCmp.Right as Constant;
                            if (immSrc != null)
                            {
                                // Found the bound of the table.
                                Operations.Add(new BackwalkOperation(BackwalkOperator.cmp, immSrc.ToInt32()));
                                return(false);
                            }
                        }
                    }
                }

                var src     = ass.Src;
                var castSrc = src as Cast;
                if (castSrc != null)
                {
                    src = castSrc.Expression;
                }
                var memSrc = src as MemoryAccess;
                var regDst = RegisterOf(ass.Dst);
                if (memSrc != null && (regDst == Index || regDst.IsSubRegisterOf(Index)))
                {
                    // R = Mem[xxx]
                    var rIdx = Index;
                    var rDst = RegisterOf(ass.Dst);
                    if (rDst != rIdx.GetSubregister(0, 8) && castSrc == null)
                    {
                        Index           = RegisterStorage.None;
                        IndexExpression = src;
                        return(true);
                    }

                    var binEa = memSrc.EffectiveAddress as BinaryExpression;
                    if (binEa == null)
                    {
                        return(false);
                    }
                    var memOffset = binEa.Right as Constant;
                    var scale     = GetMultiplier(binEa.Left);
                    var baseReg   = GetBaseRegister(binEa.Left);
                    if (memOffset != null && binEa.Operator == Operator.IAdd)
                    {
                        var mOff = memOffset.ToInt32();
                        if (mOff > 0x200)
                        {
                            Operations.Add(new BackwalkDereference(memOffset.ToInt32(), scale));
                            Index = baseReg;
                            return(true);
                        }
                    }
                    return(false);
                }

                if (regSrc != null && regDst == Index)
                {
                    Index = regSrc;
                    return(true);
                }
                return(true);
            }

            var bra = instr as Branch;

            if (bra != null)
            {
                var cond = bra.Condition as TestCondition;
                if (cond != null)
                {
                    if (cond.ConditionCode == ConditionCode.UGT)
                    {
                        Operations.Add(new BackwalkBranch(ConditionCode.UGT));
                        UsedFlagIdentifier = (Identifier)cond.Expression;
                    }
                    else if (cond.ConditionCode == ConditionCode.ULE)
                    {
                        Operations.Add(new BackwalkBranch(ConditionCode.ULE));
                        UsedFlagIdentifier = (Identifier)cond.Expression;
                    }
                }
                return(true);
            }

            Debug.WriteLine("Backwalking not supported: " + instr);
            return(true);
        }
Exemple #10
0
 public ViewBookingViewModelExecute(IServiceModel model)
 {
     TimeoutMilliseconds = 10000;
     Operations.Add(new ViewBookingOperation(model));
 }
 public CloseViewModelExecute()
 {
     TimeoutMilliseconds = 10000;
     Operations.Add(new CloseOperation());
 }
Exemple #12
0
        internal void TranslateMembers()
        {
            //Attributy
            foreach (var pr in SourceClass.PIMAttributes)
            {
                Classifier         baseType = pr.AttributeType != null ? TypeTable.Library.RootNamespace.NestedClassifier[pr.AttributeType.Name] : TypeTable.Library.Any;
                Classifier         propType = BridgeHelpers.GetTypeByCardinality(TypeTable, pr, baseType);
                PIMBridgeAttribute newProp  = new PIMBridgeAttribute(pr, PropertyType.One, propType);
                Properties.Add(newProp);
                //Hack
                newProp.Tag = pr;
                //Registration to find
                PIMAttribute.Add(pr, newProp);
            }


            //Associace

            foreach (var ass in SourceClass.PIMAssociationEnds)
            {
                var        end     = ass.PIMAssociation.PIMAssociationEnds.Where(a => a.ID != ass.ID).First();
                Classifier assType = TypeTable.Library.RootNamespace.NestedClassifier[end.PIMClass.Name];
                string     name;
                if (string.IsNullOrEmpty(end.Name))
                {
                    name = assType.Name;
                }
                else
                {
                    name = end.Name;
                }
                Classifier propType = BridgeHelpers.GetTypeByCardinality(TypeTable, end, assType);
                TypeTable.RegisterType(propType);
                PIMBridgeAssociation newass = new PIMBridgeAssociation(name, ass.PIMAssociation, end, PropertyType.One, propType);
                Properties.Add(newass);

                //hack
                newass.Tag = end;
                //Registration to find
                PIMAssociations.Add(end, newass);
            }


            //Operation

            foreach (var op in SourceClass.PIMOperations)
            {
                Operation newOp = new Operation(op.Name, true,
                                                op.ResultType != null ? TypeTable.Library.RootNamespace.NestedClassifier[op.ResultType.Name] : TypeTable.Library.Void,
                                                op.Parameters.Select(p => new Parameter(p.Name, TypeTable.Library.RootNamespace.NestedClassifier[p.Type.Name])));
                Operations.Add(newOp);

                //hack
                newOp.Tag = op;
                // Registration to find
                PIMOperations.Add(op, newOp);
            }

            // allInstances
            {
                Operation allInstancesOp = new Operation(@"allInstances", true, this);
                Operations.Add(allInstancesOp);
            }
        }
 internal static void AddOperation(FCSOperation operation)
 {
     Operations.Add(operation);
     operation.Manager.RefreshOperators();
 }
Exemple #14
0
        public void Add_MinMax()
        {
            var testAdd = Operations.Add(int.MinValue, int.MaxValue);

            Assert.That(testAdd == -1);
        }
        private async Task TryCommitToFileAsync(ITxStoreOperation operation)
        {
            try
            {
                if (operation is null || operation.IsEmpty)
                {
                    return;
                }

                // Make sure that only one call can continue.
                lock (OperationsLock)
                {
                    var isRunning = Operations.Any();
                    Operations.Add(operation);
                    if (isRunning)
                    {
                        return;
                    }
                }

                // Wait until the operation list calms down.
                IEnumerable <ITxStoreOperation> operationsToExecute;
                while (true)
                {
                    var count = Operations.Count;

                    await Task.Delay(100).ConfigureAwait(false);

                    lock (OperationsLock)
                    {
                        if (count == Operations.Count)
                        {
                            // Merge operations.
                            operationsToExecute = OperationMerger.Merge(Operations).ToList();
                            Operations.Clear();
                            break;
                        }
                    }
                }

                using (await TransactionsFileAsyncLock.LockAsync().ConfigureAwait(false))
                {
                    foreach (ITxStoreOperation op in operationsToExecute)
                    {
                        if (op is Append appendOperation)
                        {
                            var toAppends = appendOperation.Transactions;

                            try
                            {
                                await TransactionsFileManager.AppendAllLinesAsync(toAppends.ToBlockchainOrderedLines()).ConfigureAwait(false);
                            }
                            catch
                            {
                                await SerializeAllTransactionsNoLockAsync().ConfigureAwait(false);
                            }
                        }
                        else if (op is Remove removeOperation)
                        {
                            var toRemoves = removeOperation.Transactions;

                            string[] allLines = await TransactionsFileManager.ReadAllLinesAsync().ConfigureAwait(false);

                            var toSerialize = new List <string>();
                            foreach (var line in allLines)
                            {
                                var startsWith = false;
                                foreach (var toRemoveString in toRemoves.Select(x => x.ToString()))
                                {
                                    startsWith = startsWith || line.StartsWith(toRemoveString, StringComparison.Ordinal);
                                }

                                if (!startsWith)
                                {
                                    toSerialize.Add(line);
                                }
                            }

                            try
                            {
                                await TransactionsFileManager.WriteAllLinesAsync(toSerialize).ConfigureAwait(false);
                            }
                            catch
                            {
                                await SerializeAllTransactionsNoLockAsync().ConfigureAwait(false);
                            }
                        }
                        else if (op is Update updateOperation)
                        {
                            var toUpdates = updateOperation.Transactions;

                            string[] allLines = await TransactionsFileManager.ReadAllLinesAsync().ConfigureAwait(false);

                            IEnumerable <SmartTransaction> allTransactions = allLines.Select(x => SmartTransaction.FromLine(x, Network));
                            var toSerialize = new List <SmartTransaction>();

                            foreach (SmartTransaction tx in allTransactions)
                            {
                                var txsToUpdateWith = toUpdates.Where(x => x == tx);
                                foreach (var txToUpdateWith in txsToUpdateWith)
                                {
                                    tx.TryUpdate(txToUpdateWith);
                                }
                                toSerialize.Add(tx);
                            }

                            try
                            {
                                await TransactionsFileManager.WriteAllLinesAsync(toSerialize.ToBlockchainOrderedLines()).ConfigureAwait(false);
                            }
                            catch
                            {
                                await SerializeAllTransactionsNoLockAsync().ConfigureAwait(false);
                            }
                        }
                        else
                        {
                            throw new NotSupportedException();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.LogError(ex);
            }
        }
Exemple #16
0
 public void Test_Addition()
 {
     Assert.AreEqual(oper.Add(Operand1, Operand2), 24);
 }
Exemple #17
0
        public bool BackwalkInstruction(TInstr instr)
        {
            var ass = host.AsAssignment(instr);

            if (ass != null)
            {
                var assSrc = ass.Item2.Accept(eval);
                var assDst = ass.Item1;
                var regSrc = RegisterOf(assSrc);
                if (assSrc is BinaryExpression binSrc)
                {
                    if (RegisterOf(assDst) == Index || assDst == IndexExpression)
                    {
                        regSrc = RegisterOf(binSrc.Left);
                        var immSrc = binSrc.Right as Constant;
                        if (binSrc.Operator == Operator.IAdd || binSrc.Operator == Operator.ISub)
                        {
                            Index = HandleAddition(Index, Index, regSrc, immSrc, binSrc.Operator == Operator.IAdd);
                            return(true);
                        }
                        if (binSrc.Operator == Operator.And)
                        {
                            if (immSrc != null && Bits.IsEvenPowerOfTwo(immSrc.ToInt32() + 1))
                            {
                                Operations.Add(new BackwalkOperation(BackwalkOperator.cmp, immSrc.ToInt32() + 1));
                            }
                            else
                            {
                                Index = null;
                            }
                            return(false);
                        }
                        if (binSrc.Operator is IMulOperator && immSrc != null)
                        {
                            var m = immSrc.ToInt32();
                            Operations.Add(new BackwalkOperation(BackwalkOperator.mul, m));
                            Stride *= m;
                            return(true);
                        }
                        if (binSrc.Operator is ShlOperator && immSrc != null)
                        {
                            var m = 1 << immSrc.ToInt32();
                            Operations.Add(new BackwalkOperation(BackwalkOperator.mul, m));
                            Stride *= m;
                            return(true);
                        }
                    }
                    if (Index != null &&
                        binSrc.Operator == Operator.Xor &&
                        binSrc.Left == assDst &&
                        binSrc.Right == assDst &&
                        RegisterOf(assDst) == host.GetSubregister(Index, 8, 8))
                    {
                        Operations.Add(new BackwalkOperation(BackwalkOperator.and, 0xFF));
                        Index = host.GetSubregister(Index, 0, 8);
                    }
                }
                var cSrc = assSrc as Constant;
                if (Index != null &&
                    cSrc != null &&
                    cSrc.IsIntegerZero &&
                    RegisterOf(assDst) == host.GetSubregister(Index, 8, 8))
                {
                    // mov bh,0 ;; xor bh,bh
                    // jmp [bx...]
                    Operations.Add(new BackwalkOperation(BackwalkOperator.and, 0xFF));
                    Index = host.GetSubregister(Index, 0, 8);
                    return(true);
                }
                if (assSrc is ConditionOf cof && UsedFlagIdentifier != null)
                {
                    var grfDef = (((Identifier)assDst).Storage as FlagGroupStorage).FlagGroupBits;
                    var grfUse = (UsedFlagIdentifier.Storage as FlagGroupStorage).FlagGroupBits;
                    if ((grfDef & grfUse) == 0)
                    {
                        return(true);
                    }
                    var binCmp = cof.Expression as BinaryExpression;
                    binCmp = NegateRight(binCmp);
                    if (binCmp != null &&
                        (binCmp.Operator is ISubOperator ||
                         binCmp.Operator is USubOperator))
                    {
                        var idLeft = RegisterOf(binCmp.Left  as Identifier);
                        if (idLeft != null &&
                            (idLeft == Index || idLeft == host.GetSubregister(Index, 0, 8)) ||
                            (IndexExpression != null && IndexExpression.ToString() == idLeft.ToString()))   //$HACK: sleazy, but we don't appear to have an expression comparer
                        {
                            if (binCmp.Right is Constant immSrc)
                            {
                                // Found the bound of the table.
                                Operations.Add(new BackwalkOperation(BackwalkOperator.cmp, immSrc.ToInt32()));
                                return(false);
                            }
                        }
                    }
                    if (cof.Expression is Identifier idCof)
                    {
                        IndexExpression    = idCof;
                        Index              = null;
                        UsedFlagIdentifier = null;
                        UsedAsFlag         = idCof;
                        return(true);
                    }
                }

                //$BUG: this is rubbish, the simplifier should _just_
                // perform simplification, no substitutions.
                var src     = assSrc == Constant.Invalid ? ass.Item2 : assSrc;
                var castSrc = src as Cast;
                if (castSrc != null)
                {
                    src = castSrc.Expression;
                }
                var regDst = RegisterOf(assDst);
                if (src is MemoryAccess memSrc &&
                    (regDst == Index ||
                     (Index != null && regDst != null && regDst.Name != "None" && regDst.IsSubRegisterOf(Index))))
                {
                    // R = Mem[xxx]
                    var rIdx = Index;
                    var rDst = RegisterOf(assDst);
                    if ((rDst != host.GetSubregister(rIdx, 0, 8) && castSrc == null) &&
                        rDst != rIdx)
                    {
                        Index           = RegisterStorage.None;
                        IndexExpression = src;
                        return(true);
                    }

                    var binEa = memSrc.EffectiveAddress as BinaryExpression;
                    if (binEa == null)
                    {
                        Index           = RegisterStorage.None;
                        IndexExpression = null;
                        return(false);
                    }
                    var scale   = GetMultiplier(binEa.Left);
                    var baseReg = GetBaseRegister(binEa.Left);
                    if (binEa.Right is Constant memOffset && binEa.Operator == Operator.IAdd)
                    {
                        var mOff = memOffset.ToInt32();
                        if (mOff > 0x200)
                        {
                            Operations.Add(new BackwalkDereference(memOffset.ToInt32(), scale));
                            Index = baseReg;
                            return(true);
                        }
                    }

                    // Some architectures have pc-relative addressing, which the rewriters
                    // should convert to an _address_.
                    var addr = binEa.Left as Address;
                    baseReg = GetBaseRegister(binEa.Right);
                    if (addr != null && VectorAddress == null)
                    {
                        this.VectorAddress = addr;
                        Index = baseReg;
                        return(true);
                    }
                    Index           = RegisterStorage.None;
                    IndexExpression = ass.Item2;
                    return(true);
                }

                if (regSrc != null && regDst == Index)
                {
                    Index = regSrc;
                    return(true);
                }
                UsedAsFlag = null;
                return(true);
            }

            var bra = host.AsBranch(instr);

            if (bra != null)
            {
                bool fallthrough = host.IsFallthrough(instr, startBlock);
                return(VisitBranch(bra, fallthrough));
            }

            Debug.WriteLine("Backwalking not supported: " + instr);
            return(true);
        }
Exemple #18
0
 public JsonPatchDocument Remove(string path)
 {
     Operations.Add(new Operation("remove", PathHelpers.NormalizePath(path, CaseTransformType), null, null));
     return(this);
 }
Exemple #19
0
 public override void GetSlip()
 {
     Operations.Add("Generated a packing slip.");
     Console.WriteLine("Generated a packing slip.");
 }
Exemple #20
0
 public JsonPatchDocument Replace(string path, object value)
 {
     Operations.Add(new Operation("replace", PathHelpers.NormalizePath(path, CaseTransformType), null, value));
     return(this);
 }
Exemple #21
0
 public override void GetSlip()
 {
     Operations.Add("Create a duplicate packing slip for the royalty department.");
     Console.WriteLine("Create a duplicate packing slip for the royalty department.");
 }
Exemple #22
0
 public JsonPatchDocument Copy(string from, string path)
 {
     Operations.Add(new Operation("copy", PathHelpers.NormalizePath(path, CaseTransformType), PathHelpers.NormalizePath(from, CaseTransformType)));
     return(this);
 }
        public void Negative()
        {
            int result = Operations.Add(-32, -5);

            Assert.AreEqual(-37, result);
        }
Exemple #24
0
        public void Add_whenTwoNumbersPassed_ReturnsSumResult(int a, int b)
        {
            int result = Operations.Add(a, b);

            Assert.AreEqual(a + b, result);
        }
        public void PositiveResult()
        {
            int result = Operations.Add(73, -3);

            Assert.AreEqual(70, result);
        }
Exemple #26
0
        private void addOperation(string line, int opIndex, int lineNumber)
        {
            const string sectionName = "operations";

            if (!Regex.IsMatch(line, $@"^{registerNamePattern}\s+{registerNamePattern}\s+\d+\s+{registerNamePattern}\s+{registerNamePattern}\s+{registerNamePattern}$", RegexOptions.IgnoreCase))
            {
                throw new ParsingError(sectionName, line, lineNumber, 0, "Incorrect Format");
            }

            var splitLine = Regex.Replace(line, @"\s+", "\t").Split('\t');

            string codeFileForOp;

            if (!operationToCodeMap.TryGetValue(splitLine[1], out codeFileForOp))
            {
                throw new ParsingError(sectionName, line, lineNumber, line.IndexOf(splitLine[1], StringComparison.Ordinal),
                                       "Unable to find the VHDL code for the provided operation.");
            }

            int bits;

            if (!int.TryParse(splitLine[2], out bits) || bits < 1)
            {
                var lineIndex = line.Skip(splitLine[0].Length).TakeWhile(char.IsWhiteSpace).Count();
                throw new ParsingError(sectionName, line, lineNumber, lineIndex, "The number of bits is less then one.");
            }

            RegisterBase left;

            if (!Registers.TryGetValue(splitLine[3], out left))
            {
                throw new ParsingError(sectionName, line, lineNumber, line.IndexOf(splitLine[3], StringComparison.Ordinal),
                                       "Unable to find the left input register.");
            }

            RegisterBase right;

            if (!Registers.TryGetValue(splitLine[4], out right))
            {
                throw new ParsingError(sectionName, line, lineNumber, line.IndexOf(splitLine[4], StringComparison.Ordinal),
                                       "Unable to find the right input register.");
            }

            RegisterBase output;

            if (!Registers.TryGetValue(splitLine[5], out output) ||
                output is InputRegister)
            {
                throw new ParsingError(sectionName, line, lineNumber, line.IndexOf(splitLine[5], StringComparison.Ordinal),
                                       "Unable to find the output register.");
            }
            var outputWithParent = (RegisterWithParentBase)output;

            if (outputWithParent.Parent != null)
            {
                throw new ParsingError(sectionName, line, lineNumber, line.IndexOf(splitLine[5], StringComparison.Ordinal),
                                       "The output register is already linked to another operation.");
            }

            var operation = outputWithParent.Parent = new Operation
            {
                Id           = $"op{opIndex:000}",
                Name         = splitLine[0],
                Op           = splitLine[1].ToUpper(),
                Bits         = bits,
                Left         = left,
                Right        = right,
                Output       = outputWithParent,
                VhdlCodeFile = codeFileForOp
            };

            Operations.Add(operation.Name, operation);
        }
        public void Positives()
        {
            int result = Operations.Add(15, 42);

            Assert.AreEqual(57, result);
        }
        private void InitialiseOperations()
        {
            var ops = new Ops(this);

            // 0x00 - NOP
            Operations.Add(0x00, ops.NOP());

            // 0x01 - LD BC,nn
            Operations.Add(0x01, ops.LD_16(Register16BitNames.BC));

            // 0x02 - LD (BC), A
            Operations.Add(0x02, ops.LD_8(Register8BitNames.A, Register16BitNames.BC));

            // 0x04 - INC B
            Operations.Add(0x04, ops.INC_8(Register8BitNames.B));

            // 0x05 - DEC B
            Operations.Add(0x05, ops.DEC_8(Register8BitNames.B));

            // 0x06 - LD B,n
            Operations.Add(0x06, ops.LD_8(Register8BitNames.B));

            // 0x07 RLCA
            Operations.Add(0x07, ops.RLCA());

            // 0x08 LD (nn), SP
            Operations.Add(0x08, ops.LD_16_SP());

            // 0x09 - ADD HL,BC
            Operations.Add(0x09, ops.ADD_16(Register16BitNames.BC));

            // 0x02 - LD (DE), A
            Operations.Add(0x12, ops.LD_8(Register8BitNames.A, Register16BitNames.DE));

            // 0x0B - DEC BC
            Operations.Add(0x0B, ops.DEC_16(Register16BitNames.BC));

            // 0x0C - INC C
            Operations.Add(0x0C, ops.INC_8(Register8BitNames.C));

            // 0x0D - DEC C
            Operations.Add(0x0D, ops.DEC_8(Register8BitNames.C));

            // 0x0E - LD C,n
            Operations.Add(0x0E, ops.LD_8(Register8BitNames.C));

            // 0x11 - LD DE,nn
            Operations.Add(0x11, ops.LD_16(Register16BitNames.DE));

            // 0x14 - INC D
            Operations.Add(0x14, ops.INC_8(Register8BitNames.D));

            // 0x15 - DEC D
            Operations.Add(0x15, ops.DEC_8(Register8BitNames.D));

            // 0x16 - LD D,n
            Operations.Add(0x16, ops.LD_8(Register8BitNames.D));

            // 0x19 - ADD HL,DE
            Operations.Add(0x19, ops.ADD_16(Register16BitNames.DE));

            // 0x1B - DEC DE
            Operations.Add(0x1B, ops.DEC_16(Register16BitNames.DE));

            // 0x1C - INC E
            Operations.Add(0x1C, ops.INC_8(Register8BitNames.E));

            // 0x1D - DEC E
            Operations.Add(0x1D, ops.DEC_8(Register8BitNames.E));

            // 0x1E - LD E,n
            Operations.Add(0x1E, ops.LD_8(Register8BitNames.E));

            // 0x1F - RRA
            Operations.Add(0x1F, ops.RRA());

            // 0x20 - JR NZ,n
            Operations.Add(0x20, ops.JR(JRFlags.NZ));

            // 0x21 - LD HL,nn
            Operations.Add(0x21, ops.LD_16(Register16BitNames.HL));

            // 0x24 - INC H
            Operations.Add(0x24, ops.INC_8(Register8BitNames.H));

            // 0x25 - DEC H
            Operations.Add(0x25, ops.DEC_8(Register8BitNames.H));

            // 0x26 - LD H,n
            Operations.Add(0x26, ops.LD_8(Register8BitNames.H));

            // 0x28 - JR Z,n
            Operations.Add(0x28, ops.JR(JRFlags.Z));

            // 0x29 - ADD HL,HL
            Operations.Add(0x29, ops.ADD_16(Register16BitNames.HL));

            // 0x2A - LDI (HL),A
            Operations.Add(0x2A, ops.LDI(Register8BitNames.A, Register16BitNames.HL));

            // 0x2B - DEC HL
            Operations.Add(0x2B, ops.DEC_16(Register16BitNames.HL));

            // 0x2C - INC L
            Operations.Add(0x2C, ops.INC_8(Register8BitNames.L));

            // 0x2D - DEC L
            Operations.Add(0x2D, ops.DEC_8(Register8BitNames.L));

            // 0x2E - LD H,n
            Operations.Add(0x2E, ops.LD_8(Register8BitNames.L));

            // 0x2F - CPL
            Operations.Add(0x2F, ops.CPL());

            // 0x30 - JR NC,n
            Operations.Add(0x30, ops.JR(JRFlags.NC));

            // 0x31 - LD SP,nn
            Operations.Add(0x31, ops.LD_16(Register16BitNames.SP));

            // 0x32 - LDD (HL),A
            Operations.Add(0x32, ops.LDD(Register8BitNames.A, Register16BitNames.HL));

            // 0x35 - DEC A
            Operations.Add(0x35, ops.DEC_8(Register8BitNames.A));

            // 0x36 - LD HL,n
            Operations.Add(0x36, ops.LD_8(Register16BitNames.HL));

            // 0x38 - JR C,n
            Operations.Add(0x38, ops.JR(JRFlags.C));

            // 0x39 - ADD HL,SP
            Operations.Add(0x39, ops.ADD_16(Register16BitNames.SP));

            // 0x3B - DEC SP
            Operations.Add(0x3B, ops.DEC_16(Register16BitNames.SP));

            // 0x3C - INC A
            Operations.Add(0x3C, ops.INC_8(Register8BitNames.A));

            // 0x3E - LD A,n
            Operations.Add(0x3E, ops.LD_8(Register8BitNames.A));

            // 0x70 - LD (HL), B
            Operations.Add(0x70, ops.LD_8(Register8BitNames.B, Register16BitNames.HL));

            // 0x71 - LD (HL), C
            Operations.Add(0x71, ops.LD_8(Register8BitNames.C, Register16BitNames.HL));

            // 0x72 - LD (HL), D
            Operations.Add(0x72, ops.LD_8(Register8BitNames.D, Register16BitNames.HL));

            // 0x73 - LD (HL), E
            Operations.Add(0x73, ops.LD_8(Register8BitNames.E, Register16BitNames.HL));

            // 0x74 - LD (HL), H
            Operations.Add(0x74, ops.LD_8(Register8BitNames.H, Register16BitNames.HL));

            // 0x75 - LD (HL), L
            Operations.Add(0x75, ops.LD_8(Register8BitNames.L, Register16BitNames.HL));

            // 0x77 - LD (HL), A
            Operations.Add(0x77, ops.LD_8(Register8BitNames.A, Register16BitNames.HL));

            // 0x78 - LD A, B
            Operations.Add(0x78, ops.LD_8(Register8BitNames.B, Register8BitNames.A));

            // 0x79 - LD A, C
            Operations.Add(0x79, ops.LD_8(Register8BitNames.C, Register8BitNames.A));

            // 0x7A - LD A, D
            Operations.Add(0x7A, ops.LD_8(Register8BitNames.D, Register8BitNames.A));

            // 0x7B - LD A, E
            Operations.Add(0x7B, ops.LD_8(Register8BitNames.E, Register8BitNames.A));

            // 0x7C - LD A, H
            Operations.Add(0x7C, ops.LD_8(Register8BitNames.H, Register8BitNames.A));

            // 0x7D - LD A, L
            Operations.Add(0x7D, ops.LD_8(Register8BitNames.L, Register8BitNames.A));

            // 0x7F - LD A, A
            Operations.Add(0x7F, ops.LD_8(Register8BitNames.A, Register8BitNames.A));

            // 0xA0 - AND B
            Operations.Add(0xA0, ops.AND_8(Register8BitNames.B));

            // 0xA1 - AND C
            Operations.Add(0xA1, ops.AND_8(Register8BitNames.C));

            // 0xA2 - AND D
            Operations.Add(0xA2, ops.AND_8(Register8BitNames.D));

            // 0xA3 - AND E
            Operations.Add(0xA3, ops.AND_8(Register8BitNames.E));

            // 0xA4 - AND H
            Operations.Add(0xA4, ops.AND_8(Register8BitNames.H));

            // 0xA5 - AND L
            Operations.Add(0xA5, ops.AND_8(Register8BitNames.L));

            // 0xA7 - AND A
            Operations.Add(0xA7, ops.AND_8(Register8BitNames.A));

            // 0xA8 - XOR B
            Operations.Add(0xA8, ops.XOR_8(Register8BitNames.B));

            // 0xA9 - XOR C
            Operations.Add(0xA9, ops.XOR_8(Register8BitNames.C));

            // 0xAA - XOR D
            Operations.Add(0xAA, ops.XOR_8(Register8BitNames.D));

            // 0xAB - XOR E
            Operations.Add(0xAB, ops.XOR_8(Register8BitNames.E));

            // 0xAC - XOR H
            Operations.Add(0xAC, ops.XOR_8(Register8BitNames.H));

            // 0xAD - XOR L
            Operations.Add(0xAD, ops.XOR_8(Register8BitNames.L));

            // 0xAF - XOR A
            Operations.Add(0xAF, ops.XOR_8(Register8BitNames.A));

            // 0xB0 - OR B
            Operations.Add(0xB0, ops.OR_8(Register8BitNames.B));

            // 0xB1 - OR C
            Operations.Add(0xB1, ops.OR_8(Register8BitNames.C));

            // 0xB2 - OR D
            Operations.Add(0xB2, ops.OR_8(Register8BitNames.D));

            // 0xB3 - OR E
            Operations.Add(0xB3, ops.OR_8(Register8BitNames.E));

            // 0xB4 - OR H
            Operations.Add(0xB4, ops.OR_8(Register8BitNames.H));

            // 0xB5 - OR L
            Operations.Add(0xB5, ops.OR_8(Register8BitNames.L));

            // 0xB7 - OR A
            Operations.Add(0xB7, ops.OR_8(Register8BitNames.A));

            // 0xB8 - CP B
            Operations.Add(0xB8, ops.CP(Register8BitNames.B));

            // 0xB9 - CP C
            Operations.Add(0xB9, ops.CP(Register8BitNames.C));

            // 0xBA - CP D
            Operations.Add(0xBA, ops.CP(Register8BitNames.D));

            // 0xBB - CP E
            Operations.Add(0xBB, ops.CP(Register8BitNames.E));

            // 0xBC - CP H
            Operations.Add(0xBC, ops.CP(Register8BitNames.H));

            // 0xBD - CP L
            Operations.Add(0xBD, ops.CP(Register8BitNames.L));

            // 0xBF - CP A
            Operations.Add(0xBF, ops.CP(Register8BitNames.A));

            // 0xC2 - JP NZ,nn
            Operations.Add(0xC2, ops.JP_cc_nn(JRFlags.NZ));

            // 0xC3 - JP, nn
            Operations.Add(0xC3, ops.JP_nn());

            // 0xC9 - RET
            Operations.Add(0xC9, ops.RET());

            // 0xCA - JP Z,nn
            Operations.Add(0xCA, ops.JP_cc_nn(JRFlags.Z));

            // 0xCD - CALL nn
            Operations.Add(0xCD, ops.CALL());

            // 0xD2 - JP NC,nn
            Operations.Add(0xD2, ops.JP_cc_nn(JRFlags.NC));

            // 0xDA - JP C,nn
            Operations.Add(0xDA, ops.JP_cc_nn(JRFlags.C));

            // 0xE0 - LDH (n),A
            Operations.Add(0xE0, ops.LDH_n_A());

            // 0xE2 - LD (0xFF00+C),A
            Operations.Add(0xE2, ops.LD_C_FF00_A());

            // 0xE6 - AND n
            Operations.Add(0xE6, ops.AND_8());

            // 0xEA - LD (nn),A
            Operations.Add(0xEA, ops.LD_8());

            // 0xF0 - LDH A,(n)
            Operations.Add(0xF0, ops.LDH_A_n());

            // 0xF3 - DI
            Operations.Add(0xF3, ops.DI());

            // 0xFB - EI
            Operations.Add(0xFB, ops.EI());

            // 0xFE - CP
            Operations.Add(0xFE, ops.CP());
        }
Exemple #29
0
 /// <summary>
 /// Replace value.  Will result in, for example,
 /// { "op": "replace", "path": "/a/b/c", "value": 42 }
 /// </summary>
 /// <param name="path"></param>
 /// <param name="value"></param>
 /// <returns></returns>
 public JsonPatchDocument <T> Replace <TProp>(Expression <Func <T, TProp> > path, TProp value)
 {
     Operations.Add(new Operation <T>("replace", ExpressionHelpers.GetPath <T, TProp>(path).ToLower(), null, value));
     return(this);
 }
Exemple #30
0
 /// <summary>
 /// Replace value.  Will result in, for example,
 /// { "op": "replace", "path": "/a/b/c", "value": 42 }
 /// </summary>
 /// <param name="path">target location</param>
 /// <param name="value">value</param>
 /// <returns></returns>
 public JsonPatchDocument Replace([NotNull] string path, object value)
 {
     Operations.Add(new Operation("replace", PathHelpers.NormalizePath(path), null, value));
     return(this);
 }