Replace hexadecimal parse hack
This commit is contained in:
parent
7a57c6729d
commit
29b1ca27c3
|
@ -140,20 +140,15 @@ static func are_arrays_equal(a1: Array, a2: Array, fuzzy_types: bool = true) ->
|
||||||
return true
|
return true
|
||||||
|
|
||||||
static func limited_eval(token: String):
|
static func limited_eval(token: String):
|
||||||
# Try hexadecimal literal
|
|
||||||
if token.begins_with('0x'):
|
|
||||||
var hex := token.hex_to_int()
|
|
||||||
if hex > 0:
|
|
||||||
return hex
|
|
||||||
elif token.substr(2).is_valid_integer():
|
|
||||||
# Special case for 0x000000...
|
|
||||||
return 0
|
|
||||||
# Try int literal
|
# Try int literal
|
||||||
if token.is_valid_integer():
|
if token.is_valid_integer():
|
||||||
return int(token)
|
return int(token)
|
||||||
# Try float literal
|
# Try float literal
|
||||||
if token.is_valid_float():
|
if token.is_valid_float():
|
||||||
return float(token)
|
return float(token)
|
||||||
|
# Try hexadecimal literal
|
||||||
|
if token.is_valid_hex_number(true):
|
||||||
|
return token.hex_to_int()
|
||||||
# Try bool literal
|
# Try bool literal
|
||||||
match token.to_lower():
|
match token.to_lower():
|
||||||
'true':
|
'true':
|
||||||
|
|
Loading…
Reference in New Issue