Esempio n. 1
0
        public override void Visit(Instruction ins)
        {
            Tuple <int, global::VM.Bytecode.Instruction> opcodeWithInstruction = _bytecode.FindByName(ins.Name);
            var opcode      = opcodeWithInstruction.Item1;
            var instruction = opcodeWithInstruction.Item2;

            if (opcode == -1)
            {
                _errors.Add(new Error(String.Format("Error on line {0}: Opcode for instruction '{1}' not found.", ins.LineNumber, ins.Name)));
                return;
            }

            if (instruction.NumArgs != ins.Parameters.Count)
            {
                _errors.Add(new Error(String.Format("Error on line {0}: Instruction '{1}' has wrong parameter count. Expected {2}, got {3}", ins.LineNumber, instruction.Name, instruction.NumArgs, ins.Parameters.Count)));
                return;
            }
        }