expr.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:viper 作者: ethereum 项目源码 文件源码
def subscript(self):
        sub = Expr.parse_variable_location(self.expr.value, self.context)
        if isinstance(sub.typ, (MappingType, ListType)):
            if 'value' not in vars(self.expr.slice):
                raise StructureException("Array access must access a single element, not a slice", self.expr)
            index = Expr.parse_value_expr(self.expr.slice.value, self.context)
        elif isinstance(sub.typ, TupleType):
            if not isinstance(self.expr.slice.value, ast.Num) or self.expr.slice.value.n < 0 or self.expr.slice.value.n >= len(sub.typ.members):
                raise TypeMismatchException("Tuple index invalid", self.expr.slice.value)
            index = self.expr.slice.value.n
        else:
            raise TypeMismatchException("Bad subscript attempt", self.expr.value)
        o = add_variable_offset(sub, index)
        o.mutable = sub.mutable
        return o
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号