@@ -8,12 +8,14 @@ Sk.gensymcount = 0;
8
8
* @param {string } filename
9
9
* @param {SymbolTable } st
10
10
* @param {number } flags
11
+ * @param {boolean= } canSuspend whether compiled code can suspend
11
12
* @param {string= } sourceCodeForAnnotation used to add original source to listing if desired
12
13
*/
13
- function Compiler ( filename , st , flags , sourceCodeForAnnotation ) {
14
+ function Compiler ( filename , st , flags , canSuspend , sourceCodeForAnnotation ) {
14
15
this . filename = filename ;
15
16
this . st = st ;
16
17
this . flags = flags ;
18
+ this . canSuspend = canSuspend ;
17
19
this . interactive = false ;
18
20
this . nestlevel = 0 ;
19
21
@@ -1430,7 +1432,7 @@ Compiler.prototype.buildcodeobj = function (n, coname, decorator_list, args, cal
1430
1432
//
1431
1433
// enter the new scope, and create the first block
1432
1434
//
1433
- scopename = this . enterScope ( coname , n , n . lineno , true ) ;
1435
+ scopename = this . enterScope ( coname , n , n . lineno , this . canSuspend ) ;
1434
1436
1435
1437
isGenerator = this . u . ste . generator ;
1436
1438
hasFree = this . u . ste . hasFree ;
@@ -2213,7 +2215,7 @@ Compiler.prototype.cprint = function (s) {
2213
2215
Compiler . prototype . cmod = function ( mod ) {
2214
2216
//print("-----");
2215
2217
//print(Sk.astDump(mod));
2216
- var modf = this . enterScope ( new Sk . builtin . str ( "<module>" ) , mod , 0 , true ) ;
2218
+ var modf = this . enterScope ( new Sk . builtin . str ( "<module>" ) , mod , 0 , this . canSuspend ) ;
2217
2219
2218
2220
var entryBlock = this . newBlock ( "module entry" ) ;
2219
2221
this . u . prefixCode = "var " + modf + "=(function($modname){" ;
@@ -2279,13 +2281,14 @@ Compiler.prototype.cmod = function (mod) {
2279
2281
* @param {string } source the code
2280
2282
* @param {string } filename where it came from
2281
2283
* @param {string } mode one of 'exec', 'eval', or 'single'
2284
+ * @param {boolean= } canSuspend if the generated code supports suspension
2282
2285
*/
2283
- Sk . compile = function ( source , filename , mode ) {
2286
+ Sk . compile = function ( source , filename , mode , canSuspend ) {
2284
2287
//print("FILE:", filename);
2285
2288
var cst = Sk . parse ( filename , source ) ;
2286
2289
var ast = Sk . astFromParse ( cst , filename ) ;
2287
2290
var st = Sk . symboltable ( ast , filename ) ;
2288
- var c = new Compiler ( filename , st , 0 , source ) ; // todo; CO_xxx
2291
+ var c = new Compiler ( filename , st , 0 , canSuspend , source ) ; // todo; CO_xxx
2289
2292
var funcname = c . cmod ( ast ) ;
2290
2293
var ret = c . result . join ( "" ) ;
2291
2294
return {
0 commit comments