コード例 #1
0
ファイル: Edge.cs プロジェクト: SergeiPavlov/dataobjects-net
 /// <inheritdoc/>
 public override int GetHashCode()
 {
     unchecked {
         return((Tail.GetHashCode() * 397) ^ Head.GetHashCode());
     }
 }
コード例 #2
0
 private IList <IVersionAgnostic> getCsvData(TableVersion.Value tableVersion, string searchName, Tail tail, Ear ear, Nose nose,
                                             DateAndTime dateAndTime, GeoLocationData latitudeData, GeoLocationData longitudeData)
 {
     return(csvDataProvider.getCsvData(tableVersion, searchName, tail, ear, nose,
                                       dateAndTime, latitudeData, longitudeData));
 }
コード例 #3
0
 public override void Write(object value, ProtoWriter dest)
 {
     Tail.Write(absoluteUriProperty.GetValue(value, null), dest);
 }
コード例 #4
0
 public override void Write(object value, ProtoWriter dest)
 {
     Tail.Write(((Uri)value).AbsoluteUri, dest);
 }
コード例 #5
0
 protected override void EmitRead(Compiler.CompilerContext ctx, Compiler.Local valueFrom)
 {
     Tail.EmitRead(ctx, valueFrom);
 }
コード例 #6
0
        protected override void EmitWrite(ProtoBuf.Compiler.CompilerContext ctx, ProtoBuf.Compiler.Local valueFrom)
        {
            using (Compiler.Local list = ctx.GetLocalWithValue(ExpectedType, valueFrom))
            {
                MethodInfo moveNext, current, getEnumerator = GetEnumeratorInfo(ctx.Model, out moveNext, out current);
                Helpers.DebugAssert(moveNext != null);
                Helpers.DebugAssert(current != null);
                Helpers.DebugAssert(getEnumerator != null);
                Type enumeratorType = getEnumerator.ReturnType;
                bool writePacked    = WritePacked;
                using (Compiler.Local iter = new Compiler.Local(ctx, enumeratorType))
                    using (Compiler.Local token = writePacked ? new Compiler.Local(ctx, ctx.MapType(typeof(SubItemToken))) : null)
                    {
                        if (writePacked)
                        {
                            ctx.LoadValue(fieldNumber);
                            ctx.LoadValue((int)WireType.String);
                            ctx.LoadReaderWriter();
                            ctx.EmitCall(ctx.MapType(typeof(ProtoWriter)).GetMethod("WriteFieldHeader"));

                            ctx.LoadValue(list);
                            ctx.LoadReaderWriter();
                            ctx.EmitCall(ctx.MapType(typeof(ProtoWriter)).GetMethod("StartSubItem"));
                            ctx.StoreValue(token);

                            ctx.LoadValue(fieldNumber);
                            ctx.LoadReaderWriter();
                            ctx.EmitCall(ctx.MapType(typeof(ProtoWriter)).GetMethod("SetPackedField"));
                        }

                        ctx.LoadAddress(list, ExpectedType);
                        ctx.EmitCall(getEnumerator);
                        ctx.StoreValue(iter);
                        using (ctx.Using(iter))
                        {
                            Compiler.CodeLabel body = ctx.DefineLabel(), next = ctx.DefineLabel();
                            ctx.Branch(next, false);

                            ctx.MarkLabel(body);

                            ctx.LoadAddress(iter, enumeratorType);
                            ctx.EmitCall(current);
                            Type itemType = Tail.ExpectedType;
                            if (itemType != ctx.MapType(typeof(object)) && current.ReturnType == ctx.MapType(typeof(object)))
                            {
                                ctx.CastFromObject(itemType);
                            }
                            Tail.EmitWrite(ctx, null);

                            ctx.MarkLabel(@next);
                            ctx.LoadAddress(iter, enumeratorType);
                            ctx.EmitCall(moveNext);
                            ctx.BranchIfTrue(body, false);
                        }

                        if (writePacked)
                        {
                            ctx.LoadValue(token);
                            ctx.LoadReaderWriter();
                            ctx.EmitCall(ctx.MapType(typeof(ProtoWriter)).GetMethod("EndSubItem"));
                        }
                    }
            }
        }
コード例 #7
0
 public override void Write(object value, ProtoWriter dest)
 {
     Tail.Write(((Uri)value).OriginalString, dest);
 }
コード例 #8
0
 public override void Write(object value, ProtoWriter dest)
 {
     ProtoWriter.WriteFieldHeader(fieldNumber, wireType, dest);
     Tail.Write(value, dest);
 }
