def translate_pat_Call_constructor(self, ctx, pat, scrutinee_trans): scrutinee_trans_copy = astx.copy_node(scrutinee_trans) args, keywords = pat.args, pat.keywords idx = self.idx conditions = [] binding_translations = _util.odict() for i, arg in enumerate(args): n = _util.odict_idx_of(idx, i) elt_scrutinee_trans = astx.make_Subscript_Num_Index( scrutinee_trans_copy, n) elt_condition, elt_binding_translations = ctx.translate_pat( arg, elt_scrutinee_trans) conditions.append(elt_condition) binding_translations.update(elt_binding_translations) for keyword in keywords: n = _util.odict_idx_of(idx, keyword.arg) elt_scrutinee_trans = astx.make_Subscript_Num_Index( scrutinee_trans_copy, n) elt_condition, elt_binding_translations = ctx.translate_pat( keyword.value, elt_scrutinee_trans) conditions.append(elt_condition) binding_translations.update(elt_binding_translations) condition = ast.BoolOp(op=ast.And(), values=conditions) return (condition, binding_translations)
def translate_pat_Call_constructor(self, ctx, pat, scrutinee_trans): scrutinee_trans_copy = astx.copy_node(scrutinee_trans) args, keywords = pat.args, pat.keywords idx = self.idx conditions = [] binding_translations = _util.odict() for i, arg in enumerate(args): n = _util.odict_idx_of(idx, i) elt_scrutinee_trans = astx.make_Subscript_Num_Index( scrutinee_trans_copy, n) elt_condition, elt_binding_translations = ctx.translate_pat( arg, elt_scrutinee_trans) conditions.append(elt_condition) binding_translations.update(elt_binding_translations) for keyword in keywords: n = _util.odict_idx_of(idx, keyword.arg) elt_scrutinee_trans = astx.make_Subscript_Num_Index( scrutinee_trans_copy, n) elt_condition, elt_binding_translations = ctx.translate_pat( keyword.value, elt_scrutinee_trans) conditions.append(elt_condition) binding_translations.update(elt_binding_translations) condition = ast.BoolOp( op=ast.And(), values=conditions) return (condition, binding_translations)
def translate_Attribute(self, ctx, e): n = _util.odict_idx_of(self.idx, e.attr) return ast.copy_location(ast.Subscript( value=ctx.translate(e.value), slice=ast.Num(n=n), ctx=ast.Load() ), e)
def translate_Subscript(self, ctx, e): value = e.value label = e.slice.value.label n = _util.odict_idx_of(self.idx, label) return ast.copy_location( ast.Subscript(value=ctx.translate(value), slice=ast.Num(n=n), ctx=ast.Load()), e)
def translate_Subscript(self, ctx, e): value = e.value label = e.slice.value.label n = _util.odict_idx_of(self.idx, label) return ast.copy_location(ast.Subscript( value=ctx.translate(value), slice=ast.Num(n=n), ctx=ast.Load() ), e)
def translate_Call_constructor(self, ctx, e): args, keywords = e.args, e.keywords idx = self.idx elt_translation = [] idx_mapping = [] for i, arg in enumerate(args): elt_translation.append(ctx.translate(arg)) n = _util.odict_idx_of(idx, i) idx_mapping.append(n) for keyword in keywords: label = keyword.arg value = keyword.value elt_translation.append(ctx.translate(value)) n = _util.odict_idx_of(idx, label) idx_mapping.append(n) arg_translation = ast.Tuple(elts=elt_translation) return ast.copy_location( _labeled_translation(idx_mapping, arg_translation), e)
def translate_Call_constructor(self, ctx, e): args, keywords = e.args, e.keywords idx = self.idx elt_translation = [] idx_mapping = [] for i, arg in enumerate(args): elt_translation.append(ctx.translate(arg)) n = _util.odict_idx_of(idx, i) idx_mapping.append(n) for keyword in keywords: label = keyword.arg value = keyword.value elt_translation.append(ctx.translate(value)) n = _util.odict_idx_of(idx, label) idx_mapping.append(n) arg_translation = ast.Tuple(elts=elt_translation) return ast.copy_location(_labeled_translation(idx_mapping, arg_translation), e)
def translate_Dict(self, ctx, e): keys, values = e.keys, e.values idx = self.idx elt_translation = [] idx_mapping = [] for key, value in zip(keys, values): label = key.label elt_translation.append(ctx.translate(value)) i = _util.odict_idx_of(idx, label) idx_mapping.append(i) arg_translation = ast.Tuple(elts=elt_translation) return ast.copy_location( _labeled_translation(idx_mapping, arg_translation), e)
def translate_pat_Dict(self, ctx, pat, scrutinee_trans): scrutinee_trans_copy = astx.copy_node(scrutinee_trans) keys, values = pat.keys, pat.values idx = self.idx conditions = [] binding_translations = _util.odict() for key, value in zip(keys, values): label = key.label n = _util.odict_idx_of(idx, label) elt_scrutinee_trans = astx.make_Subscript_Num_Index( scrutinee_trans_copy, n) elt_condition, elt_binding_translations = ctx.translate_pat( value, elt_scrutinee_trans) conditions.append(elt_condition) binding_translations.update(elt_binding_translations) condition = ast.BoolOp(op=ast.And(), values=conditions) return (condition, binding_translations)
def translate_pat_Dict(self, ctx, pat, scrutinee_trans): scrutinee_trans_copy = astx.copy_node(scrutinee_trans) keys, values = pat.keys, pat.values idx = self.idx conditions = [] binding_translations = _util.odict() for key, value in zip(keys, values): label = key.label n = _util.odict_idx_of(idx, label) elt_scrutinee_trans = astx.make_Subscript_Num_Index( scrutinee_trans_copy, n) elt_condition, elt_binding_translations = ctx.translate_pat( value, elt_scrutinee_trans) conditions.append(elt_condition) binding_translations.update(elt_binding_translations) condition = ast.BoolOp( op=ast.And(), values=conditions) return (condition, binding_translations)
def translate_Attribute(self, ctx, e): n = _util.odict_idx_of(self.idx, e.attr) return ast.copy_location( ast.Subscript(value=ctx.translate(e.value), slice=ast.Num(n=n), ctx=ast.Load()), e)