import ast
from typing import Dict

from boa3.model.builtin.interop.nativecontract import StdLibMethod
from boa3.model.variable import Variable


class AtoiMethod(StdLibMethod):

    def __init__(self):
        from boa3.model.type.type import Type
        identifier = 'atoi'
        syscall = 'atoi'
        args: Dict[str, Variable] = {
            'value': Variable(Type.str),
            'base': Variable(Type.int)
        }

        args_default = ast.parse("{0}".format(10)
                                 ).body[0].value

        super().__init__(identifier, syscall, args, defaults=[args_default], return_type=Type.int)
