rcompiler 0.0.0-stage → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -0
- package/CONTRIBUTING.md +38 -0
- package/LICENSE +15 -0
- package/README.md +170 -2
- package/SECURITY.md +27 -0
- package/assets/placeholder.png +0 -0
- package/docs/ARCHITECTURE.md +74 -0
- package/docs/CLI.md +67 -0
- package/docs/COMPATIBILITY.md +29 -0
- package/docs/CONFIG.md +73 -0
- package/docs/DEBUGGING.md +46 -0
- package/docs/NATIVE.md +110 -0
- package/docs/ROADMAP.md +12 -0
- package/docs/TESTING.md +55 -0
- package/exts/args.js +142 -0
- package/exts/freya.js +430 -0
- package/exts/fs.js +317 -0
- package/exts/io.js +396 -0
- package/exts/path.js +208 -0
- package/exts/process.js +416 -0
- package/exts/rcompilerExt.js +1396 -0
- package/exts/vartypeany.js +131 -0
- package/package.json +50 -4
- package/src/analysis.js +571 -0
- package/src/assets.js +335 -0
- package/src/cli.js +359 -0
- package/src/emit.js +353 -0
- package/src/mods.js +146 -0
- package/src/preludes.js +4174 -0
- package/src/rcompiler.js +2785 -0
- package/src/standard.js +1452 -0
- package/src/targets.js +129 -0
- package/src/web.js +1593 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
(function (util) {
|
|
2
|
+
const ArgumentType = util.ArgumentType ? util.ArgumentType : { STRING: 'r', NUMBER: 'r' };
|
|
3
|
+
const gf = (args, name) => {
|
|
4
|
+
return args.scope.block.fields[name][0];
|
|
5
|
+
}
|
|
6
|
+
const kp = util.Cast ? util.Cast.keywordunParse : () => { };
|
|
7
|
+
if (typeof vm != 'undefined') {
|
|
8
|
+
const runtime = vm.runtime;
|
|
9
|
+
const cbfsb = runtime._convertBlockForScratchBlocks.bind(runtime);
|
|
10
|
+
runtime._convertBlockForScratchBlocks = function (blockInfo, categoryInfo) {
|
|
11
|
+
const res = cbfsb(blockInfo, categoryInfo);
|
|
12
|
+
if (blockInfo.usefield) {
|
|
13
|
+
blockInfo.usefield.forEach(element => {
|
|
14
|
+
res.json.args0[element] = {
|
|
15
|
+
"type": "field_input",
|
|
16
|
+
"name": res.json.args0[element].name,
|
|
17
|
+
"text": res.json.args0[element].text,
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return res;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
class vartypeany {
|
|
25
|
+
id = 'vartypeany';
|
|
26
|
+
blocks = [
|
|
27
|
+
{
|
|
28
|
+
opcode: 'varcreate',
|
|
29
|
+
blockType: util.BlockType.COMMAND,
|
|
30
|
+
text: '创建变量 [var] 为 [thing]',
|
|
31
|
+
usefield: ['0'],
|
|
32
|
+
arguments: {
|
|
33
|
+
var: {
|
|
34
|
+
type: ArgumentType.STRING,
|
|
35
|
+
defalutValue: ''
|
|
36
|
+
},
|
|
37
|
+
thing: {
|
|
38
|
+
type: ArgumentType.STRING,
|
|
39
|
+
defalutValue: ''
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
opcode: 'varset',
|
|
45
|
+
blockType: util.BlockType.COMMAND,
|
|
46
|
+
text: '设置 [var] 为 [thing]',
|
|
47
|
+
usefield: ['0'],
|
|
48
|
+
arguments: {
|
|
49
|
+
var: {
|
|
50
|
+
type: ArgumentType.STRING,
|
|
51
|
+
defalutValue: ''
|
|
52
|
+
},
|
|
53
|
+
thing: {
|
|
54
|
+
type: ArgumentType.STRING,
|
|
55
|
+
defalutValue: ''
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
opcode: 'varincrease',
|
|
61
|
+
blockType: util.BlockType.COMMAND,
|
|
62
|
+
text: '变量 [var] [choice] [thing]',
|
|
63
|
+
usefield: ['0'],
|
|
64
|
+
arguments: {
|
|
65
|
+
var: {
|
|
66
|
+
type: ArgumentType.STRING,
|
|
67
|
+
defalutValue: ''
|
|
68
|
+
},
|
|
69
|
+
choice: {
|
|
70
|
+
type: ArgumentType.STRING,
|
|
71
|
+
menu: 'choices'
|
|
72
|
+
},
|
|
73
|
+
thing: {
|
|
74
|
+
type: ArgumentType.STRING,
|
|
75
|
+
defalutValue: ''
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
opcode: 'varget',
|
|
81
|
+
blockType: util.BlockType.REPORTER,
|
|
82
|
+
text: '变量 [var]',
|
|
83
|
+
usefield: ['0'],
|
|
84
|
+
arguments: {
|
|
85
|
+
var: {
|
|
86
|
+
type: ArgumentType.STRING,
|
|
87
|
+
defalutValue: ''
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
]
|
|
92
|
+
getInfo() {
|
|
93
|
+
return {
|
|
94
|
+
id: this.id,
|
|
95
|
+
name: '自由变量',
|
|
96
|
+
color1: '#9999FF',
|
|
97
|
+
blocks: this.blocks,
|
|
98
|
+
menus: { choices: ['增加', '减少'] }
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
varcreate(args) {
|
|
102
|
+
if (!util.isCompiler)
|
|
103
|
+
return;
|
|
104
|
+
const varin = kp(gf(args, 'var'));
|
|
105
|
+
args.compiler += `let mut anyvar_${varin} = ${args.thing.input};\n`;
|
|
106
|
+
return args.compiler;
|
|
107
|
+
}
|
|
108
|
+
varincrease(args) {
|
|
109
|
+
if (!util.isCompiler)
|
|
110
|
+
return;
|
|
111
|
+
const varin = kp(gf(args, 'var'));
|
|
112
|
+
const choice = gf(args, 'choice');
|
|
113
|
+
args.compiler += `anyvar_${varin} ${choice == '增加' ? '+=' : '-='} ${args.thing.input};\n`;
|
|
114
|
+
return args.compiler;
|
|
115
|
+
}
|
|
116
|
+
varget(args) {
|
|
117
|
+
if (!util.isCompiler)
|
|
118
|
+
return '';
|
|
119
|
+
const varin = kp(gf(args, 'var'));
|
|
120
|
+
return new util.TypeInput.Any('anyvar_' + varin);
|
|
121
|
+
}
|
|
122
|
+
varset(args) {
|
|
123
|
+
if (!util.isCompiler)
|
|
124
|
+
return;
|
|
125
|
+
const varin = kp(gf(args, 'var'));
|
|
126
|
+
args.compiler += `anyvar_${varin} = ${args.thing.input};\n`;
|
|
127
|
+
return args.compiler;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
util.extensions.register(new vartypeany());
|
|
131
|
+
})(this.isCompiler ? this : Scratch);
|
package/package.json
CHANGED
|
@@ -1,6 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rcompiler",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "2.2.0",
|
|
4
|
+
"description": "Scratch/TurboWarp (and rCodenow) .sb3 to Rust compiler",
|
|
5
|
+
"main": "src/rcompiler.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"rcompiler": "src/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"src",
|
|
11
|
+
"exts",
|
|
12
|
+
"assets",
|
|
13
|
+
"docs",
|
|
14
|
+
"CHANGELOG.md",
|
|
15
|
+
"SECURITY.md",
|
|
16
|
+
"CONTRIBUTING.md"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"start": "node src/cli.js",
|
|
20
|
+
"test": "node test/run.js"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"scratch",
|
|
24
|
+
"turbowarp",
|
|
25
|
+
"rcodenow",
|
|
26
|
+
"sb3",
|
|
27
|
+
"rust",
|
|
28
|
+
"compiler",
|
|
29
|
+
"transpiler"
|
|
30
|
+
],
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "git+https://git.0832.ink/LingbaSanar/rCompiler.git"
|
|
34
|
+
},
|
|
35
|
+
"homepage": "https://git.0832.ink/LingbaSanar/rCompiler",
|
|
36
|
+
"bugs": {
|
|
37
|
+
"url": "https://git.0832.ink/LingbaSanar/rCompiler/issues"
|
|
38
|
+
},
|
|
39
|
+
"author": "LingbaSanar",
|
|
40
|
+
"license": "ISC",
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=18"
|
|
43
|
+
},
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"jszip": "^3.10.1",
|
|
49
|
+
"yargs": "^17.7.2",
|
|
50
|
+
"@resvg/resvg-js": "^2.6.0"
|
|
51
|
+
}
|
|
52
|
+
}
|