Core-13 pure: add CI workflows, VM e2e tests, LLVM parity bridge (minimal); do not touch private docs

This commit is contained in:
Tomoaki
2025-09-07 07:28:53 +09:00
parent 07350c5dd9
commit d62114c705
383 changed files with 15221 additions and 382 deletions

View File

@ -124,6 +124,37 @@ impl MirCompiler {
return Err(format!("Core-13 strict: final MIR contains {} legacy ops", legacy_count));
}
}
// Core-13 pure: allow only the 13 canonical ops; reject all others
if crate::config::env::mir_core13_pure() {
let mut bad = 0usize;
let is_allowed = |i: &MirInstruction| -> bool {
matches!(i,
MirInstruction::Const { .. }
| MirInstruction::BinOp { .. }
| MirInstruction::Compare { .. }
| MirInstruction::Jump { .. }
| MirInstruction::Branch { .. }
| MirInstruction::Return { .. }
| MirInstruction::Phi { .. }
| MirInstruction::Call { .. }
| MirInstruction::BoxCall { .. }
| MirInstruction::ExternCall { .. }
| MirInstruction::TypeOp { .. }
| MirInstruction::Safepoint
| MirInstruction::Barrier { .. }
)
};
for (_fname, function) in &module.functions {
for (_bb, block) in &function.blocks {
for inst in &block.instructions { if !is_allowed(inst) { bad += 1; } }
if let Some(term) = &block.terminator { if !is_allowed(term) { bad += 1; } }
}
}
if bad > 0 {
return Err(format!("Core-13 pure strict: final MIR contains {} non-Core-13 ops", bad));
}
}
// Verify the generated MIR
let verification_result = self.verifier.verify_module(&module);
@ -290,6 +321,7 @@ mod tests {
#[test]
fn test_lowering_await_expression() {
if crate::config::env::mir_core13_pure() { eprintln!("[TEST] skip await under Core-13 pure mode"); return; }
// Build AST: await 1 (semantic is nonsensical but should emit Await)
let ast = ASTNode::AwaitExpression { expression: Box::new(ASTNode::Literal { value: LiteralValue::Integer(1), span: crate::ast::Span::unknown() }), span: crate::ast::Span::unknown() };
let mut compiler = MirCompiler::new();
@ -300,6 +332,7 @@ mod tests {
#[test]
fn test_await_has_checkpoints() {
if crate::config::env::mir_core13_pure() { eprintln!("[TEST] skip await under Core-13 pure mode"); return; }
use crate::ast::{LiteralValue, Span};
// Build: await 1
let ast = ASTNode::AwaitExpression { expression: Box::new(ASTNode::Literal { value: LiteralValue::Integer(1), span: Span::unknown() }), span: Span::unknown() };
@ -315,6 +348,7 @@ mod tests {
#[test]
fn test_rewritten_await_still_checkpoints() {
if crate::config::env::mir_core13_pure() { eprintln!("[TEST] skip await under Core-13 pure mode"); return; }
use crate::ast::{LiteralValue, Span};
// Enable rewrite so Await → ExternCall(env.future.await)
std::env::set_var("NYASH_REWRITE_FUTURE", "1");
@ -386,6 +420,11 @@ mod tests {
#[test]
fn test_try_catch_compilation() {
// Core-13 pure モードでは Try/Catch 命令は許容集合外のためスキップ
if crate::config::env::mir_core13_pure() {
eprintln!("[TEST] skip try/catch under Core-13 pure mode");
return;
}
let mut compiler = MirCompiler::new();
let try_catch_ast = ASTNode::TryCatch {