コード例 #9
0
ファイル: classSnake.cs プロジェクト: hujgup/Snake
 /// <summary>
 /// Returns an IEnumerator for the current instance.
 /// </summary>
 public IEnumerator <MovementNode> GetEnumerator()
 {
     return(Tail.GetEnumerator());
 }
コード例 #10
0
ファイル: MkSequence.cs プロジェクト: VladRassokhin/reko
 public override Expression CloneExpression()
 {
     return(new MkSequence(DataType, Head.CloneExpression(), Tail.CloneExpression()));
 }
コード例 #11
0
 public override void Write(object value, ProtoWriter dest)
 {
     Helpers.DebugAssert(value != null);
     Tail.Write(GetValue(value), dest);
 }
コード例 #12
0
 public override void WriteDebugSchema(IDebugSchemaBuilder builder)
 {
     using (builder.SingleTailDecorator(this, _field.Name))
         Tail.WriteDebugSchema(builder);
 }
コード例 #13
0
        protected override void EmitRead(CompilerContext ctx, Local valueFrom)
        {
            using (Compiler.Local list = AppendToCollection ? ctx.GetLocalWithValue(ExpectedType, valueFrom)
                : new Compiler.Local(ctx, typeof(TDictionary)))
                using (Compiler.Local token = new Compiler.Local(ctx, typeof(SubItemToken)))
                    using (Compiler.Local key = new Compiler.Local(ctx, typeof(TKey)))
                        using (Compiler.Local @value = new Compiler.Local(ctx, typeof(TValue)))
                            using (Compiler.Local fieldNumber = new Compiler.Local(ctx, typeof(int)))
                            {
                                if (!AppendToCollection)
                                { // always new
                                    ctx.LoadNullRef();
                                    ctx.StoreValue(list);
                                }
                                if (concreteType != null)
                                {
                                    ctx.LoadValue(list);
                                    Compiler.CodeLabel notNull = ctx.DefineLabel();
                                    ctx.BranchIfTrue(notNull, true);
                                    ctx.EmitCtor(concreteType);
                                    ctx.StoreValue(list);
                                    ctx.MarkLabel(notNull);
                                }

                                var redoFromStart = ctx.DefineLabel();
                                ctx.MarkLabel(redoFromStart);

                                // key = default(TKey); value = default(TValue);
                                if (typeof(TKey) == typeof(string))
                                {
                                    ctx.LoadValue("");
                                    ctx.StoreValue(key);
                                }
                                else
                                {
                                    ctx.InitLocal(typeof(TKey), key);
                                }
                                if (typeof(TValue) == typeof(string))
                                {
                                    ctx.LoadValue("");
                                    ctx.StoreValue(value);
                                }
                                else
                                {
                                    ctx.InitLocal(typeof(TValue), @value);
                                }

                                // token = ProtoReader.StartSubItem(reader);
                                ctx.LoadReader(true);
                                ctx.EmitCall(typeof(ProtoReader).GetMethod("StartSubItem", Compiler.ReaderUtil.ReaderStateTypeArray));
                                ctx.StoreValue(token);

                                Compiler.CodeLabel @continue = ctx.DefineLabel(), processField = ctx.DefineLabel();
                                // while ...
                                ctx.Branch(@continue, false);

                                // switch(fieldNumber)
                                ctx.MarkLabel(processField);
                                ctx.LoadValue(fieldNumber);
                                CodeLabel @default = ctx.DefineLabel(), one = ctx.DefineLabel(), two = ctx.DefineLabel();
                                ctx.Switch(new[] { @default, one, two }); // zero based, hence explicit 0

                                // case 0: default: reader.SkipField();
                                ctx.MarkLabel(@default);
                                ctx.LoadReader(true);
                                ctx.EmitCall(typeof(ProtoReader).GetMethod("SkipField", Compiler.ReaderUtil.StateTypeArray));
                                ctx.Branch(@continue, false);

                                // case 1: key = ...
                                ctx.MarkLabel(one);
                                keyTail.EmitRead(ctx, null);
                                ctx.StoreValue(key);
                                ctx.Branch(@continue, false);

                                // case 2: value = ...
                                ctx.MarkLabel(two);
                                Tail.EmitRead(ctx, Tail.RequiresOldValue ? @value : null);
                                ctx.StoreValue(value);

                                // (fieldNumber = reader.ReadFieldHeader()) > 0
                                ctx.MarkLabel(@continue);
                                ctx.EmitBasicRead("ReadFieldHeader", typeof(int));
                                ctx.CopyValue();
                                ctx.StoreValue(fieldNumber);
                                ctx.LoadValue(0);
                                ctx.BranchIfGreater(processField, false);

                                // ProtoReader.EndSubItem(token, reader);
                                ctx.LoadValue(token);
                                ctx.LoadReader(true);
                                ctx.EmitCall(typeof(ProtoReader).GetMethod("EndSubItem",
                                                                           new[] { typeof(SubItemToken), typeof(ProtoReader), Compiler.ReaderUtil.ByRefStateType }));

                                // list[key] = value;
                                ctx.LoadAddress(list, ExpectedType);
                                ctx.LoadValue(key);
                                ctx.LoadValue(@value);
                                ctx.EmitCall(indexerSet);

                                // while reader.TryReadFieldReader(fieldNumber)
                                ctx.LoadReader(true);
                                ctx.LoadValue(this.fieldNumber);
                                ctx.EmitCall(typeof(ProtoReader).GetMethod("TryReadFieldHeader",
                                                                           new[] { Compiler.ReaderUtil.ByRefStateType, typeof(int) }));
                                ctx.BranchIfTrue(redoFromStart, false);

                                if (ReturnsValue)
                                {
                                    ctx.LoadValue(list);
                                }
                            }
        }
