Beispiel #1
0
 def compute(self, env: Environment):
     e = self.e.evaluate(env)
     func: function.FunctionObj = env.find_function('-')
     new_env = arrange_params_with_function_args([function.Param('e1', e)],
                                                 func, env)
     ret = func.compute(new_env)
     return ret
Beispiel #2
0
 def compute(self, env: Environment):
     x, y = self.x.evaluate(env), self.y.evaluate(env)
     func: function.FunctionObj = env.find_function('!')
     new_env = arrange_params_with_function_args([function.Param('x', x)],
                                                 func, env)
     ret = func.compute(new_env)
     return ret
Beispiel #3
0
 def compute(self, env: Environment):
     e1, e2 = self.e1.evaluate(env), self.e2.evaluate(env)
     func: function.FunctionObj = env.find_function(self.op_name)
     new_env = arrange_params_with_function_args(
         [function.Param('e1', e1),
          function.Param('e2', e2)], func, env)
     ret = func.compute(new_env)
     return ret
Beispiel #4
0
 def evaluate(self, env: Environment):
     standart_for_env = env.standart_output
     env.standart_output = self.standard_output
     try:
         for item in self.items:
             res = execute_item(item, env)
             self.standard_output(res.show_self())
     except CommandException as e:
         self.standard_output(e.message)
     except R_RuntimeError as e:
         self.standard_output(e.message)
     except RError as e:
         func = env.find_function('print')
         try:
             arrange_params_with_function_args([Param('x', e)], func, env)
         except Exception as e:
             self.standard_output(str(e))
     finally:
         env.standart_output = standart_for_env
         return None
Beispiel #5
0
    def compute(self, env: Environment):
        fun_to_find = '<-'

        if isinstance(self.item, DLRObj):
            fun_to_find = '$<-'
        elif isinstance(self.item, AssignObj):
            fun_to_find = '[<-'
        elif isinstance(self.item, SuperAssignObj):
            fun_to_find = '[[<-'

        func: function.FunctionObj = env.global_env.find_function(
            fun_to_find, self.item.get_classes_as_python_list())

        new_env = arrange_params_with_function_args([
            function.Param('x', self.item),
            function.Param('value', self.value)
        ], func, env.global_env)
        ret = func.compute(new_env)
        return ret