@@ -1751,7 +1751,9 @@ function reduceMain(
1751
1751
]
1752
1752
}
1753
1753
} ,
1754
-
1754
+ /**
1755
+ * Please refer to reduction of Program in stepper specification
1756
+ */
1755
1757
Program (
1756
1758
node : es . Program ,
1757
1759
context : Context ,
@@ -1974,7 +1976,9 @@ function reduceMain(
1974
1976
]
1975
1977
}
1976
1978
} ,
1977
-
1979
+ /**
1980
+ * Please refer to reduction of BlockStatement in stepper specification
1981
+ */
1978
1982
BlockStatement (
1979
1983
node : es . BlockStatement ,
1980
1984
context : Context ,
@@ -2195,7 +2199,10 @@ function reduceMain(
2195
2199
]
2196
2200
}
2197
2201
} ,
2198
-
2202
+ /**
2203
+ * Please refer to reduction of BlockExpression in stepper specification
2204
+ * This is related to function application
2205
+ */
2199
2206
BlockExpression (
2200
2207
node : BlockExpression ,
2201
2208
context : Context ,
@@ -3346,6 +3353,7 @@ export function getEvaluationSteps(
3346
3353
const steps : [ es . Program , string [ ] [ ] , string ] [ ] = [ ]
3347
3354
try {
3348
3355
checkProgramForUndefinedVariables ( program , context )
3356
+ //reading the step limit
3349
3357
const limit = stepLimit === undefined ? 1000 : stepLimit % 2 === 0 ? stepLimit : stepLimit + 1
3350
3358
evaluateImports ( program , context )
3351
3359
// starts with substituting predefined constants
@@ -3362,6 +3370,9 @@ export function getEvaluationSteps(
3362
3370
[ ] ,
3363
3371
'Start of evaluation'
3364
3372
]
3373
+ /**
3374
+ * push the content into frontend for showing contents in the webpage
3375
+ */
3365
3376
steps . push ( [
3366
3377
reducedWithPath [ 0 ] as es . Program ,
3367
3378
reducedWithPath [ 2 ] . length > 1 ? reducedWithPath [ 2 ] . slice ( 1 ) : reducedWithPath [ 2 ] ,
@@ -3373,13 +3384,18 @@ export function getEvaluationSteps(
3373
3384
// odd steps: program after reduction
3374
3385
let i = 1
3375
3386
let limitExceeded = false
3387
+ /**
3388
+ * This is the start of actual reduction, calling reduceMain function in each iteration
3389
+ * cause the program get reduced by one step at one iteration
3390
+ */
3376
3391
while ( isStatementsReducible ( reducedWithPath [ 0 ] as es . Program , context ) ) {
3377
3392
//Should work on isReducibleStatement instead of checking body.length
3378
3393
if ( steps . length === limit ) {
3379
3394
steps [ steps . length - 1 ] = [ ast . program ( [ ] ) , [ ] , 'Maximum number of steps exceeded' ]
3380
3395
limitExceeded = true
3381
3396
break
3382
3397
}
3398
+ //the program reduce by one step here
3383
3399
reducedWithPath = reduceMain ( reducedWithPath [ 0 ] , context )
3384
3400
steps . push ( [
3385
3401
reducedWithPath [ 0 ] as es . Program ,
@@ -3406,9 +3422,6 @@ export function getEvaluationSteps(
3406
3422
] )
3407
3423
}
3408
3424
}
3409
- if ( steps . length === 0 ) {
3410
- steps . push ( [ reducedWithPath [ 0 ] as es . Program , [ ] , 'Nothing to evaluate' ] )
3411
- }
3412
3425
return steps
3413
3426
} catch ( error ) {
3414
3427
if ( error instanceof RuntimeSourceError ) {
0 commit comments