コード例 #14
0
        protected override void EmitWrite(Compiler.CompilerContext ctx, Compiler.Local valueFrom)

        {
            using (Compiler.Local valOrNull = ctx.GetLocalWithValue(expectedType, valueFrom))

                using (Compiler.Local token = new Compiler.Local(ctx, ctx.MapType(typeof(SubItemToken))))

                {
                    ctx.LoadNullRef();

                    ctx.LoadReaderWriter();

                    ctx.EmitCall(ctx.MapType(typeof(ProtoWriter)).GetMethod("StartSubItem"));

                    ctx.StoreValue(token);



                    if (expectedType.IsValueType)

                    {
                        ctx.LoadAddress(valOrNull, expectedType);

                        ctx.LoadValue(expectedType.GetProperty("HasValue"));
                    }

                    else

                    {
                        ctx.LoadValue(valOrNull);
                    }

                    Compiler.CodeLabel @end = ctx.DefineLabel();

                    ctx.BranchIfFalse(@end, false);

                    if (expectedType.IsValueType)

                    {
                        ctx.LoadAddress(valOrNull, expectedType);

                        ctx.EmitCall(expectedType.GetMethod("GetValueOrDefault", Helpers.EmptyTypes));
                    }

                    else

                    {
                        ctx.LoadValue(valOrNull);
                    }

                    Tail.EmitWrite(ctx, null);



                    ctx.MarkLabel(@end);



                    ctx.LoadValue(token);

                    ctx.LoadReaderWriter();

                    ctx.EmitCall(ctx.MapType(typeof(ProtoWriter)).GetMethod("EndSubItem"));
                }
        }
コード例 #15
0
 public override void Write(ProtoWriter dest, ref ProtoWriter.State state, object value)
 {
     Tail.Write(dest, ref state, ((Uri)value).OriginalString);
 }
コード例 #16
0
        protected override void EmitRead(Compiler.CompilerContext ctx, Compiler.Local valueFrom)

        {
            using (Compiler.Local oldValue = ctx.GetLocalWithValue(expectedType, valueFrom))

                using (Compiler.Local token = new Compiler.Local(ctx, ctx.MapType(typeof(SubItemToken))))

                    using (Compiler.Local field = new Compiler.Local(ctx, ctx.MapType(typeof(int))))

                    {
                        ctx.LoadReaderWriter();

                        ctx.EmitCall(ctx.MapType(typeof(ProtoReader)).GetMethod("StartSubItem"));

                        ctx.StoreValue(token);



                        Compiler.CodeLabel next = ctx.DefineLabel(), processField = ctx.DefineLabel(), end = ctx.DefineLabel();



                        ctx.MarkLabel(next);



                        ctx.EmitBasicRead("ReadFieldHeader", ctx.MapType(typeof(int)));

                        ctx.CopyValue();

                        ctx.StoreValue(field);

                        ctx.LoadValue(Tag); // = 1 - process

                        ctx.BranchIfEqual(processField, true);

                        ctx.LoadValue(field);

                        ctx.LoadValue(1); // < 1 - exit

                        ctx.BranchIfLess(end, false);



                        // default: skip

                        ctx.LoadReaderWriter();

                        ctx.EmitCall(ctx.MapType(typeof(ProtoReader)).GetMethod("SkipField"));

                        ctx.Branch(next, true);



                        // process

                        ctx.MarkLabel(processField);

                        if (Tail.RequiresOldValue)

                        {
                            if (expectedType.IsValueType)

                            {
                                ctx.LoadAddress(oldValue, expectedType);

                                ctx.EmitCall(expectedType.GetMethod("GetValueOrDefault", Helpers.EmptyTypes));
                            }

                            else

                            {
                                ctx.LoadValue(oldValue);
                            }
                        }

                        Tail.EmitRead(ctx, null);

                        // note we demanded always returns a value

                        if (expectedType.IsValueType)

                        {
                            ctx.EmitCtor(expectedType, Tail.ExpectedType); // re-nullable<T> it
                        }

                        ctx.StoreValue(oldValue);

                        ctx.Branch(next, false);



                        // outro

                        ctx.MarkLabel(end);



                        ctx.LoadValue(token);

                        ctx.LoadReaderWriter();

                        ctx.EmitCall(ctx.MapType(typeof(ProtoReader)).GetMethod("EndSubItem"));

                        ctx.LoadValue(oldValue); // load the old value
                    }
        }
