aboutsummaryrefslogtreecommitdiff
path: root/interpreter.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2013-06-01 00:35:11 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2013-06-01 00:35:11 +0300
commitae62e8ca11b08b9b554b83b48e743f672708ace5 (patch)
treed1aa4853fec86d0a4150c49418c8c81a87920a61 /interpreter.py
parent3872cd024e8dcf4f4e3eabf9d9060c0433113027 (diff)
downloadmeson-ae62e8ca11b08b9b554b83b48e743f672708ace5.zip
meson-ae62e8ca11b08b9b554b83b48e743f672708ace5.tar.gz
meson-ae62e8ca11b08b9b554b83b48e743f672708ace5.tar.bz2
Can detect sizes of expressions.
Diffstat (limited to 'interpreter.py')
-rwxr-xr-xinterpreter.py10
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