From 1efade1a7667e4e1a34265fb3cf310faf8c80bb6 Mon Sep 17 00:00:00 2001 From: Emiel Bruijntjes Date: Sun, 11 Jan 2015 00:08:41 +0100 Subject: refactored script class to have a seperate opcodes class, added file class that uses this same opcodes class --- include/script.h | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'include/script.h') diff --git a/include/script.h b/include/script.h index d2eb575..a9c2921 100644 --- a/include/script.h +++ b/include/script.h @@ -62,7 +62,7 @@ public: /** * Destructor */ - virtual ~Script(); + virtual ~Script() {} /** * Is the script a valid PHP script without syntax errors? @@ -70,7 +70,7 @@ public: */ bool valid() const { - return _opcodes != nullptr; + return _opcodes.valid(); } /** @@ -78,14 +78,26 @@ public: * The return value of the script is returned * @return Value */ - Value execute() const; + Value execute() const + { + return _opcodes.execute(); + } private: /** * The opcodes - * @var zend_op_array + * @var Opcodes + */ + Opcodes _opcodes; + + /** + * Helper function to compile the source code + * @param name name of the script + * @param script actual PHP code + * @param size length of the string + * @return opcodes */ - struct _zend_op_array *_opcodes; + static struct _zend_op_array *compile(const char *name, const char *phpcode, size_t size); }; -- cgit v1.2.3