redscript-mc 1.2.25 → 1.2.27
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/README.md +67 -9
- package/README.zh.md +61 -4
- package/dist/__tests__/cli.test.js +1 -1
- package/dist/__tests__/codegen.test.js +12 -6
- package/dist/__tests__/e2e.test.js +6 -6
- package/dist/__tests__/lowering.test.js +8 -8
- package/dist/__tests__/optimizer.test.js +31 -0
- package/dist/__tests__/stdlib-advanced.test.d.ts +4 -0
- package/dist/__tests__/stdlib-advanced.test.js +378 -0
- package/dist/__tests__/stdlib-bigint.test.d.ts +7 -0
- package/dist/__tests__/stdlib-bigint.test.js +428 -0
- package/dist/__tests__/stdlib-math.test.d.ts +7 -0
- package/dist/__tests__/stdlib-math.test.js +352 -0
- package/dist/__tests__/stdlib-vec.test.d.ts +4 -0
- package/dist/__tests__/stdlib-vec.test.js +264 -0
- package/dist/ast/types.d.ts +17 -1
- package/dist/codegen/mcfunction/index.js +154 -18
- package/dist/codegen/var-allocator.d.ts +17 -0
- package/dist/codegen/var-allocator.js +26 -0
- package/dist/compile.d.ts +14 -0
- package/dist/compile.js +62 -5
- package/dist/data/arena/function/__load.mcfunction +6 -0
- package/dist/data/arena/function/__tick.mcfunction +2 -0
- package/dist/data/arena/function/announce_leaders/else_1.mcfunction +3 -0
- package/dist/data/arena/function/announce_leaders/foreach_0/merge_2.mcfunction +1 -0
- package/dist/data/arena/function/announce_leaders/foreach_0/then_0.mcfunction +3 -0
- package/dist/data/arena/function/announce_leaders/foreach_0.mcfunction +7 -0
- package/dist/data/arena/function/announce_leaders/foreach_1/merge_2.mcfunction +1 -0
- package/dist/data/arena/function/announce_leaders/foreach_1/then_0.mcfunction +4 -0
- package/dist/data/arena/function/announce_leaders/foreach_1.mcfunction +6 -0
- package/dist/data/arena/function/announce_leaders/merge_2.mcfunction +1 -0
- package/dist/data/arena/function/announce_leaders/then_0.mcfunction +4 -0
- package/dist/data/arena/function/announce_leaders.mcfunction +6 -0
- package/dist/data/arena/function/arena_tick/merge_2.mcfunction +1 -0
- package/dist/data/arena/function/arena_tick/then_0.mcfunction +4 -0
- package/dist/data/arena/function/arena_tick.mcfunction +11 -0
- package/dist/data/counter/function/__load.mcfunction +5 -0
- package/dist/data/counter/function/__tick.mcfunction +2 -0
- package/dist/data/counter/function/counter_tick/merge_2.mcfunction +1 -0
- package/dist/data/counter/function/counter_tick/then_0.mcfunction +3 -0
- package/dist/data/counter/function/counter_tick.mcfunction +11 -0
- package/dist/data/gcd2/function/__load.mcfunction +3 -0
- package/dist/data/gcd2/function/abs/merge_2.mcfunction +3 -0
- package/dist/data/gcd2/function/abs/then_0.mcfunction +5 -0
- package/dist/data/gcd2/function/abs.mcfunction +7 -0
- package/dist/data/gcd2/function/gcd/loop_body_1.mcfunction +7 -0
- package/dist/data/gcd2/function/gcd/loop_check_0.mcfunction +5 -0
- package/dist/data/gcd2/function/gcd/loop_exit_2.mcfunction +3 -0
- package/dist/data/gcd2/function/gcd.mcfunction +14 -0
- package/dist/data/gcd3/function/__load.mcfunction +3 -0
- package/dist/data/gcd3/function/abs/merge_2.mcfunction +3 -0
- package/dist/data/gcd3/function/abs/then_0.mcfunction +5 -0
- package/dist/data/gcd3/function/abs.mcfunction +7 -0
- package/dist/data/gcd3/function/gcd/loop_body_1.mcfunction +7 -0
- package/dist/data/gcd3/function/gcd/loop_check_0.mcfunction +5 -0
- package/dist/data/gcd3/function/gcd/loop_exit_2.mcfunction +3 -0
- package/dist/data/gcd3/function/gcd.mcfunction +14 -0
- package/dist/data/gcd3/function/test.mcfunction +7 -0
- package/dist/data/gcd3nm/function/__load.mcfunction +3 -0
- package/dist/data/gcd3nm/function/abs/merge_2.mcfunction +3 -0
- package/dist/data/gcd3nm/function/abs/then_0.mcfunction +5 -0
- package/dist/data/gcd3nm/function/abs.mcfunction +7 -0
- package/dist/data/gcd3nm/function/gcd/loop_body_1.mcfunction +7 -0
- package/dist/data/gcd3nm/function/gcd/loop_check_0.mcfunction +5 -0
- package/dist/data/gcd3nm/function/gcd/loop_exit_2.mcfunction +3 -0
- package/dist/data/gcd3nm/function/gcd.mcfunction +14 -0
- package/dist/data/gcd3nm/function/test.mcfunction +7 -0
- package/dist/data/gcd_test/function/__load.mcfunction +3 -0
- package/dist/data/gcd_test/function/abs/merge_2.mcfunction +3 -0
- package/dist/data/gcd_test/function/abs/then_0.mcfunction +5 -0
- package/dist/data/gcd_test/function/abs.mcfunction +7 -0
- package/dist/data/gcd_test/function/gcd/loop_body_1.mcfunction +7 -0
- package/dist/data/gcd_test/function/gcd/loop_check_0.mcfunction +5 -0
- package/dist/data/gcd_test/function/gcd/loop_exit_2.mcfunction +3 -0
- package/dist/data/gcd_test/function/gcd.mcfunction +14 -0
- package/dist/data/isqrttest/function/__load.mcfunction +6 -0
- package/dist/data/isqrttest/function/isqrt/loop_body_4.mcfunction +12 -0
- package/dist/data/isqrttest/function/isqrt/loop_check_3.mcfunction +5 -0
- package/dist/data/isqrttest/function/isqrt/loop_exit_5.mcfunction +3 -0
- package/dist/data/isqrttest/function/isqrt/merge_2.mcfunction +4 -0
- package/dist/data/isqrttest/function/isqrt/merge_8.mcfunction +6 -0
- package/dist/data/isqrttest/function/isqrt/then_0.mcfunction +3 -0
- package/dist/data/isqrttest/function/isqrt/then_6.mcfunction +3 -0
- package/dist/data/isqrttest/function/isqrt.mcfunction +7 -0
- package/dist/data/isqrttest/function/test.mcfunction +6 -0
- package/dist/data/mathtest/function/__load.mcfunction +3 -0
- package/dist/data/mathtest/function/abs/merge_2.mcfunction +3 -0
- package/dist/data/mathtest/function/abs/then_0.mcfunction +5 -0
- package/dist/data/mathtest/function/abs.mcfunction +6 -0
- package/dist/data/mathtest/function/test.mcfunction +5 -0
- package/dist/data/minecraft/tags/function/load.json +5 -0
- package/dist/data/minecraft/tags/function/tick.json +5 -0
- package/dist/data/mypack/function/__load.mcfunction +13 -0
- package/dist/data/mypack/function/_atan_init.mcfunction +2 -0
- package/dist/data/mypack/function/abs/merge_2.mcfunction +3 -0
- package/dist/data/mypack/function/abs/then_0.mcfunction +5 -0
- package/dist/data/mypack/function/abs.mcfunction +6 -0
- package/dist/data/mypack/function/atan2_fixed/__sgi_1.mcfunction +2 -0
- package/dist/data/mypack/function/atan2_fixed/else_34.mcfunction +3 -0
- package/dist/data/mypack/function/atan2_fixed/loop_body_31.mcfunction +19 -0
- package/dist/data/mypack/function/atan2_fixed/loop_check_30.mcfunction +5 -0
- package/dist/data/mypack/function/atan2_fixed/loop_exit_32.mcfunction +6 -0
- package/dist/data/mypack/function/atan2_fixed/merge_11.mcfunction +6 -0
- package/dist/data/mypack/function/atan2_fixed/merge_14.mcfunction +3 -0
- package/dist/data/mypack/function/atan2_fixed/merge_17.mcfunction +6 -0
- package/dist/data/mypack/function/atan2_fixed/merge_2.mcfunction +5 -0
- package/dist/data/mypack/function/atan2_fixed/merge_20.mcfunction +5 -0
- package/dist/data/mypack/function/atan2_fixed/merge_23.mcfunction +5 -0
- package/dist/data/mypack/function/atan2_fixed/merge_26.mcfunction +6 -0
- package/dist/data/mypack/function/atan2_fixed/merge_29.mcfunction +4 -0
- package/dist/data/mypack/function/atan2_fixed/merge_38.mcfunction +5 -0
- package/dist/data/mypack/function/atan2_fixed/merge_41.mcfunction +5 -0
- package/dist/data/mypack/function/atan2_fixed/merge_44.mcfunction +5 -0
- package/dist/data/mypack/function/atan2_fixed/merge_47.mcfunction +5 -0
- package/dist/data/mypack/function/atan2_fixed/merge_5.mcfunction +5 -0
- package/dist/data/mypack/function/atan2_fixed/merge_8.mcfunction +3 -0
- package/dist/data/mypack/function/atan2_fixed/then_0.mcfunction +5 -0
- package/dist/data/mypack/function/atan2_fixed/then_12.mcfunction +3 -0
- package/dist/data/mypack/function/atan2_fixed/then_15.mcfunction +5 -0
- package/dist/data/mypack/function/atan2_fixed/then_18.mcfunction +5 -0
- package/dist/data/mypack/function/atan2_fixed/then_21.mcfunction +3 -0
- package/dist/data/mypack/function/atan2_fixed/then_24.mcfunction +3 -0
- package/dist/data/mypack/function/atan2_fixed/then_27.mcfunction +6 -0
- package/dist/data/mypack/function/atan2_fixed/then_3.mcfunction +3 -0
- package/dist/data/mypack/function/atan2_fixed/then_33.mcfunction +5 -0
- package/dist/data/mypack/function/atan2_fixed/then_36.mcfunction +5 -0
- package/dist/data/mypack/function/atan2_fixed/then_39.mcfunction +5 -0
- package/dist/data/mypack/function/atan2_fixed/then_42.mcfunction +3 -0
- package/dist/data/mypack/function/atan2_fixed/then_45.mcfunction +5 -0
- package/dist/data/mypack/function/atan2_fixed/then_6.mcfunction +3 -0
- package/dist/data/mypack/function/atan2_fixed/then_9.mcfunction +5 -0
- package/dist/data/mypack/function/atan2_fixed.mcfunction +7 -0
- package/dist/data/mypack/function/my_game.mcfunction +10 -0
- package/dist/data/quiz/function/__load.mcfunction +16 -0
- package/dist/data/quiz/function/__tick.mcfunction +6 -0
- package/dist/data/quiz/function/__trigger_quiz_a_dispatch.mcfunction +4 -0
- package/dist/data/quiz/function/__trigger_quiz_b_dispatch.mcfunction +4 -0
- package/dist/data/quiz/function/__trigger_quiz_c_dispatch.mcfunction +4 -0
- package/dist/data/quiz/function/__trigger_quiz_start_dispatch.mcfunction +4 -0
- package/dist/data/quiz/function/answer_a.mcfunction +4 -0
- package/dist/data/quiz/function/answer_b.mcfunction +4 -0
- package/dist/data/quiz/function/answer_c.mcfunction +4 -0
- package/dist/data/quiz/function/ask_question/else_1.mcfunction +5 -0
- package/dist/data/quiz/function/ask_question/else_4.mcfunction +5 -0
- package/dist/data/quiz/function/ask_question/else_7.mcfunction +4 -0
- package/dist/data/quiz/function/ask_question/merge_2.mcfunction +1 -0
- package/dist/data/quiz/function/ask_question/merge_5.mcfunction +2 -0
- package/dist/data/quiz/function/ask_question/merge_8.mcfunction +2 -0
- package/dist/data/quiz/function/ask_question/then_0.mcfunction +4 -0
- package/dist/data/quiz/function/ask_question/then_3.mcfunction +4 -0
- package/dist/data/quiz/function/ask_question/then_6.mcfunction +4 -0
- package/dist/data/quiz/function/ask_question.mcfunction +7 -0
- package/dist/data/quiz/function/finish_quiz.mcfunction +6 -0
- package/dist/data/quiz/function/handle_answer/else_1.mcfunction +5 -0
- package/dist/data/quiz/function/handle_answer/else_10.mcfunction +3 -0
- package/dist/data/quiz/function/handle_answer/else_16.mcfunction +3 -0
- package/dist/data/quiz/function/handle_answer/else_4.mcfunction +3 -0
- package/dist/data/quiz/function/handle_answer/else_7.mcfunction +5 -0
- package/dist/data/quiz/function/handle_answer/merge_11.mcfunction +2 -0
- package/dist/data/quiz/function/handle_answer/merge_14.mcfunction +2 -0
- package/dist/data/quiz/function/handle_answer/merge_17.mcfunction +2 -0
- package/dist/data/quiz/function/handle_answer/merge_2.mcfunction +8 -0
- package/dist/data/quiz/function/handle_answer/merge_5.mcfunction +2 -0
- package/dist/data/quiz/function/handle_answer/merge_8.mcfunction +2 -0
- package/dist/data/quiz/function/handle_answer/then_0.mcfunction +5 -0
- package/dist/data/quiz/function/handle_answer/then_12.mcfunction +5 -0
- package/dist/data/quiz/function/handle_answer/then_15.mcfunction +6 -0
- package/dist/data/quiz/function/handle_answer/then_3.mcfunction +6 -0
- package/dist/data/quiz/function/handle_answer/then_6.mcfunction +5 -0
- package/dist/data/quiz/function/handle_answer/then_9.mcfunction +6 -0
- package/dist/data/quiz/function/handle_answer.mcfunction +11 -0
- package/dist/data/quiz/function/start_quiz.mcfunction +5 -0
- package/dist/data/reqtest/function/__load.mcfunction +4 -0
- package/dist/data/reqtest/function/_table_init.mcfunction +2 -0
- package/dist/data/reqtest/function/no_trig.mcfunction +3 -0
- package/dist/data/reqtest/function/use_table.mcfunction +4 -0
- package/dist/data/reqtest2/function/__load.mcfunction +3 -0
- package/dist/data/reqtest2/function/no_trig.mcfunction +3 -0
- package/dist/data/runtime/function/__load.mcfunction +5 -0
- package/dist/data/runtime/function/__tick.mcfunction +2 -0
- package/dist/data/runtime/function/counter_tick/then_0.mcfunction +3 -0
- package/dist/data/runtime/function/counter_tick.mcfunction +13 -0
- package/dist/data/shop/function/__load.mcfunction +7 -0
- package/dist/data/shop/function/__tick.mcfunction +3 -0
- package/dist/data/shop/function/__trigger_shop_buy_dispatch.mcfunction +4 -0
- package/dist/data/shop/function/complete_purchase/else_1.mcfunction +5 -0
- package/dist/data/shop/function/complete_purchase/else_4.mcfunction +5 -0
- package/dist/data/shop/function/complete_purchase/else_7.mcfunction +3 -0
- package/dist/data/shop/function/complete_purchase/merge_2.mcfunction +2 -0
- package/dist/data/shop/function/complete_purchase/merge_5.mcfunction +2 -0
- package/dist/data/shop/function/complete_purchase/merge_8.mcfunction +2 -0
- package/dist/data/shop/function/complete_purchase/then_0.mcfunction +4 -0
- package/dist/data/shop/function/complete_purchase/then_3.mcfunction +4 -0
- package/dist/data/shop/function/complete_purchase/then_6.mcfunction +4 -0
- package/dist/data/shop/function/complete_purchase.mcfunction +7 -0
- package/dist/data/shop/function/handle_shop_trigger.mcfunction +3 -0
- package/dist/data/swap_test/function/__load.mcfunction +3 -0
- package/dist/data/swap_test/function/gcd_old/loop_body_1.mcfunction +7 -0
- package/dist/data/swap_test/function/gcd_old/loop_check_0.mcfunction +5 -0
- package/dist/data/swap_test/function/gcd_old/loop_exit_2.mcfunction +3 -0
- package/dist/data/swap_test/function/gcd_old.mcfunction +8 -0
- package/dist/data/turret/function/__load.mcfunction +5 -0
- package/dist/data/turret/function/__tick.mcfunction +4 -0
- package/dist/data/turret/function/__trigger_deploy_turret_dispatch.mcfunction +4 -0
- package/dist/data/turret/function/deploy_turret.mcfunction +8 -0
- package/dist/data/turret/function/turret_tick/at_1.mcfunction +2 -0
- package/dist/data/turret/function/turret_tick/foreach_0.mcfunction +2 -0
- package/dist/data/turret/function/turret_tick/foreach_2.mcfunction +2 -0
- package/dist/data/turret/function/turret_tick/tick_body.mcfunction +3 -0
- package/dist/data/turret/function/turret_tick/tick_skip.mcfunction +1 -0
- package/dist/data/turret/function/turret_tick.mcfunction +5 -0
- package/dist/gcd2.map.json +15 -0
- package/dist/gcd3.map.json +17 -0
- package/dist/gcd_test.map.json +15 -0
- package/dist/index.js +20 -1
- package/dist/ir/types.d.ts +4 -0
- package/dist/isqrttest.map.json +15 -0
- package/dist/lexer/index.d.ts +1 -1
- package/dist/lexer/index.js +1 -0
- package/dist/lowering/index.d.ts +5 -0
- package/dist/lowering/index.js +154 -14
- package/dist/mathtest.map.json +6 -0
- package/dist/mypack.map.json +27 -0
- package/dist/optimizer/dce.js +21 -5
- package/dist/optimizer/passes.js +18 -6
- package/dist/optimizer/structure.js +7 -0
- package/dist/pack.mcmeta +6 -0
- package/dist/parser/index.d.ts +5 -0
- package/dist/parser/index.js +43 -2
- package/dist/reqtest.map.json +4 -0
- package/dist/reqtest2.map.json +4 -0
- package/dist/runtime/index.d.ts +6 -0
- package/dist/runtime/index.js +130 -9
- package/dist/runtime.map.json +7 -0
- package/dist/swap_test.map.json +14 -0
- package/editors/vscode/package-lock.json +3 -3
- package/editors/vscode/package.json +1 -1
- package/examples/showcase.mcrs +505 -0
- package/package.json +1 -1
- package/src/__tests__/cli.test.ts +1 -1
- package/src/__tests__/codegen.test.ts +12 -6
- package/src/__tests__/e2e.test.ts +6 -6
- package/src/__tests__/lowering.test.ts +8 -8
- package/src/__tests__/optimizer.test.ts +33 -0
- package/src/__tests__/stdlib-advanced.test.ts +379 -0
- package/src/__tests__/stdlib-bigint.test.ts +427 -0
- package/src/__tests__/stdlib-math.test.ts +374 -0
- package/src/__tests__/stdlib-vec.test.ts +259 -0
- package/src/ast/types.ts +11 -1
- package/src/codegen/mcfunction/index.ts +143 -19
- package/src/codegen/var-allocator.ts +29 -0
- package/src/compile.ts +72 -5
- package/src/index.ts +21 -1
- package/src/ir/types.ts +2 -0
- package/src/lexer/index.ts +2 -1
- package/src/lowering/index.ts +171 -14
- package/src/optimizer/dce.ts +22 -5
- package/src/optimizer/passes.ts +18 -5
- package/src/optimizer/structure.ts +6 -1
- package/src/parser/index.ts +47 -2
- package/src/runtime/index.ts +130 -10
- package/src/stdlib/advanced.mcrs +330 -0
- package/src/stdlib/bigint.mcrs +205 -0
- package/src/stdlib/math.mcrs +274 -21
- package/src/stdlib/vec.mcrs +246 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# RedScript runtime init
|
|
2
|
+
scoreboard objectives add rs dummy
|
|
3
|
+
scoreboard objectives add quiz_start trigger
|
|
4
|
+
scoreboard players enable @a quiz_start
|
|
5
|
+
scoreboard objectives add quiz_a trigger
|
|
6
|
+
scoreboard players enable @a quiz_a
|
|
7
|
+
scoreboard objectives add quiz_b trigger
|
|
8
|
+
scoreboard players enable @a quiz_b
|
|
9
|
+
scoreboard objectives add quiz_c trigger
|
|
10
|
+
scoreboard players enable @a quiz_c
|
|
11
|
+
scoreboard players set $const_1 rs 1
|
|
12
|
+
scoreboard players set $const_2 rs 2
|
|
13
|
+
scoreboard players set $const_3 rs 3
|
|
14
|
+
scoreboard players set $const_1 rs 1
|
|
15
|
+
scoreboard players set $const_2 rs 2
|
|
16
|
+
scoreboard players set $const_3 rs 3
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# RedScript tick dispatcher
|
|
2
|
+
# Trigger checks
|
|
3
|
+
execute as @a[scores={quiz_start=1..}] run function quiz:__trigger_quiz_start_dispatch
|
|
4
|
+
execute as @a[scores={quiz_a=1..}] run function quiz:__trigger_quiz_a_dispatch
|
|
5
|
+
execute as @a[scores={quiz_b=1..}] run function quiz:__trigger_quiz_b_dispatch
|
|
6
|
+
execute as @a[scores={quiz_c=1..}] run function quiz:__trigger_quiz_c_dispatch
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# block: else_1
|
|
2
|
+
scoreboard players set $t2 rs 0
|
|
3
|
+
execute if score $question rs = $const_2 rs run scoreboard players set $t2 rs 1
|
|
4
|
+
execute if score $t2 rs matches 1.. run function quiz:ask_question/then_3
|
|
5
|
+
execute if score $t2 rs matches ..0 run function quiz:ask_question/else_4
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# block: else_4
|
|
2
|
+
scoreboard players set $t3 rs 0
|
|
3
|
+
execute if score $question rs = $const_3 rs run scoreboard players set $t3 rs 1
|
|
4
|
+
execute if score $t3 rs matches 1.. run function quiz:ask_question/then_6
|
|
5
|
+
execute if score $t3 rs matches ..0 run function quiz:ask_question/else_7
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# block: merge_2
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# block: entry
|
|
2
|
+
execute store result score $t0 rs run scoreboard players get @s quiz_question
|
|
3
|
+
scoreboard players operation $question rs = $t0 rs
|
|
4
|
+
scoreboard players set $t1 rs 0
|
|
5
|
+
execute if score $t0 rs = $const_1 rs run scoreboard players set $t1 rs 1
|
|
6
|
+
execute if score $t1 rs matches 1.. run function quiz:ask_question/then_0
|
|
7
|
+
execute if score $t1 rs matches ..0 run function quiz:ask_question/else_1
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# block: entry
|
|
2
|
+
execute store result score $t0 rs run scoreboard players get @s quiz_score
|
|
3
|
+
title @s title {"text":"Quiz Complete"}
|
|
4
|
+
tellraw @s {"text":"Your final quiz score is recorded in quiz_score."}
|
|
5
|
+
scoreboard players set @s quiz_question 0
|
|
6
|
+
execute store result score @s quiz_score run scoreboard players get $t1 rs
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# block: else_1
|
|
2
|
+
scoreboard players set $t5 rs 0
|
|
3
|
+
execute if score $question rs = $const_2 rs run scoreboard players set $t5 rs 1
|
|
4
|
+
execute if score $t5 rs matches 1.. run function quiz:handle_answer/then_6
|
|
5
|
+
execute if score $t5 rs matches ..0 run function quiz:handle_answer/else_7
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# block: else_7
|
|
2
|
+
scoreboard players set $t8 rs 0
|
|
3
|
+
execute if score $question rs = $const_3 rs run scoreboard players set $t8 rs 1
|
|
4
|
+
execute if score $t8 rs matches 1.. run function quiz:handle_answer/then_12
|
|
5
|
+
execute if score $t8 rs matches ..0 run function quiz:handle_answer/merge_14
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# block: merge_2
|
|
2
|
+
execute store result score @s quiz_score run scoreboard players get $t11 rs
|
|
3
|
+
scoreboard players operation $t12 rs = $question rs
|
|
4
|
+
scoreboard players operation $t12 rs += $const_1 rs
|
|
5
|
+
scoreboard players operation $question rs = $t12 rs
|
|
6
|
+
execute store result score @s quiz_question run scoreboard players get $t13 rs
|
|
7
|
+
function quiz:ask_question
|
|
8
|
+
scoreboard players operation $t14 rs = $ret rs
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# block: then_0
|
|
2
|
+
scoreboard players set $t3 rs 0
|
|
3
|
+
execute if score $choice rs = $const_1 rs run scoreboard players set $t3 rs 1
|
|
4
|
+
execute if score $t3 rs matches 1.. run function quiz:handle_answer/then_3
|
|
5
|
+
execute if score $t3 rs matches ..0 run function quiz:handle_answer/else_4
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# block: then_12
|
|
2
|
+
scoreboard players set $t9 rs 0
|
|
3
|
+
execute if score $choice rs = $const_2 rs run scoreboard players set $t9 rs 1
|
|
4
|
+
execute if score $t9 rs matches 1.. run function quiz:handle_answer/then_15
|
|
5
|
+
execute if score $t9 rs matches ..0 run function quiz:handle_answer/else_16
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# block: then_6
|
|
2
|
+
scoreboard players set $t6 rs 0
|
|
3
|
+
execute if score $choice rs = $const_2 rs run scoreboard players set $t6 rs 1
|
|
4
|
+
execute if score $t6 rs matches 1.. run function quiz:handle_answer/then_9
|
|
5
|
+
execute if score $t6 rs matches ..0 run function quiz:handle_answer/else_10
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# block: entry
|
|
2
|
+
scoreboard players operation $choice rs = $p0 rs
|
|
3
|
+
scoreboard players operation $choice rs = $p0 rs
|
|
4
|
+
execute store result score $t0 rs run scoreboard players get @s quiz_question
|
|
5
|
+
scoreboard players operation $question rs = $t0 rs
|
|
6
|
+
execute store result score $t1 rs run scoreboard players get @s quiz_score
|
|
7
|
+
scoreboard players operation $score rs = $t1 rs
|
|
8
|
+
scoreboard players set $t2 rs 0
|
|
9
|
+
execute if score $t0 rs = $const_1 rs run scoreboard players set $t2 rs 1
|
|
10
|
+
execute if score $t2 rs matches 1.. run function quiz:handle_answer/then_0
|
|
11
|
+
execute if score $t2 rs matches ..0 run function quiz:handle_answer/else_1
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# block: entry
|
|
2
|
+
execute store result score $_0 rs run scoreboard players get counter ticks
|
|
3
|
+
scoreboard players operation $d rs = $e rs
|
|
4
|
+
scoreboard players operation $f rs = $e rs
|
|
5
|
+
scoreboard players operation $f rs += $b rs
|
|
6
|
+
scoreboard players operation $d rs = $f rs
|
|
7
|
+
execute store result score counter ticks run scoreboard players get $d rs
|
|
8
|
+
scoreboard players operation $g rs = $f rs
|
|
9
|
+
scoreboard players operation $g rs %= $c rs
|
|
10
|
+
scoreboard players set $h rs 0
|
|
11
|
+
execute if score $g rs = $a rs run scoreboard players set $h rs 1
|
|
12
|
+
execute if score $h rs matches 1.. run function runtime:counter_tick/then_0
|
|
13
|
+
execute if score $h rs matches ..0 run function runtime:counter_tick/merge_2
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# block: else_1
|
|
2
|
+
scoreboard players set $t2 rs 0
|
|
3
|
+
execute if score $choice rs = $const_2 rs run scoreboard players set $t2 rs 1
|
|
4
|
+
execute if score $t2 rs matches 1.. run function shop:complete_purchase/then_3
|
|
5
|
+
execute if score $t2 rs matches ..0 run function shop:complete_purchase/else_4
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# block: else_4
|
|
2
|
+
scoreboard players set $t3 rs 0
|
|
3
|
+
execute if score $choice rs = $const_3 rs run scoreboard players set $t3 rs 1
|
|
4
|
+
execute if score $t3 rs matches 1.. run function shop:complete_purchase/then_6
|
|
5
|
+
execute if score $t3 rs matches ..0 run function shop:complete_purchase/else_7
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# block: entry
|
|
2
|
+
execute store result score $t0 rs run scoreboard players get @s shop_choice
|
|
3
|
+
scoreboard players operation $choice rs = $t0 rs
|
|
4
|
+
scoreboard players set $t1 rs 0
|
|
5
|
+
execute if score $t0 rs = $const_1 rs run scoreboard players set $t1 rs 1
|
|
6
|
+
execute if score $t1 rs matches 1.. run function shop:complete_purchase/then_0
|
|
7
|
+
execute if score $t1 rs matches ..0 run function shop:complete_purchase/else_1
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# block: loop_body_1
|
|
2
|
+
scoreboard players operation $k rs = $i rs
|
|
3
|
+
scoreboard players operation $l rs = $h rs
|
|
4
|
+
scoreboard players operation $l rs %= $i rs
|
|
5
|
+
scoreboard players operation $i rs = $l rs
|
|
6
|
+
scoreboard players operation $h rs = $k rs
|
|
7
|
+
function swap_test:gcd_old/loop_check_0
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# block: loop_check_0
|
|
2
|
+
scoreboard players set $j rs 0
|
|
3
|
+
execute if score $i rs > $a rs run scoreboard players set $j rs 1
|
|
4
|
+
execute if score $j rs matches 1.. run function swap_test:gcd_old/loop_body_1
|
|
5
|
+
execute if score $j rs matches ..0 run function swap_test:gcd_old/loop_exit_2
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# block: entry
|
|
2
|
+
scoreboard players operation $b rs = $c rs
|
|
3
|
+
scoreboard players operation $d rs = $e rs
|
|
4
|
+
scoreboard players operation $b rs = $f rs
|
|
5
|
+
scoreboard players operation $d rs = $g rs
|
|
6
|
+
scoreboard players operation $h rs = $f rs
|
|
7
|
+
scoreboard players operation $i rs = $g rs
|
|
8
|
+
function swap_test:gcd_old/loop_check_0
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# block: entry
|
|
2
|
+
summon minecraft:armor_stand 0 64 0 {Invisible:1b,Marker:1b,NoGravity:1b,Tags:["__rs_obj_0"]}
|
|
3
|
+
scoreboard players set @e[tag=__rs_obj_0,limit=1] rs 40
|
|
4
|
+
tag @e[tag=__rs_obj_0,limit=1] add turret
|
|
5
|
+
data modify storage rs:heap turretstate_state.health set value 40
|
|
6
|
+
execute store result score $t0 rs run data get storage rs:heap turretstate_state.health
|
|
7
|
+
execute store result score turret health run scoreboard players get $t1 rs
|
|
8
|
+
say Turret deployed.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# block: tick_skip
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# block: entry
|
|
2
|
+
scoreboard players add $__tick_turret_tick rs 1
|
|
3
|
+
execute store success score $__tick_turret_tick_check rs if score $__tick_turret_tick rs matches 20..
|
|
4
|
+
execute if score $__tick_turret_tick_check rs matches 1.. run function turret:turret_tick/tick_body
|
|
5
|
+
execute if score $__tick_turret_tick_check rs matches ..0 run function turret:turret_tick/tick_skip
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$b": "x",
|
|
3
|
+
"$d": "p0",
|
|
4
|
+
"$h": "g",
|
|
5
|
+
"$i": "a",
|
|
6
|
+
"$j": "b",
|
|
7
|
+
"$l": "p1",
|
|
8
|
+
"$m": "c",
|
|
9
|
+
"$p": "y",
|
|
10
|
+
"$s": "r",
|
|
11
|
+
"$t": "k",
|
|
12
|
+
"$v": "result",
|
|
13
|
+
"$a": "const:0",
|
|
14
|
+
"$c": "internal:p0",
|
|
15
|
+
"$g": "internal:ret",
|
|
16
|
+
"$k": "internal:p1"
|
|
17
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -37,8 +37,27 @@ function compile(source, options = {}) {
|
|
|
37
37
|
const preprocessedSource = preprocessed.source;
|
|
38
38
|
// Lexing
|
|
39
39
|
const tokens = new lexer_1.Lexer(preprocessedSource, filePath).tokenize();
|
|
40
|
-
// Parsing
|
|
40
|
+
// Parsing — user source
|
|
41
41
|
const parsedAst = new parser_1.Parser(tokens, preprocessedSource, filePath).parse(namespace);
|
|
42
|
+
// Library imports: files that declared `module library;` are parsed independently
|
|
43
|
+
// (fresh Parser per file) so their functions are DCE-eligible but never bleed into user code.
|
|
44
|
+
const allLibrarySources = [];
|
|
45
|
+
for (const li of preprocessed.libraryImports ?? []) {
|
|
46
|
+
allLibrarySources.push({ src: li.source, fp: li.filePath });
|
|
47
|
+
}
|
|
48
|
+
for (const { src, fp } of allLibrarySources) {
|
|
49
|
+
const libPreprocessed = (0, compile_1.preprocessSourceWithMetadata)(src, fp ? { filePath: fp } : {});
|
|
50
|
+
const libTokens = new lexer_1.Lexer(libPreprocessed.source, fp).tokenize();
|
|
51
|
+
const libAst = new parser_1.Parser(libTokens, libPreprocessed.source, fp).parse(namespace);
|
|
52
|
+
for (const fn of libAst.declarations)
|
|
53
|
+
fn.isLibraryFn = true;
|
|
54
|
+
parsedAst.declarations.push(...libAst.declarations);
|
|
55
|
+
parsedAst.structs.push(...libAst.structs);
|
|
56
|
+
parsedAst.implBlocks.push(...libAst.implBlocks);
|
|
57
|
+
parsedAst.enums.push(...libAst.enums);
|
|
58
|
+
parsedAst.consts.push(...libAst.consts);
|
|
59
|
+
parsedAst.globals.push(...libAst.globals);
|
|
60
|
+
}
|
|
42
61
|
const dceResult = shouldRunDce ? (0, dce_1.eliminateDeadCode)(parsedAst, preprocessed.ranges) : { program: parsedAst, warnings: [] };
|
|
43
62
|
const ast = dceResult.program;
|
|
44
63
|
// Type checking (warn mode - collect errors but don't block)
|
package/dist/ir/types.d.ts
CHANGED
|
@@ -19,6 +19,9 @@ export type Operand = {
|
|
|
19
19
|
} | {
|
|
20
20
|
kind: 'storage';
|
|
21
21
|
path: string;
|
|
22
|
+
} | {
|
|
23
|
+
kind: 'param';
|
|
24
|
+
index: number;
|
|
22
25
|
};
|
|
23
26
|
export type BinOp = '+' | '-' | '*' | '/' | '%';
|
|
24
27
|
export type CmpOp = '==' | '!=' | '<' | '<=' | '>' | '>=';
|
|
@@ -104,6 +107,7 @@ export interface IRFunction {
|
|
|
104
107
|
commands?: IRCommand[];
|
|
105
108
|
isTickLoop?: boolean;
|
|
106
109
|
isLoadInit?: boolean;
|
|
110
|
+
requiredLoads?: string[];
|
|
107
111
|
isTriggerHandler?: boolean;
|
|
108
112
|
triggerName?: string;
|
|
109
113
|
eventTrigger?: {
|