Skip to content

Commit

Permalink
builtin 'sleep'
Browse files Browse the repository at this point in the history
  • Loading branch information
NotFound committed Sep 21, 2011
1 parent 533961d commit d1abd4f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Winxed news.
(C) Julián Albo "NotFound"

Version 1.3
- builtin sleep

Version 1.2
- Don't tailcall by defaultinside try blocks to avoid losing the
Expand Down
30 changes: 30 additions & 0 deletions winxedst1.winxed
Original file line number Diff line number Diff line change
Expand Up @@ -1565,6 +1565,32 @@ function builtineval_indexof_pos(owner, start, args)
return integerValue(owner, start, indexof(strfrom, strsearch, pos));
}

function builtin_sleep(e, owner, start, result, args)
{
var expr = args[0];
string reg;
string type = expr.checkresult();
switch (type) {
case REGint:
reg = expr.emit_getint(e);
break;
case REGfloat:
reg = expr.emit_get(e);
break;
default:
if (expr.isnull())
reg = "0";
else {
string aux = expr.emit_get(e);
reg = owner.tempreg(REGfloat);
e.annotate(start);
e.emitset(reg, aux);
}
}
e.annotate(start);
e.emitarg1('sleep', reg);
}

function getbuiltins(builder)
{
builder.add(new BuiltinFunctionEval('int',
Expand Down Expand Up @@ -1601,6 +1627,10 @@ function getbuiltins(builder)
'time %0',
REGfloat
));
builder.add(new BuiltinFunction('sleep',
builtin_sleep,
REGnone, REGraw1
));
builder.add(new BuiltinFunction('spawnw',
'spawnw %0, %1',
REGint, REGvar
Expand Down

0 comments on commit d1abd4f

Please sign in to comment.