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

Snap Compiler #3048

Draft
wants to merge 37 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
12bf287
Create compile block + template compile block code
ochan1 Nov 25, 2021
3e83dee
Add compiler javascript
ochan1 Nov 27, 2021
3350986
Refactor Compiler + Add compiler related blocks
ochan1 Nov 27, 2021
cb27493
Use generators to pause compiled for Snap GUI
ochan1 Nov 28, 2021
afe49de
Comment about Empty Push Context
ochan1 Nov 30, 2021
1f7e1a6
Restyle While loop + Add doRepeat Compiler
ochan1 Nov 30, 2021
2fc38ce
Add try catch to gen + Unlist JSCompiler
ochan1 Dec 10, 2021
eaae8f5
Copywrite + current_process + Impl doFor
ochan1 Dec 10, 2021
4efbfbe
Encode String and Decode during eval, avoid JS injection
ochan1 Feb 25, 2022
c8a8aa5
Efficient string concatination for default
ochan1 Feb 25, 2022
b6dc00d
Prevent JS injection on naming compiled blocks
ochan1 Mar 8, 2022
55151fe
Option yielding optional, but required on forever
ochan1 Mar 8, 2022
7d46916
Code creation in string cleanup
ochan1 Mar 8, 2022
6315eb0
Support Color Type reporting
ochan1 Mar 8, 2022
8fac606
Yield enabling, var name injection prevent, compile loops
ochan1 Mar 9, 2022
e8efa10
doRepeat for loop syntax re-stying
ochan1 Mar 25, 2022
ba6a6c1
Compiling on Click Structure
ochan1 Mar 25, 2022
bc6872e
Rename proc_context_vars, refactor loop params, and design + setup Cu…
ochan1 Mar 25, 2022
b2d659d
If about to compile detect yield on stack
ochan1 Mar 25, 2022
4eea919
Fix forever loop when block compile fails
ochan1 Apr 14, 2022
8077342
WIP - compiling function params and potential vars
ochan1 Apr 14, 2022
10effee
Pop Context and Report Error on runtime errors
ochan1 Apr 15, 2022
c63a24a
Progress on Compiling Fns - need to send fns to running script
ochan1 Apr 15, 2022
fdc633d
Additional Compiled Function Resets when Input Slots change
ochan1 Apr 17, 2022
0fe91d0
Custom Block Compiler - MVP
ochan1 Apr 20, 2022
3d286b2
Custom Block Compiler - MVP
ochan1 Apr 20, 2022
86e3731
Comment clarify if statement return for reportGo
ochan1 Apr 20, 2022
ac0165d
Merge branch 'snap-compiler' of github.com:ochan1/Snap into snap-comp…
ochan1 May 3, 2022
c0f53ac
Reverse adding compile block - comment compile fn
ochan1 May 3, 2022
d5ad9cf
Flag on custom block definition if custom block by having def var
ochan1 May 3, 2022
4f54bbb
Pop all contexts made during compiler - hotfix
ochan1 May 3, 2022
e3c2f49
Compile ReporterBlocks by themselves
ochan1 May 3, 2022
e826ffd
Compiler inside warp + harness to yield out less often
ochan1 May 14, 2022
66a8e1e
Fix dofor + Receiver fix
ochan1 May 14, 2022
01c39ad
Enable skipping some yields and Report smart popping to func context
ochan1 May 14, 2022
bc6a115
Increase yield and use timeout in compiler running
ochan1 May 15, 2022
82d0ac8
Cleanup report + custom block compiler code
ochan1 May 16, 2022
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
Next Next commit
Create compile block + template compile block code
ochan1 committed Nov 25, 2021
commit 12bf287e1f2eb00d114d815ea15abf6a26d0c31d
6 changes: 3 additions & 3 deletions src/gui.js
Original file line number Diff line number Diff line change
@@ -1391,12 +1391,12 @@ IDE_Morph.prototype.createCategories = function () {
i;

myself.categories.children.forEach((button, i) => {
row = i < 8 ? i % 4 : i - 4;
col = (i < 4 || i > 7) ? 1 : 2;
row = i % 4;
col = Math.floor(i / 4) + 1;
button.setPosition(new Point(
l + (col * xPadding + ((col - 1) * buttonWidth)),
t + ((row + 1) * yPadding + (row * buttonHeight) + border) +
(i > 7 ? border + 2 : 0)
border + 2
));
});

11 changes: 11 additions & 0 deletions src/objects.js
Original file line number Diff line number Diff line change
@@ -146,6 +146,7 @@ SpriteMorph.prototype.categories =
'sensing',
'operators',
'variables',
'compiler',
'lists',
'other'
];
@@ -159,6 +160,7 @@ SpriteMorph.prototype.blockColor = {
sensing : new Color(4, 148, 220),
operators : new Color(98, 194, 19),
variables : new Color(243, 118, 29),
compiler : new Color(253, 0, 91),
lists : new Color(217, 77, 17),
other: new Color(150, 150, 150)
};
@@ -1316,6 +1318,13 @@ SpriteMorph.prototype.initBlocks = function () {
category: 'other',
spec: 'script variables %scriptVars'
},

// Compiler
compile: {
type: 'command',
category: 'compiler',
spec: 'compile %c'
},

// inheritance
doDeleteAttr: {
@@ -2776,6 +2785,8 @@ SpriteMorph.prototype.blockTemplates = function (
blocks.push('-');
blocks.push(block('doShowTable'));
}
} else if (category == "compiler") {
blocks.push(block('compile'));
}

return blocks;
11 changes: 11 additions & 0 deletions src/threads.js
Original file line number Diff line number Diff line change
@@ -1688,6 +1688,17 @@ Process.prototype.evaluateCustomBlock = function () {
runnable.expression = runnable.expression.blockSequence();
};

// Process compiler primitives
Process.prototype.compile = function () {
var args = this.context.inputs;
var body = args[0];
if (body) {
console.log(body.blockSequence());
}
console.log("COMPILER");
console.trace();
}

// Process variables primitives

Process.prototype.doDeclareVariables = function (varNames) {