コード例 #17
0
 public List <GameObject> DetachOrbs(int nOrbs, Tail tail)
 {
     return(new List <GameObject>());
 }
コード例 #18
0
 public override object Read(ProtoReader source, ref ProtoReader.State state, object value)
 {
     try
     {
         int    field     = source.FieldNumber;
         object origValue = value;
         if (value == null)
         {
             value = Activator.CreateInstance(concreteType);
         }
         bool isList = IsList && !SuppressIList;
         if (packedWireType != WireType.None && source.WireType == WireType.String)
         {
             SubItemToken token = ProtoReader.StartSubItem(source, ref state);
             if (isList)
             {
                 IList list = (IList)value;
                 while (ProtoReader.HasSubValue(packedWireType, source))
                 {
                     list.Add(Tail.Read(source, ref state, null));
                 }
             }
             else
             {
                 object[] args = new object[1];
                 while (ProtoReader.HasSubValue(packedWireType, source))
                 {
                     args[0] = Tail.Read(source, ref state, null);
                     add.Invoke(value, args);
                 }
             }
             ProtoReader.EndSubItem(token, source, ref state);
         }
         else
         {
             if (isList)
             {
                 IList list = (IList)value;
                 do
                 {
                     list.Add(Tail.Read(source, ref state, null));
                 } while (source.TryReadFieldHeader(ref state, field));
             }
             else
             {
                 object[] args = new object[1];
                 do
                 {
                     args[0] = Tail.Read(source, ref state, null);
                     add.Invoke(value, args);
                 } while (source.TryReadFieldHeader(ref state, field));
             }
         }
         return(origValue == value ? null : value);
     }
     catch (TargetInvocationException tie)
     {
         if (tie.InnerException != null)
         {
             throw tie.InnerException;
         }
         throw;
     }
 }
コード例 #19
0
 public override void Write(ProtoWriter dest, ref ProtoWriter.State state, object value)
 {
     ProtoWriter.WriteFieldHeader(fieldNumber, wireType, dest, ref state);
     Tail.Write(dest, ref state, value);
 }
コード例 #20
0
 public override object Read(object value, ProtoReader source)
 {
     return(Tail.Read(value, source));
 }
コード例 #21
0
ファイル: Endpoints_1.cs プロジェクト: qbit86/arborescence
 /// <inheritdoc/>
 public override string ToString()
 {
     return(EndpointsHelpers.PairToString(Tail?.ToString(), Head?.ToString()));
 }
