Sleep function enabled.
parent
b75236096e
commit
c6e3678f15
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue