|
|
|
@ -2096,23 +2096,23 @@ class Interpreter(): |
|
|
|
|
obj = self.to_native(obj) |
|
|
|
|
(posargs, _) = self.reduce_arguments(args) |
|
|
|
|
if method_name == 'to_string': |
|
|
|
|
if len(posargs) == 0: |
|
|
|
|
if obj == True: |
|
|
|
|
return 'true' |
|
|
|
|
else: |
|
|
|
|
return 'false' |
|
|
|
|
elif len(posargs) == 2 and isinstance(posargs[0], str) and isinstance(posargs[1], str): |
|
|
|
|
if obj == True: |
|
|
|
|
return posargs[0] |
|
|
|
|
else: |
|
|
|
|
return posargs[1] |
|
|
|
|
else: |
|
|
|
|
raise InterpreterException('bool.to_string() must have either no arguments or exactly two string arguments.') |
|
|
|
|
if len(posargs) == 0: |
|
|
|
|
if obj == True: |
|
|
|
|
return 'true' |
|
|
|
|
else: |
|
|
|
|
return 'false' |
|
|
|
|
elif len(posargs) == 2 and isinstance(posargs[0], str) and isinstance(posargs[1], str): |
|
|
|
|
if obj == True: |
|
|
|
|
return posargs[0] |
|
|
|
|
else: |
|
|
|
|
return posargs[1] |
|
|
|
|
else: |
|
|
|
|
raise InterpreterException('bool.to_string() must have either no arguments or exactly two string arguments.') |
|
|
|
|
elif method_name == 'to_int': |
|
|
|
|
if obj == True: |
|
|
|
|
return 1 |
|
|
|
|
else: |
|
|
|
|
return 0 |
|
|
|
|
if obj == True: |
|
|
|
|
return 1 |
|
|
|
|
else: |
|
|
|
|
return 0 |
|
|
|
|
else: |
|
|
|
|
raise InterpreterException('Unknown method "%s" for a boolean.' % method_name) |
|
|
|
|
|
|
|
|
|