def _execute_method_defined(self, toward: data.UserDefinedMethod, name, args, repeat): # check sizeof args if toward.args_min > len(args) or toward.args_max < len(args): raise TooMuchOrLessArguments(name, toward.args_min, len(args), int(toward.args_min != toward.args_max)) args = attr.AttrTuple(args, self._execute_recursive) # add placeholders placeholders = attr.AttrTuple(toward.args, self._execute_recursive) # call method method = self._execute_recursive(toward.toward) method.code = toward.toward.encode() # add repeat repeat = self._execute_recursive(repeat) # create iteration method = attr.AttrIteration(toward.name, method, toward, placeholders, args, repeat) return method
def _execute_operator(self, toward: data.Operator): # substitute if toward.op in Exp.IS: return self._execute_operator_modify(toward) # the others args = attr.AttrTuple([toward.sub, toward.obj, toward.step, *toward.args], self._execute_recursive) op = attr.AttrOP(toward.op, args) return op
def _execute_method_delegate(self, toward): name = toward.name toward_origin = toward repeat = toward.repeat while toward.toward is not None and not toward.is_method_defined: toward = toward.toward if name.startswith(Exp.CODE_CONST): name = toward.name repeat = self._execute_method_update_repeat(repeat, toward.repeat) # if builtins if toward.is_builtins: method, fixed = self.find_method(toward.name, find_hidden=False) args = attr.AttrTuple(toward_origin.args, self._execute_recursive) kwargs = attr.AttrDict(toward_origin.kwargs, self._execute_recursive) repeat = self._execute_recursive(repeat) return attr.AttrMethod(self, name, method, toward_origin, args, kwargs, fixed, repeat) # if user-defined methods if toward.is_method_defined: return self._execute_method_defined(toward, name, toward_origin.args, repeat) # undefined error raise RequiredError(toward.name)
def _execute_tuple(self, toward: data.Tuple): return attr.AttrTuple(toward.args, self._execute_recursive)
def _execute_shell(self, toward: data.Shell, attribute_type): sub = self._execute_recursive(toward.sub) args = attr.AttrTuple(toward.args, self._execute_recursive) op = attribute_type(sub, args) return op