コード例 #1
0
ファイル: VMTranslator.cs プロジェクト: simscolony/FreeSims
        public static VMRoutine Assemble(VM vm, BHAV bhav)
        {
            var context = vm.Context;

            var routine = new VMRoutine();

            routine.Locals    = bhav.Locals;
            routine.Arguments = bhav.Args;
            routine.Type      = bhav.Type;
            routine.ID        = bhav.ChunkID;
            routine.Chunk     = bhav;
            routine.VM        = vm;
            routine.Rti       = new VMFunctionRTI {
                Name = bhav.ChunkLabel
            };

            VMInstruction[] instructions = new VMInstruction[bhav.Instructions.Length];
            for (var i = 0; i < bhav.Instructions.Length; i++)
            {
                var bhavInstruction = bhav.Instructions[i];
                var instruction     = new VMInstruction();

                instruction.Index        = (byte)i;
                instruction.Opcode       = bhavInstruction.Opcode;
                instruction.Operand      = null;
                instruction.FalsePointer = bhavInstruction.FalsePointer;
                instruction.TruePointer  = bhavInstruction.TruePointer;
                instruction.Breakpoint   = bhavInstruction.Breakpoint;
                instruction.Function     = routine;

                /** Routine call **/
                if (instruction.Opcode >= 256)
                {
                    var operand = new VMSubRoutineOperand();
                    operand.Read(bhavInstruction.Operand);
                    instruction.Operand = operand;
                }
                else
                {
                    var primitive = context.Primitives[instruction.Opcode];
                    if (primitive != null)
                    {
                        if (primitive.OperandModel != null)
                        {
                            VMPrimitiveOperand operand = (VMPrimitiveOperand)Activator.CreateInstance(primitive.OperandModel);
                            operand.Read(bhavInstruction.Operand);
                            instruction.Operand = operand;
                        }
                    }
                }
                instructions[i] = instruction;
            }
            routine.Instructions = instructions;
            return(routine);
        }
コード例 #2
0
        protected void PopulateRoutineFields(BHAV bhav, VMRoutine routine)
        {
            routine.Locals    = bhav.Locals;
            routine.Arguments = bhav.Args;
            routine.Type      = bhav.Type;
            routine.ID        = bhav.ChunkID;
            routine.Chunk     = bhav;
            routine.Rti       = new VMFunctionRTI
            {
                Name = bhav.ChunkLabel
            };

            VMInstruction[] instructions = new VMInstruction[bhav.Instructions.Length];
            for (var i = 0; i < bhav.Instructions.Length; i++)
            {
                var bhavInstruction = bhav.Instructions[i];
                var instruction     = new VMInstruction();

                instruction.Index        = (byte)i;
                instruction.Opcode       = bhavInstruction.Opcode;
                instruction.Operand      = null;
                instruction.FalsePointer = bhavInstruction.FalsePointer;
                instruction.TruePointer  = bhavInstruction.TruePointer;
                instruction.Breakpoint   = bhavInstruction.Breakpoint;
                instruction.Function     = routine;

                /** Routine call **/
                if (instruction.Opcode >= 256)
                {
                    var operand = new VMSubRoutineOperand();
                    operand.Read(bhavInstruction.Operand);
                    instruction.Operand = operand;
                }
                else
                {
                    var primitive = VMContext.Primitives[instruction.Opcode];
                    if (primitive != null)
                    {
                        if (primitive.OperandModel != null)
                        {
                            VMPrimitiveOperand operand = (VMPrimitiveOperand)Activator.CreateInstance(primitive.OperandModel);
                            operand.Read(bhavInstruction.Operand);
                            instruction.Operand = operand;
                        }
                    }
                }
                instructions[i] = instruction;
            }
            routine.Instructions = instructions;
        }
