Пример #1
0
 public ILVariable(VariableKind kind, Type type, StackType stackType, bool isPinned)
 {
     if (type == null)
         throw new ArgumentNullException(nameof(type));
     this.Kind = kind;
     this.type = type;
     this.IsPinned = isPinned;
     this.HasInitialValue = hasInitialValue;
     this.StackType = stackType;
     if (kind == VariableKind.Parameter)
         this.HasInitialValue = true;
 }
Пример #2
0
        /// <summary>
        /// Gets whether the type is an IL floating point type.
        /// Returns true for F4 or F8.
        /// </summary>
        public static bool IsFloatType(this StackType type)
        {
            switch (type)
            {
            case StackType.F4:
            case StackType.F8:
                return(true);

            default:
                return(false);
            }
        }
Пример #3
0
        /// <summary>
        /// Edit the settings of the selected reel in the lvIncluded ListView
        /// </summary>
        private void EditReel(object sender, EventArgs e)
        {
            if (lvIncluded.SelectedItems.Count == 0)
            {
                MessageBox.Show("Please select a reel", "no reel selected", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            //Find the reel in reelsToPlace
            ListViewItem selectedItem = lvIncluded.SelectedItems[0];
            Reel         selectedReel = reelsToPlace.Find(curReel => curReel.GetDisplayString() == selectedItem.Text);

#if DEBUG
            //this only happens when the listview isn't updated when the reelsToPlace list is changed (the reel is in the excludedReels list)
            if (selectedReel == null)
            {
                MessageBox.Show("This error is the result of a bug," + Environment.NewLine + "You shouldn't see this" + Environment.NewLine + "have a nice day, for safety reasens the program wil automaticly close", "critical error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
                return;
            }
#endif
            FootprintForm dialog = new FootprintForm();
            dialog.SetFootprint(selectedReel.Footprint);
            if (dialog.ShowDialog() == DialogResult.Yes)
            {
                StackType oldStackType  = selectedReel.Footprint.StackType;
                Footprint footprint     = dialog.GetFootprint();
                bool      couldBePlaced = pnpMachine.ReelCanBePlaced(selectedReel);
                //Changing MPN = creating/changing footprint, changing reels with the original MPN makes it impossible to break the "connection"
                //between reels with the same MPN
                //however, all reels with the same new MPN need to be updated
                selectedReel.Footprint = footprint; //If the manufacturer part number changes, it needs to be updated
                List <Reel> similarReels = reelsToPlace.FindAll(reel => reel.ManufacturerPartNumber == footprint.ManufacturerPartNumber);
                similarReels.AddRange(excludedReels.FindAll(reel => reel.ManufacturerPartNumber == footprint.ManufacturerPartNumber));
                foreach (Reel reel in similarReels)
                {
                    reel.Footprint = footprint;
                }
                //BUG: a splitted reel is not in the list
                //if ((stacklisters.Count != 0) &&
                //    (couldBePlaced != pnpMachine.ReelCanBeplaced(selectedReel) || (footprint.StackType != oldStackType)))
                //{
                //    //IF the stacks are fild AND
                //    //the ReelCanBePlaced state is changed OR the StackType has changed
                //    //then should the stacks be updated
                //    AssignReels(false);
                //}
                if (stacklisters.Count != 0)
                {
                    AssignReels(false);
                }
                GenerateListViewItems(lvIncluded, reelsToPlace);
            }
        }
Пример #4
0
        public bool MatchLdLen(StackType type, out ILInstruction array)
        {
            var inst = this as LdLen;

            if (inst != null && inst.ResultType == type)
            {
                array = inst.Array;
                return(true);
            }
            array = null;
            return(false);
        }
Пример #5
0
 public BinaryNumericInstruction(BinaryNumericOperator op, ILInstruction left, ILInstruction right, StackType leftInputType, StackType rightInputType, bool checkForOverflow, Sign sign, bool isLifted = false)
     : base(OpCode.BinaryNumericInstruction, left, right)
 {
     this.CheckForOverflow = checkForOverflow;
     this.Sign             = sign;
     this.Operator         = op;
     this.LeftInputType    = leftInputType;
     this.RightInputType   = rightInputType;
     this.IsLifted         = isLifted;
     this.resultType       = ComputeResultType(op, LeftInputType, RightInputType);
     Debug.Assert(resultType != StackType.Unknown);
 }
Пример #6
0
            static StackType UnifyTypes(StackType a, StackType b)
            {
                if (a == b)
                {
                    return(a);
                }

                return((a, b) switch {
                    (StackType.Bool, StackType.YololNumber) => StackType.YololNumber,
                    (StackType.YololNumber, StackType.Bool) => StackType.YololNumber,

                    _ => StackType.YololValue
                });
 private bool IsValidTypeStackTypeMerge(StackType stackType1, StackType stackType2)
 {
     if (stackType1 == StackType.I && stackType2 == StackType.I4)
     {
         return(true);
     }
     if (stackType1 == StackType.I4 && stackType2 == StackType.I)
     {
         return(true);
     }
     // allow merging unknown type with any other type
     return(stackType1 == StackType.Unknown || stackType2 == StackType.Unknown);
 }
Пример #8
0
        ILVariable RegisterVariable(VariableKind kind, IType type, StackType stackType, string name = null)
        {
            var variable = new ILVariable(kind, type, stackType);

            if (string.IsNullOrWhiteSpace(name))
            {
                name = "I_" + (helperVariableCount++);
                variable.HasGeneratedName = true;
            }
            variable.Name = name;
            Variables.Add(variable);
            return(variable);
        }
Пример #9
0
 public Stack(string name, StackType type, Border border)
 {
     Name     = name;
     Type     = type;
     Border   = border;
     Location = border.Margin;
     if (type == StackType.Main)
     {
         Canvas = CreateStackCanvas();
         LogicResources.Main.Children.Add(Canvas);
         Canvas.MouseEnter += Canvas_MouseEnter;
     }
 }
Пример #10
0
        /// <summary>
        /// Gets whether the type is an IL integer type.
        /// Returns true for I4, I, or I8.
        /// </summary>
        public static bool IsIntegerType(this StackType type)
        {
            switch (type)
            {
            case StackType.I4:
            case StackType.I:
            case StackType.I8:
                return(true);

            default:
                return(false);
            }
        }
Пример #11
0
        public Conv(ILInstruction argument, StackType inputType, Sign inputSign, PrimitiveType targetType, bool checkForOverflow, bool isLifted = false)
            : base(OpCode.Conv, argument)
        {
            bool needsSign = checkForOverflow || targetType == PrimitiveType.R4 || targetType == PrimitiveType.R8;

            Debug.Assert(!(needsSign && inputSign == Sign.None));
            this.InputType        = inputType;
            this.InputSign        = needsSign ? inputSign : Sign.None;
            this.TargetType       = targetType;
            this.CheckForOverflow = checkForOverflow;
            this.Kind             = GetConversionKind(targetType, this.InputType, this.InputSign);
            this.IsLifted         = isLifted;
        }
Пример #12
0
 /// <summary>
 /// Initializes a new <see cref="PickAndPlaceLib.Footprint"/>
 /// </summary>
 /// <param name="manufacturerPartNumber">Manufacturer part number of the new footprint</param>
 /// <param name="width">Width of the new footprint</param>
 /// <param name="length">Length of the new footprint</param>
 /// <param name="height">Height of the new footprint</param>
 /// <param name="rotation">Rotation of the new footprint</param>
 /// <param name="offsetStackX">Horizontal stack offset of the new footprint</param>
 /// <param name="offsetStackY">Vertical stack offset of the new footprint</param>
 /// <param name="feedRate">Feedrate of the new footprint</param>
 /// <param name="nozzle">Nozzle of the new footprint</param>
 /// <param name="stackType">Stack type of the new footprint</param>
 internal Footprint(string manufacturerPartNumber, float width, float length, float height, int rotation,
                    float offsetStackX, float offsetStackY, float feedRate, Nozzle nozzle, StackType stackType)
 {
     manufacturerPartNumber_ = manufacturerPartNumber;
     width_        = width;
     length_       = length;
     height_       = height;
     rotation_     = rotation;
     offsetStackX_ = offsetStackX;
     offsetStackY_ = offsetStackY;
     feedRate_     = feedRate;
     nozzle_       = nozzle;
     stackType_    = stackType;
 }
Пример #13
0
        public static IType FindType(this ICompilation compilation, StackType stackType, Sign sign = Sign.None)
        {
            switch (stackType)
            {
            case StackType.Unknown:
                return(SpecialType.UnknownType);

            case StackType.Ref:
                return(new ByReferenceType(SpecialType.UnknownType));

            default:
                return(compilation.FindType(stackType.ToKnownTypeCode(sign)));
            }
        }
Пример #14
0
 static void EmitNullaryIntegerOperation(StackType st, bool allowConstants)
 {
     if (!allowConstants || RandomBool(0.5))
     {
         // declare a parameter instead of using a constant
         method.Parameters.Add(new ParameterDefinition(RandomType(st)));
         parameterStackTypes.Add(st);
         processor.Emit(OpCodes.Ldarg, method.Parameters.Last());
     }
     else
     {
         EmitConstantInteger(st);
     }
 }
Пример #15
0
        public Conv(ILInstruction argument, StackType inputType, Sign inputSign, PrimitiveType targetType, bool checkForOverflow, bool isLifted = false)
            : base(OpCode.Conv, argument)
        {
            bool needsSign = checkForOverflow || (!inputType.IsFloatType() && (targetType == PrimitiveType.R4 || targetType == PrimitiveType.R8));

            Debug.Assert(!(needsSign && inputSign == Sign.None));
            this.InputSign        = needsSign ? inputSign : Sign.None;
            this.InputType        = inputType;
            this.TargetType       = targetType;
            this.CheckForOverflow = checkForOverflow;
            this.Kind             = GetConversionKind(targetType, this.InputType, this.InputSign);
            // Debug.Assert(Kind != ConversionKind.Invalid); // invalid conversion can happen with invalid IL/missing references
            this.IsLifted = isLifted;
        }
Пример #16
0
        public StacksCarousel(StackType stackType)
        {
            InitializeComponent();

            var visiblePage = new DailyPage();

            Children.Add(new DailyPage(-1));
            Children.Add(visiblePage);
            Children.Add(new DailyPage(1));

            CurrentPage = visiblePage;

            Title = CurrentPage.Title;
        }
Пример #17
0
        public void Block_there_and_back(StackType inbound, StackType outbound, bool framingEnabled)
        {
            Transaction     a               = Build.A.Transaction.TestObject;
            Transaction     b               = Build.A.Transaction.TestObject;
            Block           block           = Build.A.Block.WithTransactions(a, b).TestObject;
            NewBlockMessage newBlockMessage = new NewBlockMessage();

            newBlockMessage.Block = block;

            NewBlockMessageSerializer newBlockMessageSerializer = new NewBlockMessageSerializer();

            byte[] data    = newBlockMessageSerializer.Serialize(newBlockMessage);
            Packet packet  = new Packet("eth", 7, data);
            Packet decoded = Run(packet, inbound, outbound, framingEnabled);
        }
Пример #18
0
 public ILVariable(VariableKind kind, IType type, StackType stackType, int index)
 {
     if (type == null)
     {
         throw new ArgumentNullException(nameof(type));
     }
     this.Kind      = kind;
     this.type      = type;
     this.StackType = stackType;
     this.Index     = index;
     if (kind == VariableKind.Parameter)
     {
         this.HasInitialValue = true;
     }
 }
Пример #19
0
 public void SetStackType()
 {
     if (Surpassed.Count > 0)
     {
         StackType = StackType.Surpassed;
     }
     else if (Refresh.Count > 0)
     {
         StackType = StackType.Refresh;
     }
     else if (Surpass.Count > 0)
     {
         StackType = StackType.Surpass;
     }
 }
Пример #20
0
    private void SetupStacks(StackType stackType, string configName, Vector2 panelPosition, InitialPosition[] initialPosition, Vector2 offset)
    {
        var subPath       = stackType.ToString() + "s";
        var elementCounts = ConfigLoader.Load(subPath, configName);
        var elementsList  = Stack.GetElements(elementCounts);
        int countInStack  = elementsList.Count / GameSettings.NumberOfPlayers;

        elementsList.Shuffle();
        var stackElementLists = elementsList.ChunkBy(countInStack + 1);

        for (var i = 0; i < stackElementLists.Count; ++i)
        {
            Spawner.SpawnStack(stackType, panelPosition * initialPosition[i].BoardQuarter + offset, $"Graphics/{subPath}/Common", stackElementLists[i]);
        }
    }
Пример #21
0
 public NumericCompoundAssign(BinaryNumericInstruction binary, ILInstruction target, ILInstruction value, IType type, CompoundAssignmentType compoundAssignmentType)
     : base(OpCode.NumericCompoundAssign, compoundAssignmentType, target, value)
 {
     Debug.Assert(IsBinaryCompatibleWithType(binary, type));
     this.CheckForOverflow     = binary.CheckForOverflow;
     this.Sign                 = binary.Sign;
     this.LeftInputType        = binary.LeftInputType;
     this.RightInputType       = binary.RightInputType;
     this.UnderlyingResultType = binary.UnderlyingResultType;
     this.Operator             = binary.Operator;
     this.IsLifted             = binary.IsLifted;
     this.type                 = type;
     this.ILRange              = binary.ILRange;
     Debug.Assert(compoundAssignmentType == CompoundAssignmentType.EvaluatesToNewValue || (Operator == BinaryNumericOperator.Add || Operator == BinaryNumericOperator.Sub));
     Debug.Assert(IsValidCompoundAssignmentTarget(Target));
 }
Пример #22
0
        /*-------------------------------------------------------------*/
        private void btnSave_Click(object sender, EventArgs e)
        {
            string    manufacturerPartNumber = tbxMPN.Text;
            float     width     = (float)nudwuWidth.Value;
            float     length    = (float)nudwuLength.Value;
            float     height    = (float)nudwuHeight.Value;
            int       rotation  = Convert.ToInt32(nudwuRotation.Value);
            float     offsetX   = (float)bscOffset.valueX;
            float     offsetY   = (float)bscOffset.valueY;
            float     feedRate  = (float)nudwuFeedRate.Value;
            StackType stackType = PNPconverterTools.stringToStackType(cbxStackType.SelectedItem.ToString());

            footPrint_        = new Footprint(manufacturerPartNumber, width, length, height, rotation, offsetX, offsetY, feedRate, (Nozzle)cbxNozzle.SelectedItem, stackType);
            this.DialogResult = DialogResult.Yes;
            this.Close();
        }
Пример #23
0
        private Packet Run(Packet packet, StackType inbound, StackType outbound, bool framingEnabled)
        {
            EmbeddedChannel embeddedChannel = null;

            try
            {
                embeddedChannel = BuildEmbeddedChannel(inbound, outbound, framingEnabled);

                if (outbound == StackType.Zero)
                {
                    IByteBuffer packetBuffer = embeddedChannel.Allocator.Buffer(1 + packet.Data.Length);
                    packetBuffer.WriteByte(packet.PacketType);
                    packetBuffer.WriteBytes(packet.Data);
                    embeddedChannel.WriteOutbound(packetBuffer);
                }
                else // allocating
                {
                    embeddedChannel.WriteOutbound(packet);
                }

                while (embeddedChannel.OutboundMessages.Any())
                {
                    IByteBuffer encodedPacket = embeddedChannel.ReadOutbound <IByteBuffer>();
                    embeddedChannel.WriteInbound(encodedPacket);
                }

                if (inbound == StackType.Zero)
                {
                    ZeroPacket decodedPacket = embeddedChannel.ReadInbound <ZeroPacket>();
                    Assert.AreEqual(packet.Data.ToHexString(), decodedPacket.Content.ReadAllHex());
                    Assert.AreEqual(packet.PacketType, decodedPacket.PacketType);
                    decodedPacket.Release();
                }
                else // allocating
                {
                    Packet decodedPacket = embeddedChannel.ReadInbound <Packet>();
                    Assert.AreEqual(packet.Data.ToHexString(), decodedPacket.Data.ToHexString());
                    Assert.AreEqual(packet.PacketType, decodedPacket.PacketType);
                }
            }
            finally
            {
                embeddedChannel?.Finish();
            }

            return(packet);
        }
Пример #24
0
        public Stack AddStack(Slot slot, StackType type = StackType.undefined, StackMethod stackMethod = StackMethod.normal)
        {
            var stack = new Stack(this, cardBack, slotTex, spriteBatch, stackOffsetHorizontal, stackOffsetVertical)
            {
                slot   = slot,
                method = stackMethod,
                type   = type
            };

            slot.stack = stack;

            stacks.Add(stack);

            dragonDrop.Add(slot);

            return(stack);
        }
Пример #25
0
        static void EmitInteger(StackType st, bool allowConstants)
        {
            double what = random.NextDouble();

            if (what < 0.3)
            {
                EmitBinaryIntegerOperation(st);
            }
            else if (what < 0.6)
            {
                EmitUnaryIntegerOperation(st, allowConstants);
            }
            else
            {
                EmitNullaryIntegerOperation(st, allowConstants);
            }
        }
Пример #26
0
 public NumericCompoundAssign(BinaryNumericInstruction binary, ILInstruction target,
                              CompoundTargetKind targetKind, ILInstruction value, IType type, CompoundEvalMode evalMode)
     : base(OpCode.NumericCompoundAssign, evalMode, target, targetKind, value)
 {
     Debug.Assert(IsBinaryCompatibleWithType(binary, type));
     this.CheckForOverflow     = binary.CheckForOverflow;
     this.Sign                 = binary.Sign;
     this.LeftInputType        = binary.LeftInputType;
     this.RightInputType       = binary.RightInputType;
     this.UnderlyingResultType = binary.UnderlyingResultType;
     this.Operator             = binary.Operator;
     this.IsLifted             = binary.IsLifted;
     this.type                 = type;
     this.AddILRange(binary);
     Debug.Assert(evalMode == CompoundEvalMode.EvaluatesToNewValue || (Operator == BinaryNumericOperator.Add || Operator == BinaryNumericOperator.Sub));
     Debug.Assert(this.ResultType == (IsLifted ? StackType.O : UnderlyingResultType));
 }
Пример #27
0
        static void EmitComplexInteger(StackType st)
        {
            double what = random.NextDouble();

            if (what < 0.9)
            {
                EmitBinaryIntegerOperation(st);
            }
            else if (what < 0.95)
            {
                EmitUnaryIntegerOperation(st, allowConstants: true);
            }
            else
            {
                EmitNullaryIntegerOperation(st, allowConstants: true);
            }
        }
Пример #28
0
        public static IEntity SpawnStack(StackType stack, int amount, EntityCoordinates coordinates, IEntityManager?entityManager = null)
        {
            entityManager ??= IoCManager.Resolve <IEntityManager>();

            string prototype;

            switch (stack)
            {
            case StackType.Metal:
                prototype = "SteelSheet1";
                break;

            case StackType.Glass:
                prototype = "GlassSheet1";
                break;

            case StackType.MetalRod:
                prototype = "MetalRodStack1";
                break;

            case StackType.Phoron:
                prototype = "PhoronStack1";
                break;

            case StackType.Plasteel:
                prototype = "PlasteelSheet1";
                break;

            case StackType.Cable:
                prototype = "ApcExtensionCableStack1";
                break;

            // TODO: Add more.

            default:
                throw new ArgumentOutOfRangeException(nameof(stack), "Stack type doesn't have a prototype specified yet!");
            }

            var ent = entityManager.SpawnEntity(prototype, coordinates);

            var stackComponent = ent.GetComponent <StackComponent>();

            stackComponent.Count = Math.Min(amount, stackComponent.MaxCount);

            return(ent);
        }
Пример #29
0
        static void EmitConstantInteger(StackType st)
        {
            switch (st)
            {
            case StackType.I4:
                if (RandomBool(0.9))
                {
                    processor.Emit(OpCodes.Ldc_I4, unchecked (RandomElement(commonIntegers) + random.Next(-1, 2)));
                }
                else
                {
                    processor.Emit(OpCodes.Ldc_I4, random.Next());
                }
                break;

            case StackType.I:
                if (RandomBool(0.5))
                {
                    goto case StackType.I4;
                }
                else
                {
                    EmitConstantInteger(StackType.I8);
                    processor.Emit(OpCodes.Conv_I);
                    break;
                }

            case StackType.I8:
                if (RandomBool(0.75))
                {
                    processor.Emit(OpCodes.Ldc_I8, (long)unchecked (RandomElement(commonIntegers) + random.Next(-1, 2)));
                }
                else if (RandomBool(0.2))
                {
                    processor.Emit(OpCodes.Ldc_I8, RandomBool(0.5) ? long.MaxValue : long.MinValue);
                }
                else
                {
                    processor.Emit(OpCodes.Ldc_I8, (long)random.Next() << 32 | (uint)random.Next());
                }
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Пример #30
0
        public void Get_block_bodies_there_and_back(StackType inbound, StackType outbound, bool framingEnabled)
        {
            var hashes = new Keccak[256];

            for (int i = 0; i < hashes.Length; i++)
            {
                hashes[i] = Keccak.Compute(i.ToString());
            }

            GetBlockBodiesMessage message = new GetBlockBodiesMessage(hashes);

            GetBlockBodiesMessageSerializer serializer = new GetBlockBodiesMessageSerializer();

            byte[] data = serializer.Serialize(message);

            Packet packet  = new Packet("eth", 5, data);
            Packet decoded = Run(packet, inbound, outbound, framingEnabled);
        }
Пример #31
0
            void PushStack(StackType type)
            {
                ProcStack newStack = new ProcStack();
                newStack.StackType = type;
                curIndex++;

                switch (type) {
                    case StackType.Dict:
                        newStack.StackObj = new Dict();

                        if (curIndex == myBytes.Length) throw Ops.EofError("EOF read where object expected");

                        if (myBytes[curIndex] == '0')
                            newStack.StackCount = 0;
                        else
                            newStack.StackCount = -1;

                        break;
                    case StackType.List:
                        newStack.StackObj = new List();
                        newStack.StackCount = ReadInt32();
                        break;
                    case StackType.Tuple:
                        newStack.StackObj = new List<object>();
                        newStack.StackCount = ReadInt32();
                        break;
                }

                if (stack == null) stack = new Stack<ProcStack>();

                stack.Push(newStack);
            }
Пример #32
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StackElement"/> class.
 /// </summary>
 /// <param name="Alpha">The alpha of the node.</param>
 /// <param name="Blend">The blending coefficient of the node.</param>
 /// <param name="flags">The flags of the node.</param>
 /// <param name="Type">The type of the node.</param>
 public StackElement(float Alpha, float Blend, int flags, StackType Type)
 {
     alpha = Alpha;
     blend = Blend;
     type = Type;
 }
Пример #33
0
 public IRegister AllocateDestReg(StackType type = StackType.STACK_I4)
 {
     return new Register(_registers++);
 }
Пример #34
0
            private void PushStack (StackType type) {
                ProcStack newStack = new ProcStack ();
                newStack.StackType = type;

                switch (type) {
                    case StackType.Dict:
                        newStack.StackObj = new PythonDictionary ();
                        newStack.StackCount = -1;
                        break;
                    case StackType.List:
                        newStack.StackObj = new List ();
                        newStack.StackCount = ReadInt32 ();
                        break;
                    case StackType.Tuple:
                        newStack.StackCount = ReadInt32 ();
                        newStack.StackObj = new List<object> (newStack.StackCount);
                        break;
                    case StackType.Set:
                        newStack.StackObj = new SetCollection ();
                        newStack.StackCount = ReadInt32 ();
                        break;
                    case StackType.FrozenSet:
                        newStack.StackCount = ReadInt32 ();
                        newStack.StackObj = new List<object> (newStack.StackCount);
                        break;
                }

                if (_stack == null) _stack = new Stack<ProcStack> ();

                _stack.Push (newStack);
            }
Пример #35
0
 public ChipStack(double stack, StackType type)
 {
     this.Stack = stack;
     this.StackType = type;
 }