Пример #1
0
        public Instruction(String Code, VariablesManager Variables)
        {
            this.Code = Code;
            this.Variables = Variables;

            //special treatment for if statements
            if (Code.Substring(0,2) == "if")
            {
                Type = "if";
                Length = 0;
                Dynamic = true;
                IfConition = Code.Split(new char[] { '(', ')' }, StringSplitOptions.RemoveEmptyEntries)[1];

                IfInstruction = new Instruction(Code.Split(new char[] { '{', '}' }, StringSplitOptions.RemoveEmptyEntries)[1], Variables);

                if (Code.Contains("else"))
                    ElseInstruction = new Instruction(Code.Split(new char[] { '{', '}' }, StringSplitOptions.RemoveEmptyEntries)[3], Variables);
                return;
            }

            Dynamic = false;

            Type = Code.Split(new string[] { "->" }, StringSplitOptions.None)[0];

            Destinationformula = Code.Split(new string[] { "fill." }, StringSplitOptions.None)[1];
            Destination = Destinationformula;

            foreach (Char c in Arethmitic)
                Destination = Destination.Split(c)[0];

            if (Destinationformula.Contains("(") && Destinationformula.Contains(")"))
                DestinationConstant = Destinationformula.Split('(')[1].Split(')')[0];

            Length = Array.IndexOf(Types, Type);
            Length = Length < 0 ? Length : Lengths[Length];

            if (Type.Contains("@"))
            {
                TypeVariable = Type.Split('@')[1];
                Type = Type.Split('@')[0];

                if (new Regex(@"^\d+$").IsMatch(TypeVariable))
                    Length = Convert.ToInt32(TypeVariable);
                else
                    Dynamic = true;
            }

            if(Length < 0 && !Dynamic)
            {
                //treat as variable
                TypeVariable = Type;
                Type = "variable";
                Length = 0;
            }
        }
        private void update_instructions()
        {
            ReadInstructions = new Instruction[ReadData.Length];
            WriteInstructions = new Instruction[WriteData.Length];
            InitialInstructions = new Instruction[InitData.Length];

            for (int i = 0; i < ReadData.Length; i++)
                ReadInstructions[i] = new Instruction(ReadData.ElementAt(i), Variables);

            for (int i = 0; i < WriteData.Length; i++)
                WriteInstructions[i] = new Instruction(WriteData.ElementAt(i), Variables);

            for (int i = 0; i < InitData.Length; i++)
                InitialInstructions[i] = new Instruction(InitData.ElementAt(i), Variables);
        }
Пример #3
0
 public void CopyFrom(Instruction instruction)
 {
     this.Code = instruction.Code;
     this.ReadValue = instruction.ReadValue;
     this.WriteValue = instruction.WriteValue;
     this.Type = instruction.Type;
     this.TypeVariable = instruction.TypeVariable;
     this.Destination = instruction.Destination;
     this.DestinationConstant = instruction.DestinationConstant;
     this.Destinationformula = instruction.Destinationformula;
     this.Length = instruction.Length;
     this.Variables = instruction.Variables;
     this.Dynamic = instruction.Dynamic;
     this.IfConition = instruction.IfConition;
     this.IfInstruction = instruction.IfInstruction;
     this.ElseInstruction = instruction.ElseInstruction;
 }