@devaloop/devalang 0.0.1-alpha.16-hotfix.3 → 0.0.1-alpha.18
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/.cargo/config.toml +2 -0
- package/.devalang +10 -10
- package/.github/workflows/ci.yml +0 -1
- package/Cargo.toml +18 -2
- package/README.md +82 -34
- package/docs/CHANGELOG.md +91 -0
- package/docs/ROADMAP.md +7 -4
- package/docs/TODO.md +1 -1
- package/examples/index.deva +55 -35
- package/examples/pattern.deva +5 -5
- package/out-tsc/bin/index.d.ts +2 -0
- package/out-tsc/core/functions/index.d.ts +37 -0
- package/out-tsc/core/functions/index.js +76 -0
- package/out-tsc/core/index.d.ts +6 -0
- package/out-tsc/core/index.js +22 -0
- package/out-tsc/core/types/index.d.ts +4 -0
- package/out-tsc/core/types/index.js +20 -0
- package/out-tsc/core/types/plugin.d.ts +18 -0
- package/out-tsc/core/types/plugin.js +2 -0
- package/out-tsc/core/types/result.d.ts +27 -0
- package/out-tsc/core/types/result.js +2 -0
- package/out-tsc/core/types/statement.d.ts +106 -0
- package/out-tsc/core/types/statement.js +2 -0
- package/out-tsc/core/types/value.d.ts +43 -0
- package/out-tsc/core/types/value.js +2 -0
- package/out-tsc/index.d.ts +7 -0
- package/out-tsc/index.js +41 -2
- package/out-tsc/pkg/devalang_core.d.ts +7 -0
- package/out-tsc/pkg/devalang_core_bg.wasm.d.ts +33 -0
- package/out-tsc/scripts/copy-wasm-dts.d.ts +1 -0
- package/out-tsc/scripts/copy-wasm-dts.js +73 -0
- package/out-tsc/scripts/postinstall.d.ts +1 -0
- package/out-tsc/scripts/postinstall.js +33 -23
- package/out-tsc/scripts/version/bump.d.ts +1 -0
- package/out-tsc/scripts/version/fetch.d.ts +1 -0
- package/out-tsc/scripts/version/index.d.ts +1 -0
- package/out-tsc/scripts/version/sync.d.ts +1 -0
- package/package.json +16 -4
- package/project-version.json +3 -3
- package/rust/cli/bank/api.rs +122 -0
- package/rust/cli/bank/commands.rs +275 -0
- package/rust/cli/bank/mod.rs +29 -0
- package/rust/cli/build/commands.rs +107 -0
- package/rust/cli/build/mod.rs +2 -0
- package/rust/cli/build/process.rs +146 -0
- package/rust/cli/{check.rs → check/mod.rs} +18 -31
- package/rust/cli/discover/commands.rs +253 -0
- package/rust/cli/discover/config.rs +111 -0
- package/rust/cli/discover/fs.rs +19 -0
- package/rust/cli/discover/install.rs +103 -0
- package/rust/cli/discover/metadata.rs +48 -0
- package/rust/cli/discover/mod.rs +5 -0
- package/rust/cli/{init.rs → init/commands.rs} +88 -87
- package/rust/cli/init/mod.rs +1 -0
- package/rust/cli/install/addon.rs +126 -0
- package/rust/cli/install/bank.rs +53 -0
- package/rust/cli/{install.rs → install/commands.rs} +9 -9
- package/rust/{installer → cli/install}/mod.rs +2 -3
- package/rust/cli/install/plugin.rs +61 -0
- package/rust/cli/{login.rs → login/commands.rs} +8 -11
- package/rust/cli/login/mod.rs +1 -0
- package/rust/cli/mod.rs +2 -2
- package/rust/cli/{driver.rs → parser.rs} +7 -2
- package/rust/cli/play/commands.rs +324 -0
- package/rust/cli/play/io.rs +17 -0
- package/rust/cli/play/mod.rs +5 -0
- package/rust/cli/play/process.rs +150 -0
- package/rust/cli/play/realtime.rs +91 -0
- package/rust/cli/play/utils.rs +23 -0
- package/rust/cli/{telemetry.rs → telemetry/commands.rs} +4 -4
- package/rust/cli/telemetry/event_creator.rs +80 -0
- package/rust/cli/telemetry/mod.rs +3 -0
- package/rust/cli/telemetry/send.rs +51 -0
- package/rust/cli/{template.rs → template/commands.rs} +1 -1
- package/rust/cli/template/mod.rs +1 -0
- package/rust/cli/{update.rs → update/commands.rs} +6 -6
- package/rust/cli/update/mod.rs +1 -0
- package/rust/config/driver.rs +57 -72
- package/rust/config/mod.rs +1 -2
- package/rust/config/ops.rs +26 -0
- package/rust/config/settings.rs +40 -42
- package/rust/core/audio/engine/helpers.rs +158 -0
- package/rust/core/audio/engine/mod.rs +7 -0
- package/rust/core/audio/engine/sample.rs +359 -0
- package/rust/core/audio/engine/synth.rs +325 -0
- package/rust/core/audio/evaluator.rs +68 -27
- package/rust/core/audio/interpreter/arrow_call.rs +113 -33
- package/rust/core/audio/interpreter/call.rs +232 -56
- package/rust/core/audio/interpreter/condition.rs +3 -2
- package/rust/core/audio/interpreter/driver.rs +206 -151
- package/rust/core/audio/interpreter/let_.rs +1 -1
- package/rust/core/audio/interpreter/load.rs +2 -1
- package/rust/core/audio/interpreter/loop_.rs +7 -6
- package/rust/core/audio/interpreter/sleep.rs +2 -1
- package/rust/core/audio/interpreter/spawn.rs +186 -54
- package/rust/core/audio/interpreter/tempo.rs +31 -10
- package/rust/core/audio/interpreter/trigger.rs +2 -2
- package/rust/core/audio/loader/trigger.rs +4 -7
- package/rust/core/audio/player.rs +6 -0
- package/rust/core/audio/renderer.rs +5 -7
- package/rust/core/audio/special/env.rs +3 -1
- package/rust/core/audio/special/math.rs +26 -6
- package/rust/core/audio/special/modulator.rs +2 -2
- package/rust/core/builder/mod.rs +9 -3
- package/rust/core/debugger/lexer.rs +1 -1
- package/rust/core/debugger/mod.rs +6 -0
- package/rust/core/debugger/module.rs +4 -4
- package/rust/core/debugger/preprocessor.rs +1 -1
- package/rust/core/debugger/store.rs +2 -2
- package/rust/core/error/mod.rs +189 -0
- package/rust/core/lexer/driver.rs +61 -0
- package/rust/core/lexer/handler/arrow.rs +1 -1
- package/rust/core/lexer/handler/at.rs +1 -1
- package/rust/core/lexer/handler/brace.rs +2 -2
- package/rust/core/lexer/handler/colon.rs +1 -1
- package/rust/core/lexer/handler/comment.rs +1 -1
- package/rust/core/lexer/handler/dot.rs +1 -1
- package/rust/core/lexer/handler/driver.rs +1 -1
- package/rust/core/lexer/handler/identifier.rs +4 -3
- package/rust/core/lexer/handler/mod.rs +1 -2
- package/rust/core/lexer/handler/number.rs +1 -1
- package/rust/core/lexer/handler/operator.rs +1 -1
- package/rust/core/lexer/handler/parenthesis.rs +2 -2
- package/rust/core/lexer/handler/slash.rs +1 -1
- package/rust/core/lexer/handler/string.rs +1 -1
- package/rust/core/lexer/mod.rs +1 -52
- package/rust/core/lexer/token.rs +91 -97
- package/rust/core/mod.rs +0 -1
- package/rust/core/parser/driver.rs +78 -22
- package/rust/core/parser/handler/arrow_call.rs +28 -8
- package/rust/core/parser/handler/at.rs +55 -21
- package/rust/core/parser/handler/bank.rs +14 -4
- package/rust/core/parser/handler/condition.rs +6 -3
- package/rust/core/parser/handler/dot.rs +5 -3
- package/rust/core/parser/handler/identifier/automate.rs +13 -16
- package/rust/core/parser/handler/identifier/call.rs +4 -4
- package/rust/core/parser/handler/identifier/emit.rs +9 -5
- package/rust/core/parser/handler/identifier/function.rs +20 -7
- package/rust/core/parser/handler/identifier/group.rs +11 -7
- package/rust/core/parser/handler/identifier/let_.rs +24 -9
- package/rust/core/parser/handler/identifier/mod.rs +6 -5
- package/rust/core/parser/handler/identifier/on.rs +16 -7
- package/rust/core/parser/handler/identifier/print.rs +6 -9
- package/rust/core/parser/handler/identifier/sleep.rs +12 -5
- package/rust/core/parser/handler/identifier/spawn.rs +4 -4
- package/rust/core/parser/handler/identifier/synth.rs +79 -9
- package/rust/core/parser/handler/loop_.rs +38 -13
- package/rust/core/parser/handler/mod.rs +1 -0
- package/rust/core/parser/handler/pattern.rs +74 -0
- package/rust/core/parser/handler/tempo.rs +9 -5
- package/rust/core/parser/mod.rs +0 -1
- package/rust/core/parser/statement.rs +6 -137
- package/rust/core/plugin/loader.rs +41 -27
- package/rust/core/plugin/runner.rs +68 -17
- package/rust/core/preprocessor/loader.rs +181 -99
- package/rust/core/preprocessor/processor.rs +9 -9
- package/rust/core/preprocessor/resolver/bank.rs +6 -8
- package/rust/core/preprocessor/resolver/call.rs +47 -23
- package/rust/core/preprocessor/resolver/condition.rs +6 -8
- package/rust/core/preprocessor/resolver/driver.rs +28 -28
- package/rust/core/preprocessor/resolver/function.rs +6 -6
- package/rust/core/preprocessor/resolver/group.rs +6 -8
- package/rust/core/preprocessor/resolver/loop_.rs +8 -10
- package/rust/core/preprocessor/resolver/mod.rs +1 -0
- package/rust/core/preprocessor/resolver/pattern.rs +75 -0
- package/rust/core/preprocessor/resolver/spawn.rs +45 -22
- package/rust/core/preprocessor/resolver/synth.rs +6 -8
- package/rust/core/preprocessor/resolver/tempo.rs +6 -8
- package/rust/core/preprocessor/resolver/trigger.rs +22 -19
- package/rust/core/preprocessor/resolver/value.rs +99 -4
- package/rust/core/store/export.rs +28 -28
- package/rust/core/store/function.rs +6 -0
- package/rust/core/store/global.rs +7 -1
- package/rust/core/store/import.rs +28 -28
- package/rust/core/store/variable.rs +16 -2
- package/rust/core/utils/mod.rs +0 -1
- package/rust/lib.rs +102 -9
- package/rust/main.rs +159 -45
- package/rust/types/Cargo.toml +11 -0
- package/rust/types/src/addons.rs +55 -0
- package/rust/types/src/ast.rs +202 -0
- package/rust/types/src/config.rs +74 -0
- package/rust/types/src/lib.rs +12 -0
- package/rust/types/src/telemetry.rs +85 -0
- package/rust/utils/Cargo.toml +26 -0
- package/rust/utils/{error.rs → src/error.rs} +186 -200
- package/rust/utils/src/file.rs +94 -0
- package/rust/utils/src/first_usage.rs +97 -0
- package/rust/utils/{mod.rs → src/lib.rs} +1 -1
- package/rust/utils/{logger.rs → src/logger.rs} +17 -12
- package/rust/utils/src/path.rs +88 -0
- package/rust/utils/src/signature.rs +41 -0
- package/rust/utils/{spinner.rs → src/spinner.rs} +3 -5
- package/rust/utils/src/version.rs +27 -0
- package/rust/utils/{watcher.rs → src/watcher.rs} +13 -1
- package/rust/web/cdn.rs +34 -0
- package/templates/minimal/README.md +98 -54
- package/templates/welcome/README.md +98 -54
- package/templates/welcome/src/index.deva +56 -8
- package/templates/welcome/src/variables.deva +2 -4
- package/tests/rust/TODO.md +0 -0
- package/tests/typescript/index.spec.ts +136 -0
- package/tests/typescript/playhead.spec.ts +36 -0
- package/tests/typescript/render_e2e.spec.ts +77 -0
- package/tsconfig.json +1 -1
- package/typescript/core/functions/index.ts +83 -0
- package/typescript/core/index.ts +6 -0
- package/typescript/core/types/index.ts +4 -0
- package/typescript/core/types/plugin.ts +19 -0
- package/typescript/core/types/result.ts +29 -0
- package/typescript/core/types/statement.ts +47 -0
- package/typescript/core/types/value.ts +29 -0
- package/typescript/index.ts +7 -2
- package/typescript/pkg/devalang_core.d.ts +4 -0
- package/typescript/scripts/copy-wasm-dts.ts +41 -0
- package/rust/cli/bank.rs +0 -462
- package/rust/cli/build.rs +0 -252
- package/rust/cli/play.rs +0 -1123
- package/rust/common/cdn.rs +0 -5
- package/rust/config/loader.rs +0 -165
- package/rust/config/stats.rs +0 -257
- package/rust/core/audio/engine.rs +0 -696
- package/rust/core/shared/bank.rs +0 -21
- package/rust/core/shared/duration.rs +0 -9
- package/rust/core/shared/mod.rs +0 -3
- package/rust/core/shared/value.rs +0 -35
- package/rust/core/utils/validation.rs +0 -35
- package/rust/installer/addon.rs +0 -84
- package/rust/installer/bank.rs +0 -62
- package/rust/installer/plugin.rs +0 -54
- package/rust/installer/utils.rs +0 -56
- package/rust/utils/file.rs +0 -38
- package/rust/utils/first_usage.rs +0 -83
- package/rust/utils/signature.rs +0 -19
- package/rust/utils/telemetry.rs +0 -292
- package/rust/utils/version.rs +0 -15
- /package/rust/{common → web}/api.rs +0 -0
- /package/rust/{common → web}/mod.rs +0 -0
- /package/rust/{common → web}/sso.rs +0 -0
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
use devalang_types::{Duration, Value};
|
|
2
|
+
|
|
1
3
|
use crate::core::{
|
|
2
4
|
audio::{engine::AudioEngine, interpreter::driver::execute_audio_block},
|
|
3
5
|
parser::statement::{Statement, StatementKind},
|
|
4
|
-
shared::value::Value,
|
|
5
6
|
store::{function::FunctionTable, global::GlobalStore, variable::VariableTable},
|
|
6
7
|
};
|
|
7
8
|
|
|
@@ -16,83 +17,258 @@ pub fn interprete_call_statement(
|
|
|
16
17
|
max_end_time: f32,
|
|
17
18
|
cursor_time: f32,
|
|
18
19
|
) -> (f32, f32) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
if let StatementKind::Call { name, args } = &stmt.kind {
|
|
21
|
+
// Classic function call case
|
|
22
|
+
if let Some(func) = functions.functions.get(name) {
|
|
23
|
+
// function found
|
|
24
|
+
if func.parameters.len() != args.len() {
|
|
25
|
+
eprintln!(
|
|
26
|
+
"❌ Function '{}' expects {} args, got {}",
|
|
27
|
+
name,
|
|
28
|
+
func.parameters.len(),
|
|
29
|
+
args.len()
|
|
30
|
+
);
|
|
31
|
+
return (max_end_time, cursor_time);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
let mut local_vars = VariableTable::with_parent(variable_table.clone());
|
|
35
|
+
for (param, arg) in func.parameters.iter().zip(args) {
|
|
36
|
+
local_vars.set(param.clone(), arg.clone());
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return execute_audio_block(
|
|
40
|
+
audio_engine,
|
|
41
|
+
global_store,
|
|
42
|
+
local_vars,
|
|
43
|
+
functions.clone(),
|
|
44
|
+
&func.body,
|
|
45
|
+
base_bpm,
|
|
46
|
+
base_duration,
|
|
47
|
+
max_end_time,
|
|
48
|
+
cursor_time,
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Group case
|
|
53
|
+
if let Some(group_stmt) = find_group(name, variable_table, global_store) {
|
|
54
|
+
// group found
|
|
55
|
+
if let Value::Map(map) = &group_stmt.value {
|
|
56
|
+
if let Some(Value::Block(body)) = map.get("body") {
|
|
57
|
+
return execute_audio_block(
|
|
58
|
+
audio_engine,
|
|
59
|
+
global_store,
|
|
60
|
+
variable_table.clone(),
|
|
61
|
+
functions.clone(),
|
|
62
|
+
body,
|
|
63
|
+
base_bpm,
|
|
64
|
+
base_duration,
|
|
65
|
+
max_end_time,
|
|
66
|
+
cursor_time,
|
|
29
67
|
);
|
|
30
|
-
return (max_end_time, cursor_time);
|
|
31
68
|
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
32
71
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
72
|
+
// Pattern case
|
|
73
|
+
if let Some(pattern_stmt) = find_pattern(name, variable_table, global_store) {
|
|
74
|
+
// Extract pattern string from statement value
|
|
75
|
+
if let Value::String(pat) = &pattern_stmt.value {
|
|
76
|
+
// Determine target entity (explicit or inferred)
|
|
77
|
+
let mut target_entity = name.clone();
|
|
78
|
+
if let StatementKind::Pattern { name: _n, target } = &pattern_stmt.kind {
|
|
79
|
+
if let Some(t) = target {
|
|
80
|
+
target_entity = t.clone();
|
|
81
|
+
}
|
|
36
82
|
}
|
|
37
83
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
84
|
+
// Build a variable table snapshot for resolution like triggers do
|
|
85
|
+
// Preserve the full parent chain so lookups behave the same as runtime
|
|
86
|
+
fn clone_with_parents(orig: &crate::core::store::variable::VariableTable) -> crate::core::store::variable::VariableTable {
|
|
87
|
+
crate::core::store::variable::VariableTable {
|
|
88
|
+
variables: orig.variables.clone(),
|
|
89
|
+
parent: orig.parent.as_ref().map(|p| Box::new(clone_with_parents(p))),
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
let final_variable_table = clone_with_parents(variable_table);
|
|
94
|
+
|
|
95
|
+
// Normalize pattern: remove spaces and line breaks
|
|
96
|
+
let pattern_str: String = pat.chars().filter(|c| !c.is_whitespace()).collect();
|
|
97
|
+
if pattern_str.is_empty() {
|
|
98
|
+
return (max_end_time, cursor_time);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
let step_count = pattern_str.len() as f32;
|
|
102
|
+
// Assume pattern spans one bar (4 beats)
|
|
103
|
+
let total_bar = 4.0 * base_duration;
|
|
104
|
+
let step_duration = total_bar / step_count; // seconds per step
|
|
105
|
+
|
|
106
|
+
let mut updated_max = max_end_time;
|
|
107
|
+
|
|
108
|
+
for (i, ch) in pattern_str.chars().enumerate() {
|
|
109
|
+
if ch == '-' {
|
|
110
|
+
continue; // rest
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Schedule a trigger at cursor_time + offset
|
|
114
|
+
let event_time = cursor_time + (i as f32) * step_duration;
|
|
115
|
+
|
|
116
|
+
// Resolve trigger value similarly to interprete_trigger_statement
|
|
117
|
+
let mut trigger_val = Value::String(target_entity.clone());
|
|
118
|
+
if let Some(val) = variable_table.variables.get(&target_entity) {
|
|
119
|
+
match val {
|
|
120
|
+
Value::Identifier(id) => {
|
|
121
|
+
// resolve from parent if available
|
|
122
|
+
if let Some(parent) = &variable_table.parent {
|
|
123
|
+
if let Some(v) = parent.get(id) {
|
|
124
|
+
trigger_val = v.clone();
|
|
125
|
+
}
|
|
126
|
+
} else if let Some(v) = variable_table.get(id) {
|
|
127
|
+
trigger_val = v.clone();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
Value::Map(map) => {
|
|
131
|
+
if let Some(Value::String(src)) = map.get("entity") {
|
|
132
|
+
trigger_val = Value::String(src.clone());
|
|
133
|
+
} else if let Some(Value::Identifier(src)) = map.get("entity") {
|
|
134
|
+
trigger_val = Value::Identifier(src.clone());
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
Value::Sample(sample_src) => {
|
|
138
|
+
trigger_val = Value::Sample(sample_src.clone());
|
|
139
|
+
}
|
|
140
|
+
_ => {
|
|
141
|
+
// leave as string
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Use loader to get sample path and sample length
|
|
147
|
+
let (src, sample_length) =
|
|
148
|
+
crate::core::audio::loader::trigger::load_trigger(&trigger_val, &Duration::Number(step_duration), &None, base_duration, final_variable_table.clone());
|
|
149
|
+
|
|
150
|
+
let play_length = step_duration.min(sample_length);
|
|
151
|
+
|
|
152
|
+
let trigger_src = match trigger_val.get("entity") {
|
|
153
|
+
Some(Value::String(s)) => s.clone(),
|
|
154
|
+
Some(Value::Identifier(id)) => id.clone(),
|
|
155
|
+
Some(Value::Statement(stmt)) => {
|
|
156
|
+
if let StatementKind::Trigger { entity, .. } = &stmt.kind {
|
|
157
|
+
entity.clone()
|
|
158
|
+
} else {
|
|
159
|
+
src.clone()
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
_ => src.clone(),
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
audio_engine.insert_sample(&trigger_src, event_time, play_length, None, &final_variable_table);
|
|
50
166
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if let Some(Value::Block(body)) = map.get("body") {
|
|
55
|
-
return execute_audio_block(
|
|
56
|
-
audio_engine,
|
|
57
|
-
global_store,
|
|
58
|
-
variable_table.clone(),
|
|
59
|
-
functions.clone(),
|
|
60
|
-
&body,
|
|
61
|
-
base_bpm,
|
|
62
|
-
base_duration,
|
|
63
|
-
max_end_time,
|
|
64
|
-
cursor_time,
|
|
65
|
-
);
|
|
167
|
+
let end_time = event_time + play_length;
|
|
168
|
+
if end_time > updated_max {
|
|
169
|
+
updated_max = end_time;
|
|
66
170
|
}
|
|
67
171
|
}
|
|
68
|
-
}
|
|
69
172
|
|
|
70
|
-
|
|
173
|
+
return (updated_max, cursor_time);
|
|
174
|
+
}
|
|
71
175
|
}
|
|
72
176
|
|
|
73
|
-
|
|
74
|
-
"❌ interprete_call_statement expected Call, got {:?}",
|
|
75
|
-
stmt.kind
|
|
76
|
-
),
|
|
177
|
+
// Function or group not found; keep as debug-free fail path
|
|
77
178
|
}
|
|
78
179
|
|
|
79
180
|
(max_end_time, cursor_time)
|
|
80
181
|
}
|
|
81
182
|
|
|
82
|
-
fn find_group
|
|
183
|
+
fn find_group(
|
|
83
184
|
name: &str,
|
|
84
|
-
variable_table: &
|
|
85
|
-
global_store: &
|
|
86
|
-
) -> Option
|
|
185
|
+
variable_table: &VariableTable,
|
|
186
|
+
global_store: &GlobalStore,
|
|
187
|
+
) -> Option<Statement> {
|
|
188
|
+
use crate::core::parser::statement::Statement;
|
|
189
|
+
use crate::core::parser::statement::StatementKind;
|
|
190
|
+
|
|
87
191
|
if let Some(Value::Statement(stmt_box)) = variable_table.get(name) {
|
|
88
192
|
if let StatementKind::Group = stmt_box.kind {
|
|
89
|
-
return Some(stmt_box);
|
|
193
|
+
return Some(*stmt_box.clone());
|
|
90
194
|
}
|
|
91
195
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
196
|
+
|
|
197
|
+
if let Some(val) = global_store.variables.variables.get(name) {
|
|
198
|
+
match val {
|
|
199
|
+
Value::Statement(stmt_box) => {
|
|
200
|
+
if let StatementKind::Group = stmt_box.kind {
|
|
201
|
+
return Some(*stmt_box.clone());
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
Value::Map(map) => {
|
|
205
|
+
// Try to rebuild a Group statement from the stored map
|
|
206
|
+
if let (Some(Value::String(_id)), Some(Value::Block(_body))) =
|
|
207
|
+
(map.get("identifier"), map.get("body"))
|
|
208
|
+
{
|
|
209
|
+
let stmt = Statement {
|
|
210
|
+
kind: StatementKind::Group,
|
|
211
|
+
value: Value::Map(map.clone()),
|
|
212
|
+
indent: 0,
|
|
213
|
+
line: 0,
|
|
214
|
+
column: 0,
|
|
215
|
+
};
|
|
216
|
+
return Some(stmt);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
_ => {}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
None
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
fn find_pattern(
|
|
227
|
+
name: &str,
|
|
228
|
+
variable_table: &VariableTable,
|
|
229
|
+
global_store: &GlobalStore,
|
|
230
|
+
) -> Option<Statement> {
|
|
231
|
+
use crate::core::parser::statement::Statement;
|
|
232
|
+
use crate::core::parser::statement::StatementKind;
|
|
233
|
+
|
|
234
|
+
if let Some(Value::Statement(stmt_box)) = variable_table.get(name) {
|
|
235
|
+
if let StatementKind::Pattern { .. } = stmt_box.kind {
|
|
236
|
+
return Some(*stmt_box.clone());
|
|
95
237
|
}
|
|
96
238
|
}
|
|
239
|
+
|
|
240
|
+
if let Some(val) = global_store.variables.variables.get(name) {
|
|
241
|
+
match val {
|
|
242
|
+
Value::Statement(stmt_box) => {
|
|
243
|
+
if let StatementKind::Pattern { .. } = stmt_box.kind {
|
|
244
|
+
return Some(*stmt_box.clone());
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
Value::Map(map) => {
|
|
248
|
+
if let Some(Value::String(_pat)) = map.get("pattern") {
|
|
249
|
+
// Rebuild a Pattern statement from stored map if possible
|
|
250
|
+
let stmt = Statement {
|
|
251
|
+
kind: StatementKind::Pattern {
|
|
252
|
+
name: name.to_string(),
|
|
253
|
+
target: map.get("target").and_then(|v| match v {
|
|
254
|
+
Value::String(s) => Some(s.clone()),
|
|
255
|
+
_ => None,
|
|
256
|
+
}),
|
|
257
|
+
},
|
|
258
|
+
value: Value::String(map.get("pattern").and_then(|v| match v {
|
|
259
|
+
Value::String(s) => Some(s.clone()),
|
|
260
|
+
_ => None,
|
|
261
|
+
}).unwrap_or_default()),
|
|
262
|
+
indent: 0,
|
|
263
|
+
line: 0,
|
|
264
|
+
column: 0,
|
|
265
|
+
};
|
|
266
|
+
return Some(stmt);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
_ => {}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
97
273
|
None
|
|
98
274
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
use devalang_types::Value;
|
|
2
|
+
|
|
1
3
|
use crate::core::{
|
|
2
4
|
audio::{
|
|
3
5
|
engine::AudioEngine, evaluator::evaluate_condition_string,
|
|
4
6
|
interpreter::driver::execute_audio_block,
|
|
5
7
|
},
|
|
6
8
|
parser::statement::Statement,
|
|
7
|
-
shared::value::Value,
|
|
8
9
|
store::{function::FunctionTable, global::GlobalStore, variable::VariableTable},
|
|
9
10
|
};
|
|
10
11
|
|
|
@@ -43,7 +44,7 @@ pub fn interprete_condition_statement(
|
|
|
43
44
|
global_store,
|
|
44
45
|
variable_table.clone(),
|
|
45
46
|
functions_table.clone(),
|
|
46
|
-
|
|
47
|
+
block,
|
|
47
48
|
base_bpm,
|
|
48
49
|
base_duration,
|
|
49
50
|
max_time,
|