smokes: add curated LLVM runner; archive legacy smokes; PHI-off unified across Bridge/Builder; LLVM resolver tracing; minimal Throw lowering; config env getters; dev profile and root cleaner; docs updated; CI workflow runs curated LLVM (PHI-on/off)
This commit is contained in:
@ -1,28 +1,28 @@
|
||||
/*!
|
||||
* Phase 7 MIR Builder & VM Test - Async Operations (nowait/await)
|
||||
*
|
||||
*
|
||||
* Tests AST → MIR lowering and VM execution for Phase 7 async operations
|
||||
*/
|
||||
|
||||
use nyash_rust::mir::{MirBuilder, MirPrinter};
|
||||
use nyash_rust::backend::VM;
|
||||
use nyash_rust::ast::{ASTNode, LiteralValue, Span};
|
||||
use nyash_rust::backend::VM;
|
||||
use nyash_rust::mir::{MirBuilder, MirPrinter};
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[test]
|
||||
#[ignore = "MIR13 async: await result wrapping semantics under revision"]
|
||||
fn test_mir_phase7_basic_nowait_await() {
|
||||
// Build AST equivalent to:
|
||||
// static box Main {
|
||||
// main() {
|
||||
// nowait f1 = 42;
|
||||
// local result = await f1;
|
||||
// return result
|
||||
// static box Main {
|
||||
// main() {
|
||||
// nowait f1 = 42;
|
||||
// local result = await f1;
|
||||
// return result
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
let mut main_methods = HashMap::new();
|
||||
|
||||
|
||||
// Create main method body
|
||||
let main_body = vec![
|
||||
// nowait f1 = 42
|
||||
@ -55,7 +55,7 @@ fn test_mir_phase7_basic_nowait_await() {
|
||||
span: Span::unknown(),
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
// Create main method
|
||||
let main_method = ASTNode::FunctionDeclaration {
|
||||
name: "main".to_string(),
|
||||
@ -65,9 +65,9 @@ fn test_mir_phase7_basic_nowait_await() {
|
||||
is_override: false,
|
||||
span: Span::unknown(),
|
||||
};
|
||||
|
||||
|
||||
main_methods.insert("main".to_string(), main_method);
|
||||
|
||||
|
||||
// Create static box Main
|
||||
let ast = ASTNode::BoxDeclaration {
|
||||
name: "Main".to_string(),
|
||||
@ -86,54 +86,56 @@ fn test_mir_phase7_basic_nowait_await() {
|
||||
static_init: None,
|
||||
span: Span::unknown(),
|
||||
};
|
||||
|
||||
|
||||
// Build MIR
|
||||
let mut builder = MirBuilder::new();
|
||||
let result = builder.build_module(ast);
|
||||
|
||||
|
||||
if let Err(e) = &result {
|
||||
println!("MIR build error: {}", e);
|
||||
}
|
||||
assert!(result.is_ok(), "MIR build should succeed");
|
||||
|
||||
|
||||
let module = result.unwrap();
|
||||
|
||||
|
||||
// Print MIR for debugging
|
||||
let printer = MirPrinter::new();
|
||||
let mir_output = printer.print_module(&module);
|
||||
println!("Generated MIR:");
|
||||
println!("{}", mir_output);
|
||||
|
||||
|
||||
// Verify MIR contains expected instructions
|
||||
let function = module.get_function("main").unwrap();
|
||||
let instructions: Vec<_> = function.blocks.values()
|
||||
let instructions: Vec<_> = function
|
||||
.blocks
|
||||
.values()
|
||||
.flat_map(|block| &block.instructions)
|
||||
.collect();
|
||||
|
||||
|
||||
// Should contain FutureNew instruction
|
||||
let has_future_new = instructions.iter().any(|inst| {
|
||||
matches!(inst, nyash_rust::mir::MirInstruction::FutureNew { .. })
|
||||
});
|
||||
let has_future_new = instructions
|
||||
.iter()
|
||||
.any(|inst| matches!(inst, nyash_rust::mir::MirInstruction::FutureNew { .. }));
|
||||
assert!(has_future_new, "MIR should contain FutureNew instruction");
|
||||
|
||||
|
||||
// Should contain Await instruction
|
||||
let has_await = instructions.iter().any(|inst| {
|
||||
matches!(inst, nyash_rust::mir::MirInstruction::Await { .. })
|
||||
});
|
||||
let has_await = instructions
|
||||
.iter()
|
||||
.any(|inst| matches!(inst, nyash_rust::mir::MirInstruction::Await { .. }));
|
||||
assert!(has_await, "MIR should contain Await instruction");
|
||||
|
||||
|
||||
// Test VM execution
|
||||
let mut vm = VM::new();
|
||||
let execution_result = vm.execute_module(&module);
|
||||
|
||||
|
||||
if let Err(e) = &execution_result {
|
||||
println!("VM execution error: {}", e);
|
||||
}
|
||||
assert!(execution_result.is_ok(), "VM execution should succeed");
|
||||
|
||||
|
||||
let final_value = execution_result.unwrap();
|
||||
println!("VM execution result: {}", final_value.to_string_box().value);
|
||||
|
||||
|
||||
// Should return 42
|
||||
assert_eq!(final_value.to_string_box().value, "42");
|
||||
}
|
||||
@ -142,18 +144,18 @@ fn test_mir_phase7_basic_nowait_await() {
|
||||
#[ignore = "MIR13 async: multiple await aggregation semantics under revision"]
|
||||
fn test_mir_phase7_multiple_nowait_await() {
|
||||
// Build AST equivalent to:
|
||||
// static box Main {
|
||||
// main() {
|
||||
// nowait f1 = 10;
|
||||
// nowait f2 = 20;
|
||||
// local result1 = await f1;
|
||||
// local result2 = await f2;
|
||||
// return result1 + result2
|
||||
// static box Main {
|
||||
// main() {
|
||||
// nowait f1 = 10;
|
||||
// nowait f2 = 20;
|
||||
// local result1 = await f1;
|
||||
// local result2 = await f2;
|
||||
// return result1 + result2
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
let mut main_methods = HashMap::new();
|
||||
|
||||
|
||||
// Create main method body
|
||||
let main_body = vec![
|
||||
// nowait f1 = 10
|
||||
@ -215,7 +217,7 @@ fn test_mir_phase7_multiple_nowait_await() {
|
||||
span: Span::unknown(),
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
// Create main method
|
||||
let main_method = ASTNode::FunctionDeclaration {
|
||||
name: "main".to_string(),
|
||||
@ -225,9 +227,9 @@ fn test_mir_phase7_multiple_nowait_await() {
|
||||
is_override: false,
|
||||
span: Span::unknown(),
|
||||
};
|
||||
|
||||
|
||||
main_methods.insert("main".to_string(), main_method);
|
||||
|
||||
|
||||
// Create static box Main
|
||||
let ast = ASTNode::BoxDeclaration {
|
||||
name: "Main".to_string(),
|
||||
@ -246,28 +248,28 @@ fn test_mir_phase7_multiple_nowait_await() {
|
||||
static_init: None,
|
||||
span: Span::unknown(),
|
||||
};
|
||||
|
||||
|
||||
// Build MIR
|
||||
let mut builder = MirBuilder::new();
|
||||
let result = builder.build_module(ast);
|
||||
|
||||
|
||||
assert!(result.is_ok(), "MIR build should succeed");
|
||||
let module = result.unwrap();
|
||||
|
||||
|
||||
// Print MIR for debugging
|
||||
let printer = MirPrinter::new();
|
||||
let mir_output = printer.print_module(&module);
|
||||
println!("Generated MIR for multiple nowait/await:");
|
||||
println!("{}", mir_output);
|
||||
|
||||
|
||||
// Test VM execution
|
||||
let mut vm = VM::new();
|
||||
let execution_result = vm.execute_module(&module);
|
||||
|
||||
|
||||
assert!(execution_result.is_ok(), "VM execution should succeed");
|
||||
let final_value = execution_result.unwrap();
|
||||
println!("VM execution result: {}", final_value.to_string_box().value);
|
||||
|
||||
|
||||
// Should return 30 (10 + 20)
|
||||
assert_eq!(final_value.to_string_box().value, "30");
|
||||
}
|
||||
@ -276,18 +278,18 @@ fn test_mir_phase7_multiple_nowait_await() {
|
||||
#[ignore = "MIR13 async: nested await semantics under revision"]
|
||||
fn test_mir_phase7_nested_await() {
|
||||
// Build AST equivalent to:
|
||||
// static box Main {
|
||||
// main() {
|
||||
// static box Main {
|
||||
// main() {
|
||||
// nowait outer = {
|
||||
// nowait inner = 5;
|
||||
// await inner * 2
|
||||
// };
|
||||
// return await outer
|
||||
// return await outer
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
let mut main_methods = HashMap::new();
|
||||
|
||||
|
||||
// Create inner computation: nowait inner = 5; await inner * 2
|
||||
let inner_computation = ASTNode::Program {
|
||||
statements: vec![
|
||||
@ -317,7 +319,7 @@ fn test_mir_phase7_nested_await() {
|
||||
],
|
||||
span: Span::unknown(),
|
||||
};
|
||||
|
||||
|
||||
// Create main method body
|
||||
let main_body = vec![
|
||||
// nowait outer = { ... }
|
||||
@ -338,7 +340,7 @@ fn test_mir_phase7_nested_await() {
|
||||
span: Span::unknown(),
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
// Create main method
|
||||
let main_method = ASTNode::FunctionDeclaration {
|
||||
name: "main".to_string(),
|
||||
@ -348,9 +350,9 @@ fn test_mir_phase7_nested_await() {
|
||||
is_override: false,
|
||||
span: Span::unknown(),
|
||||
};
|
||||
|
||||
|
||||
main_methods.insert("main".to_string(), main_method);
|
||||
|
||||
|
||||
// Create static box Main
|
||||
let ast = ASTNode::BoxDeclaration {
|
||||
name: "Main".to_string(),
|
||||
@ -369,28 +371,28 @@ fn test_mir_phase7_nested_await() {
|
||||
static_init: None,
|
||||
span: Span::unknown(),
|
||||
};
|
||||
|
||||
|
||||
// Build MIR
|
||||
let mut builder = MirBuilder::new();
|
||||
let result = builder.build_module(ast);
|
||||
|
||||
|
||||
assert!(result.is_ok(), "MIR build should succeed");
|
||||
let module = result.unwrap();
|
||||
|
||||
|
||||
// Print MIR for debugging
|
||||
let printer = MirPrinter::new();
|
||||
let mir_output = printer.print_module(&module);
|
||||
println!("Generated MIR for nested await:");
|
||||
println!("{}", mir_output);
|
||||
|
||||
|
||||
// Test VM execution
|
||||
let mut vm = VM::new();
|
||||
let execution_result = vm.execute_module(&module);
|
||||
|
||||
|
||||
assert!(execution_result.is_ok(), "VM execution should succeed");
|
||||
let final_value = execution_result.unwrap();
|
||||
println!("VM execution result: {}", final_value.to_string_box().value);
|
||||
|
||||
|
||||
// Should return 10 (5 * 2)
|
||||
assert_eq!(final_value.to_string_box().value, "10");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user