diff options
Diffstat (limited to 'interpreter.py')
-rwxr-xr-x | interpreter.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/interpreter.py b/interpreter.py index 5153c2e..fdbeed1 100755 --- a/interpreter.py +++ b/interpreter.py @@ -537,10 +537,19 @@ class CompilerHolder(InterpreterObject): self.compiler = compiler self.methods.update({'compiles': self.compiles_method, 'get_id': self.get_id_method, + 'sizeof': self.sizeof_method, }) def get_id_method(self, args, kwargs): return self.compiler.get_id() + + def sizeof_method(self, args, kwargs): + if len(args) != 1: + raise InterpreterException('Sizeof takes exactly one argument.') + string = args[0] + if not isinstance(string, str): + raise InterpreterException('Argument to sizeof must be a string.') + return self.compiler.sizeof(string) def compiles_method(self, args, kwargs): if len(args) != 1: @@ -944,6 +953,7 @@ class Interpreter(): isinstance(value, str) or\ isinstance(value, nodes.BoolStatement) or\ isinstance(value, nodes.IntStatement) or\ + isinstance(value, int) or \ isinstance(value, list): return True return False |