コード例 #3
0
        public void PreparePrimitive()
        {
            Descriptor = PrimitiveRegistry.GetDescriptor(Instruction.Opcode);
            Operand    = (VMPrimitiveOperand)Activator.CreateInstance(Descriptor.OperandType);
            Operand.Read(Instruction.Operand);

            Nodes         = new PrimitiveNode[2];
            Nodes[0]      = new PrimitiveNode();
            Nodes[0].Type = NodeType.False;
            Nodes[1]      = new PrimitiveNode();
            Nodes[1].Type = NodeType.True;

            Title           = new UILabel();
            Title.Alignment = TextAlignment.Middle | TextAlignment.Center;
            Title.Y         = 0;
            Title.X         = 0;
            this.Add(Title);
            Title.CaptionStyle       = TextStyle.DefaultLabel.Clone();
            Title.CaptionStyle.Font  = FSO.Client.GameFacade.EdithFont;
            Title.CaptionStyle.VFont = FSO.Client.GameFacade.EdithVectorFont;
            Title.CaptionStyle.Size  = 14;

            Index           = new UILabel();
            Index.Alignment = TextAlignment.Right | TextAlignment.Center;
            Index.Y         = 0;
            Index.X         = 0;
            this.Add(Index);
            Index.CaptionStyle       = TextStyle.DefaultLabel.Clone();
            Index.CaptionStyle.Font  = FSO.Client.GameFacade.EdithFont;
            Index.CaptionStyle.VFont = FSO.Client.GameFacade.EdithVectorFont;
            Index.CaptionStyle.Size  = 10;
            Index.Visible            = false;

            BodyTextStyle       = TextStyle.DefaultLabel.Clone();
            BodyTextStyle.Font  = FSO.Client.GameFacade.EdithFont;
            BodyTextStyle.VFont = FSO.Client.GameFacade.EdithVectorFont;
            BodyTextStyle.Size  = 12;

            CommentNode = new CommentContainer(TreeBox.Comment);
            CommentNode.OnCommentChanged += CommentNode_OnCommentChanged;
            CommentNode.Y = -3;
            Add(CommentNode);

            this.Add(Nodes[0]);
            this.Add(Nodes[1]);

            UpdateDisplay();
        }
コード例 #4
0
ファイル: PrimitiveBox.cs プロジェクト: HarryFreeMyLand/newso
        public PrimitiveBox(BHAVInstruction inst, byte ptr, BHAVContainer master)
        {
            Type        = PrimBoxType.Primitive;
            Instruction = inst;
            Descriptor  = PrimitiveRegistry.GetDescriptor(inst.Opcode);
            Operand     = (VMPrimitiveOperand)Activator.CreateInstance(Descriptor.OperandType);
            Operand.Read(inst.Operand);
            InstPtr = ptr;

            Nodes    = new PrimitiveNode[2];
            Nodes[0] = new PrimitiveNode
            {
                Type = NodeType.False
            };
            Nodes[1] = new PrimitiveNode
            {
                Type = NodeType.True
            };

            Title = new UILabel
            {
                Alignment = TextAlignment.Middle | TextAlignment.Center,
                Y         = 0,
                X         = 0
            };
            this.Add(Title);
            Title.CaptionStyle      = TextStyle.DefaultLabel.Clone();
            Title.CaptionStyle.Font = Client.GameFacade.EdithFont;
            Title.CaptionStyle.Size = 14;

            BodyTextStyle      = TextStyle.DefaultLabel.Clone();
            BodyTextStyle.Font = Client.GameFacade.EdithFont;
            BodyTextStyle.Size = 12;

            this.Add(Nodes[0]);
            this.Add(Nodes[1]);

            HitTest = ListenForMouse(new Rectangle(0, 0, Width, Height), new UIMouseEvent(MouseEvents));

            Master = master;
            UpdateDisplay();
        }
コード例 #5
0
ファイル: PrimitiveBox.cs プロジェクト: RHY3756547/FreeSO
        public PrimitiveBox(BHAVInstruction inst, byte ptr, BHAVContainer master)
        {
            Type = PrimBoxType.Primitive;
            Instruction = inst;
            Descriptor = PrimitiveRegistry.GetDescriptor(inst.Opcode);
            Operand = (VMPrimitiveOperand)Activator.CreateInstance(Descriptor.OperandType);
            Operand.Read(inst.Operand);
            InstPtr = ptr;

            Nodes = new PrimitiveNode[2];
            Nodes[0] = new PrimitiveNode();
            Nodes[0].Type = NodeType.False;
            Nodes[1] = new PrimitiveNode();
            Nodes[1].Type = NodeType.True;

            Title = new UILabel();
            Title.Alignment = TextAlignment.Middle | TextAlignment.Center;
            Title.Y = 0;
            Title.X = 0;
            this.Add(Title);
            Title.CaptionStyle = TextStyle.DefaultLabel.Clone();
            Title.CaptionStyle.Font = FSO.Client.GameFacade.EdithFont;
            Title.CaptionStyle.Size = 14;

            BodyTextStyle = TextStyle.DefaultLabel.Clone();
            BodyTextStyle.Font = FSO.Client.GameFacade.EdithFont;
            BodyTextStyle.Size = 12;

            this.Add(Nodes[0]);
            this.Add(Nodes[1]);

            HitTest = ListenForMouse(new Rectangle(0, 0, Width, Height), new UIMouseEvent(MouseEvents));

            Master = master;
            UpdateDisplay();
        }
コード例 #6
0
ファイル: PrimitiveBox.cs プロジェクト: HarryFreeMyLand/newso
 public void RefreshOperand()
 {
     Operand.Read(Instruction.Operand);
 }