コード例 #1
0
def is_varname_valid(varname, custom_units, custom_structs, constants):
    from vyper.functions import dispatch_table, stmt_dispatch_table
    built_in_functions = [x for x in stmt_dispatch_table.keys()] + \
      [x for x in dispatch_table.keys()]
    if custom_units is None:
        custom_units = set()
    if varname.lower() in {cu.lower() for cu in custom_units}:
        return False, "%s is a unit name." % varname

    # struct names are case sensitive.
    if varname in custom_structs:
        return False, "Duplicate name: %s, previously defined as a struct." % varname
    if varname in constants:
        return False, "Duplicate name: %s, previously defined as a constant." % varname
    if varname.lower() in base_types:
        return False, "%s name is a base type." % varname
    if varname.lower() in valid_units:
        return False, "%s is a built in unit type." % varname
    if varname.lower() in reserved_words:
        return False, "%s is a a reserved keyword." % varname
    if varname.upper() in opcodes:
        return False, "%s is a reserved keyword (EVM opcode)." % varname
    if varname.lower() in built_in_functions:
        return False, "%s is a built in function."
    if not re.match('^[_a-zA-Z][a-zA-Z0-9_]*$', varname):
        return False, "%s contains invalid character(s)."
    return True, ""
コード例 #2
0
def is_varname_valid(varname, custom_units):
    from vyper.functions import dispatch_table, stmt_dispatch_table
    built_in_functions = [x for x in stmt_dispatch_table.keys()] + \
      [x for x in dispatch_table.keys()]
    if custom_units is None:
        custom_units = []
    if varname.lower() in [cu.lower() for cu in custom_units]:
        return False
    if varname.lower() in base_types:
        return False
    if varname.lower() in valid_units:
        return False
    if varname.lower() in reserved_words:
        return False
    if varname.upper() in opcodes:
        return False
    if varname.lower() in built_in_functions:
        return False
    return True
コード例 #3
0
def is_varname_valid(varname, custom_units, custom_structs):
    from vyper.functions import dispatch_table, stmt_dispatch_table
    built_in_functions = [x for x in stmt_dispatch_table.keys()] + \
      [x for x in dispatch_table.keys()]
    if custom_units is None:
        custom_units = set()
    if varname.lower() in {cu.lower() for cu in custom_units}:
        return False
    # struct names are case sensitive.
    if varname in custom_structs:
        return False
    if varname.lower() in base_types:
        return False
    if varname.lower() in valid_units:
        return False
    if varname.lower() in reserved_words:
        return False
    if varname.upper() in opcodes:
        return False
    if varname.lower() in built_in_functions:
        return False
    if not re.match('^[_a-zA-Z][a-zA-Z0-9_]*$', varname):
        return False
    return True