summaryrefslogtreecommitdiffstats
path: root/Sencha-lang
diff options
context:
space:
mode:
authorJustyna Ilczuk <justyna.ilczuk@gmail.com>2012-12-22 12:20:23 +0100
committerJustyna Ilczuk <justyna.ilczuk@gmail.com>2012-12-22 12:20:23 +0100
commitc6e3678f15338085d737c58c2057dcd1891f4310 (patch)
tree80dcc1215d60af52553c43b229aa833751b157f1 /Sencha-lang
parentb75236096e2b8077ed5b8f2107575a075d657f14 (diff)
downloadsencha-lang-c6e3678f15338085d737c58c2057dcd1891f4310.tar.gz
sencha-lang-c6e3678f15338085d737c58c2057dcd1891f4310.tar.bz2
sencha-lang-c6e3678f15338085d737c58c2057dcd1891f4310.zip
Sleep function enabled.
Diffstat (limited to 'Sencha-lang')
-rw-r--r--Sencha-lang/main.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/Sencha-lang/main.cpp b/Sencha-lang/main.cpp
index df30ff6..e903992 100644
--- a/Sencha-lang/main.cpp
+++ b/Sencha-lang/main.cpp
@@ -8,7 +8,9 @@
#include "Tests/TestLexer.h"
#include "Context.h"
#include "ASTInspector.h"
-#include "Tests/tests.h"
+#include "Tests/tests.h"
+#include <unistd.h>
+
using namespace std;
@@ -25,6 +27,24 @@ dupa"); declaration? hello? It's probably temporary effect of searching for this
>>
*/
+
+SenchaObject sleep(vector<ASTExpression *> arguments)
+{
+ SenchaObject argument = arguments[0]->evaluate();
+ if(argument.type == SenchaObject::integer_number && argument.integer >= 0)
+ {
+ cout << "valid argument for sleep: " << argument.integer << endl;
+ usleep(1000 * argument.integer);
+ return SenchaObject();
+ }
+ else
+ {
+ cout << "invalid argument for sleep";
+ argument.type = SenchaObject::invalid;
+ return argument;
+ }
+
+}
SenchaObject print(vector<ASTExpression *> arguments)
{
for (auto argument: arguments)
@@ -130,6 +150,7 @@ void interactive()
context.register_function("sin", s_sin);
context.register_function("cos", s_cos);
context.register_function("tan", s_tan);
+ context.register_function("sleep", sleep);
Parser parser(&context);
ASTInspector inspector;
@@ -188,6 +209,7 @@ int main(int argc, char *argv[])
context.register_function("sin", s_sin);
context.register_function("cos", s_cos);
context.register_function("tan", s_tan);
+ context.register_function("sleep", sleep);
Parser parser(&context);