Ejemplo n.º 1
0
        public Interpreter()
        {
            _embededFunctions = new Dictionary <string, FunctionDelegate>();
            _embededLibrary   = new EmbededLibrary();
            _embededFunctions = _embededLibrary.EmbededFunctions;
            _erros            = new Errors();

            InstructionExecutors.Add(typeof(InstructionAssignment), ExecuteInstructionAssignment);
            InstructionExecutors.Add(typeof(InstructionValue), ExecuteInstructionValue);
            InstructionExecutors.Add(typeof(InstructionFunction), ExecuteInstructionFunction);
            InstructionExecutors.Add(typeof(InstructionVariableValue), ExecuteInstructionVariableValue);
            InstructionExecutors.Add(typeof(InstructionReturn), ExecuteInstructionReturn);
            InstructionExecutors.Add(typeof(InstructionOperation), ExecuteInstructionOperation);
            InstructionExecutors.Add(typeof(InstructionCondition), ExecuteInstructionCondition);
            InstructionExecutors.Add(typeof(InstructionWhile), ExecuteInstructionWhile);
            InstructionExecutors.Add(typeof(InstructionDoWhile), ExecuteInstructionDoWhile);
            InstructionExecutors.Add(typeof(InstructionUnaryOperator), ExecuteInstructionUnaryOperator);
            InstructionExecutors.Add(typeof(InstructionFor), ExecuteInstructionFor);
            InstructionExecutors.Add(typeof(InstructionNegation), ExecuteInstructionNegation);
            InstructionExecutors.Add(typeof(InstructionBreak), ExecuteInstructionBreak);
        }
Ejemplo n.º 2
0
        InstructionResult ExecuteInstruction(Instruction instruction)
        {
            Type type = instruction.GetType();

            return(InstructionExecutors[type](instruction));
        }