Skip to content

Commit

Permalink
Put python analysis in importModules-1.5
Browse files Browse the repository at this point in the history
Import by bundle now import css if present in a bundle
Import python-analysis only if language = python (defered to import when language modules are imported)
Show a console.log if python-analysis module is imported but cannot be used (forbidden variables)
Add a gulpfile-v4 for compatibility with gulpt 4
  • Loading branch information
GeoffreyHuck committed Apr 23, 2020
1 parent 7137088 commit af5fe2f
Show file tree
Hide file tree
Showing 17 changed files with 14,702 additions and 2,492 deletions.
89 changes: 52 additions & 37 deletions bundles/bebras-base.js

Large diffs are not rendered by default.

3,186 changes: 1,728 additions & 1,458 deletions bundles/bebras-interface.js

Large diffs are not rendered by default.

923 changes: 923 additions & 0 deletions bundles/python-analysis.js

Large diffs are not rendered by default.

1,233 changes: 996 additions & 237 deletions bundles/quickAlgo-all-blockly.js

Large diffs are not rendered by default.

5,381 changes: 5,381 additions & 0 deletions bundles/quickAlgo-all-python-1.5.js

Large diffs are not rendered by default.

2,577 changes: 2,371 additions & 206 deletions bundles/quickAlgo-all-python.js

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions ext/codecast/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

## Add the skulpt analysis to a task

In task/index.html, load the python_analysis module that is available from importModules 1.5 :

```
importModules([
...'python-analysis'...
]);
```

Note : The module will be loaded only if the python language is selected.

In task/task.js, the "variables" whole category must be selected :

```
Expand All @@ -21,16 +31,6 @@ In task/task.js, the "variables" whole category must be selected :
...
```

It is possible also to disable the modules in such case using the disableAnalysis option in gridInfos :

```
subTask.gridInfos = {
...
disableAnalysis: true,
...
}
```

## Modify the React components related to analysis display

The components are written using javascript ES6 and compiled using babel, their source code are within the **source-components-es6** directory.
Expand Down
15 changes: 15 additions & 0 deletions ext/codecast/analysis.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ var analyseSkulptState = function analyseSkulptState(suspensions, lastAnalysis)
var functionCallStack = Immutable.List();
for (var suspensionIdx = 0; suspensionIdx < suspensions.length; suspensionIdx++) {
var suspension = suspensions[suspensionIdx];
if (!isProgramSuspension(suspension)) {
continue;
}

var lastScopeAnalysis = null;
if (lastAnalysis && lastAnalysis.functionCallStack.size > suspensionIdx) {
Expand Down Expand Up @@ -200,6 +203,18 @@ var valuesWithPrevious = function valuesWithPrevious(newValue, oldValue) {
}
};

/**
* Checks whether a suspension is a program's suspension.
* It can also be only a promise encapsulated in a suspension when certain functions are called.
*
* @param {Object} suspension The suspension.
*
* @returns {boolean}
*/
var isProgramSuspension = function(suspension) {
return suspension.hasOwnProperty('$lineno');
};

/**
* Clone a skulpt value.
*
Expand Down
Loading

0 comments on commit af5fe2f

Please sign in to comment.