Exemplo n.º 1
0
def to_string(expr, args, kwargs, context):
    in_arg = args[0]
    if in_arg.typ.maxlen > args[1].slice.value.n:
        raise TypeMismatchException(
            'Cannot convert as input bytes are larger than max length', expr)
    return LLLnode(value=in_arg.value,
                   args=in_arg.args,
                   typ=StringType(in_arg.typ.maxlen),
                   pos=getpos(expr),
                   location=in_arg.location)
Exemplo n.º 2
0
 def string(self):
     bytez, bytez_length = string_to_bytes(self.expr.value)
     typ = StringType(bytez_length, is_literal=True)
     return self._make_bytelike(typ, bytez, bytez_length)
Exemplo n.º 3
0
 def string(self):
     bytez, bytez_length = string_to_bytes(self.expr.s)
     return self._make_bytelike(StringType(bytez_length), bytez,
                                bytez_length)