Skip to content

Commit

Permalink
can't return instruction
Browse files Browse the repository at this point in the history
  • Loading branch information
yyrdl committed Sep 18, 2018
1 parent f9c5c10 commit 4994ff8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 22 deletions.
3 changes: 1 addition & 2 deletions cc.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 1 addition & 13 deletions index.js
Expand Up @@ -250,19 +250,7 @@
return func;
};
exec.return = function () {
var result = [].slice.call(arguments);
var ins = new Instruction(function () {
var final_result = [];
for (var i = 0; i < result.length; i++) {
if (result[i] && ("function" === typeof result[i]) && (result[i]._ins instanceof Instruction)) {
final_result[i] = result[i]._ins.result();
} else {
final_result[i] = result[i];
}
}
cpu.exit(null, final_result);
}, insType.normal);
cpu.stack.push(ins);
return cpu.exit(null,[].slice.call(arguments));
};
function _resume() {
cpu.resume([].slice.call(arguments));
Expand Down
8 changes: 4 additions & 4 deletions readme.md
Expand Up @@ -124,10 +124,10 @@ function sync_code() {
*
* More: you can return multiple result ,like "exec.return(1,2,3,4,5)"
* */
exec.return(exec(function () {
return ctx.v;
}));

exec(function(){
exec.return(ctx.v);
});
});

}
Expand Down
6 changes: 3 additions & 3 deletions test/test.js
Expand Up @@ -118,9 +118,9 @@ describe("basic",function () {
cc(function (exec,ctx,resume) {
exec.async(async_func).assign("result")(resume);

exec.return(exec(function () {
return ctx.result[0];
}));
exec(function(){
exec.return(ctx.result[0]);
});

})(function (err,result) {

Expand Down

0 comments on commit 4994ff8

Please sign in to comment.