stage1 人工重构ast.c

This commit is contained in:
zzy
2026-08-12 10:29:38 +08:00
parent 314100afbc
commit b0e6b406ac
22 changed files with 1619 additions and 2895 deletions

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env python3
"""SPL build system .c .o exe, .spl .sir, deps auto-resolved."""
"""SPL build system - .c -> .o -> exe, .spl -> .sir, deps auto-resolved."""
import argparse
import hashlib
@@ -304,13 +304,13 @@ def clean():
print(f" CLEAN {BUILD_DIR}")
def list_targets(desc):
print("Executables (.c .o exe):")
print("Executables (.c -> .o -> exe):")
for name, sources in desc.get("exe", {}).items():
print(f" {name}")
for s in sources:
print(f" {s}")
if desc.get("spl"):
print("\nSPL programs (.spl .sir via pipeline):")
print("\nSPL programs (.spl -> .sir via pipeline):")
for name, info in desc["spl"].items():
pl_name = info.get("pipeline", "-")
print(f" {name} pipeline={pl_name} src={info['src']}")
@@ -366,7 +366,7 @@ def main():
save_cache(cache)
return rc
# Pipeline: build compiler compile .spl run via runner
# Pipeline: build compiler -> compile .spl -> run via runner
if args.command == "pipeline":
desc = load_desc(); cache = load_cache()
pl = desc.get("pipeline", {}).get(args.name)
@@ -384,7 +384,7 @@ def main():
if not build(compiler, desc, cache, False): return 1
if not build(runner, desc, cache, False): return 1
# Compile .spl .sir (temp name = src path hash)
# Compile .spl -> .sir (temp name = src path hash)
sir_name = "pipeline_" + hashlib.sha256(str(src_path).encode()).hexdigest()[:8]
if not compile_spl(sir_name, args.src, compiler, desc, cache, False):
return 1