Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add the comment to link the specification #1680

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/py-slang
27 changes: 24 additions & 3 deletions src/stepper/stepper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1751,7 +1751,9 @@ function reduceMain(
]
}
},

/**
* Please refer to reduction of Program in stepper specification
*/
Program(
node: es.Program,
context: Context,
Expand Down Expand Up @@ -1974,7 +1976,9 @@ function reduceMain(
]
}
},

/**
* Please refer to reduction of BlockStatement in stepper specification
*/
BlockStatement(
node: es.BlockStatement,
context: Context,
Expand Down Expand Up @@ -2194,7 +2198,10 @@ function reduceMain(
]
}
},

/**
* Please refer to reduction of BlockExpression in stepper specification
* This is related to function application
*/
BlockExpression(
node: BlockExpression,
context: Context,
Expand Down Expand Up @@ -3345,6 +3352,7 @@ export function getEvaluationSteps(
const steps: [es.Program, string[][], string][] = []
try {
checkProgramForUndefinedVariables(program, context)
//reading the step limit
const limit = stepLimit === undefined ? 1000 : stepLimit % 2 === 0 ? stepLimit : stepLimit + 1
evaluateImports(program, context)
// starts with substituting predefined constants
Expand All @@ -3361,6 +3369,10 @@ export function getEvaluationSteps(
[],
'Start of evaluation'
]
/**
* push the content into frontend for showing contents in the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sentence is not complete: "in the" ...

* this comment may not be correct, please correct it if you find any mismatch in description
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment "this comment may not be correct" is quite strange. Are you referring to the one above: "push the content..."?

steps.push([
reducedWithPath[0] as es.Program,
reducedWithPath[2].length > 1 ? reducedWithPath[2].slice(1) : reducedWithPath[2],
Expand All @@ -3372,13 +3384,18 @@ export function getEvaluationSteps(
// odd steps: program after reduction
let i = 1
let limitExceeded = false
/**
* This is the start of actual reduction, calling reduceMain function in each iteration
* cause the program get reduced by one step at one iteration
*/
while (isStatementsReducible(reducedWithPath[0] as es.Program, context)) {
//Should work on isReducibleStatement instead of checking body.length
if (steps.length === limit) {
steps[steps.length - 1] = [ast.program([]), [], 'Maximum number of steps exceeded']
limitExceeded = true
break
}
//the program reduce by one step here
reducedWithPath = reduceMain(reducedWithPath[0], context)
steps.push([
reducedWithPath[0] as es.Program,
Expand All @@ -3405,6 +3422,10 @@ export function getEvaluationSteps(
])
}
}
/**
* Deprecated check for empty program
* It can be deleted or kept as a reference for legacy code.
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the check is deprecated, please delete it.

if (steps.length === 0) {
steps.push([reducedWithPath[0] as es.Program, [], 'Nothing to evaluate'])
}
Expand Down
Loading