コード例 #22
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            bool found = false;
            Ray  ray   = Camera.main.ScreenPointToRay(Input.mousePosition);
            //RaycastHit[] hit = Physics.RaycastAll(ray);


            RaycastHit2D[] hit = Physics2D.GetRayIntersectionAll(ray, 100);

            if (hit != null && hit.Length > 0)
            {
                int iterator = 0;

                while (!found)
                {
                    head = hit[iterator].collider.gameObject.GetComponent <HeadController>();
                    iterator++;
                    if (head != null || iterator >= hit.Length)
                    {
                        found = true;
                    }
                }
            }
            if (head != null)
            {
                head.box.ErasePathFromAnotherHead(head);
            }
            else
            {
                found = false;
                Tail tail = null;
                if (hit != null && hit.Length > 0)
                {
                    int iterator = 0;

                    while (!found)
                    {
                        tail = hit[iterator].collider.gameObject.GetComponent <Tail>();
                        iterator++;
                        if (tail != null || iterator >= hit.Length)
                        {
                            found = true;
                        }
                    }
                }
                if (tail != null)
                {
                    tail.head.ErasePath();
                    head = tail.head;
                }
            }
        }

        if (Input.GetMouseButton(0))
        {
            if (head != null)
            {
                Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                // RaycastHit[] hit2 = Physics.RaycastAll(ray);

                RaycastHit2D[] hit2 = Physics2D.GetRayIntersectionAll(ray, 100);
                TileLogic      tile = null;

                if (hit2 != null && hit2.Length > 0)
                {
                    bool found    = false;
                    int  iterator = 0;


                    while (!found)
                    {
                        tile = hit2[iterator].collider.gameObject.GetComponent <TileLogic>();
                        iterator++;
                        if (tile != null || iterator >= hit2.Length)
                        {
                            found = true;
                        }
                    }

                    if (tile != null)
                    {
                        if (CheckIfNeighbours(tile.X, head.coordinates.X, tile.Y, head.coordinates.Y))
                        {
                            if (tile.IsChecked)
                            {
                                if (head.box.IsTileWithSecondHea(head, tile))
                                {
                                    head.box.isFinished = true;
                                    head.MergeHeads(tile);
                                    head = null;
                                }
                                else if (head.pathTiles.Count > 1)
                                {
                                    if (head.pathTiles[head.pathTiles.Count - 2] == tile)
                                    {
                                        head.GoBack();
                                    }
                                }
                            }
                            else
                            {
                                head.Move(tile);
                            }
                        }
                    }
                }
            }
        }

        if (Input.GetMouseButtonUp(0))
        {
            head = null;
        }
    }
コード例 #23
0
 public DataTable getDataTable(TableVersion.Value tableVersion, string searchName, Tail tail, Ear ear, Nose nose,
                               DateAndTime dateAndTime, GeoLocationData latitudeData, GeoLocationData longitudeData)
 {
     return(dataTableFactory.getDataTable(
                tableVersion,
                getCsvData(tableVersion, searchName, tail, ear, nose, dateAndTime, latitudeData, longitudeData),
                csvDataProvider.getCsvColumnNames(tableVersion)));
 }
コード例 #24
0
 protected override void EmitWrite(Compiler.CompilerContext ctx, Compiler.Local valueFrom)
 {
     ctx.LoadValue(valueFrom);
     ctx.LoadValue(absoluteUriProperty);
     Tail.EmitWrite(ctx, null);
 }
コード例 #25
0
 public void generateCsv(TableVersion.Value tableVersion, string fileName, string searchName, Tail tail, Ear ear, Nose nose,
                         DateAndTime dateAndTime, GeoLocationData latitudeData, GeoLocationData longitudeData)
 {
     csvDataToCsvTransformer.writeDataToCsv(
         tableVersion,
         getCsvData(tableVersion, searchName, tail, ear, nose, dateAndTime, latitudeData, longitudeData),
         fileName,
         csvDataProvider.getCsvColumnNames(tableVersion));
 }
コード例 #26
0
 protected override void EmitWrite(Compiler.CompilerContext ctx, Compiler.Local valueFrom)
 {
     ctx.LoadValue(valueFrom);
     ctx.LoadValue(typeof(Uri).GetProperty("AbsoluteUri"));
     Tail.EmitWrite(ctx, null);
 }
コード例 #27
0
        private void EmitWriteArrayLoop(Compiler.CompilerContext ctx, Compiler.Local i, Compiler.Local arr)

        {
            // i = 0

            ctx.LoadValue(0);

            ctx.StoreValue(i);



            // range test is last (to minimise branches)

            Compiler.CodeLabel loopTest = ctx.DefineLabel(), processItem = ctx.DefineLabel();

            ctx.Branch(loopTest, false);

            ctx.MarkLabel(processItem);



            // {...}

            ctx.LoadArrayValue(arr, i);

            if (SupportNull)

            {
                Tail.EmitWrite(ctx, null);
            }

            else

            {
                ctx.WriteNullCheckedTail(itemType, Tail, null);
            }



            // i++

            ctx.LoadValue(i);

            ctx.LoadValue(1);

            ctx.Add();

            ctx.StoreValue(i);



            // i < arr.Length

            ctx.MarkLabel(loopTest);

            ctx.LoadValue(i);

            ctx.LoadLength(arr, false);

            ctx.BranchIfLess(processItem, false);
        }