Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ TypeScript (.ts) → Parse (SWC) → AST → Lower → HIR → Transform → Cod
|-------|---------|
| **perry** | CLI driver (parallel module codegen via rayon) |
| **perry-parser** | SWC wrapper for TypeScript parsing |
| **perry-types** | Type system definitions |
| **perry-hir** | HIR data structures (`ir.rs`) and AST→HIR lowering (`lower.rs`) |
| **perry-hir** | HIR types and data structures, plus AST→HIR lowering |
| **perry-transform** | IR passes (closure conversion, async lowering, inlining) |
| **perry-codegen** | LLVM-based native code generation |
| **perry-runtime** | Runtime: value.rs, object.rs, array.rs, string.rs, gc.rs, arena.rs, thread.rs |
Expand Down
16 changes: 0 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ resolver = "2"
members = [
"crates/perry",
"crates/perry-parser",
"crates/perry-types",
"crates/perry-api-manifest",
"crates/perry-hir",
"crates/perry-transform",
Expand Down Expand Up @@ -390,7 +389,6 @@ zstd = "0.13"

# Internal crates
perry-parser = { path = "crates/perry-parser" }
perry-types = { path = "crates/perry-types" }
perry-api-manifest = { path = "crates/perry-api-manifest" }
perry-hir = { path = "crates/perry-hir" }
perry-transform = { path = "crates/perry-transform" }
Expand Down
1 change: 1 addition & 0 deletions changelog.d/6760-merge-types-into-hir.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**Compiler architecture:** move the shared compiler type definitions into `perry_hir::types`, remove the standalone types crate, and reduce the Perry dependency closure from 18 crates to 17 crates.
2 changes: 0 additions & 2 deletions crates/perry-codegen-arkts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ workspace = true

[dependencies]
perry-hir.workspace = true
perry-types.workspace = true
anyhow.workspace = true

[dev-dependencies]
perry-types.workspace = true
10 changes: 5 additions & 5 deletions crates/perry-codegen-arkts/src/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::*;
/// same way as real top-level lets.
pub(crate) fn inlined_analysis_init(module: &Module) -> Vec<Stmt> {
use perry_hir::analysis::remap_local_ids_in_stmts;
use perry_types::FuncId;
use perry_hir::types::FuncId;
use std::collections::HashSet;

let mut function_map: HashMap<FuncId, perry_hir::ir::Function> = HashMap::new();
Expand Down Expand Up @@ -128,7 +128,7 @@ pub(crate) fn inlined_analysis_init(module: &Module) -> Vec<Stmt> {
/// covers Mango's makePill but punts on more complex returning fns.
pub(crate) fn expr_level_inline_pass(
stmts: Vec<Stmt>,
function_map: &HashMap<perry_types::FuncId, perry_hir::ir::Function>,
function_map: &HashMap<perry_hir::types::FuncId, perry_hir::ir::Function>,
bindings: &HashMap<LocalId, Expr>,
next_local: &mut u32,
budget: &mut usize,
Expand Down Expand Up @@ -156,7 +156,7 @@ pub(crate) fn expr_level_inline_pass(

pub(crate) fn inline_calls_in_stmt(
stmt: &mut Stmt,
function_map: &HashMap<perry_types::FuncId, perry_hir::ir::Function>,
function_map: &HashMap<perry_hir::types::FuncId, perry_hir::ir::Function>,
bindings: &HashMap<LocalId, Expr>,
next_local: &mut u32,
budget: &mut usize,
Expand Down Expand Up @@ -210,7 +210,7 @@ pub(crate) fn inline_calls_in_stmt(

pub(crate) fn inline_calls_in_expr(
expr: &mut Expr,
function_map: &HashMap<perry_types::FuncId, perry_hir::ir::Function>,
function_map: &HashMap<perry_hir::types::FuncId, perry_hir::ir::Function>,
bindings: &HashMap<LocalId, Expr>,
next_local: &mut u32,
budget: &mut usize,
Expand Down Expand Up @@ -327,7 +327,7 @@ pub(crate) fn inline_calls_in_expr(
name: String::new(),
type_params: Vec::new(),
params,
return_type: perry_types::Type::Any,
return_type: perry_hir::types::Type::Any,
body,
is_strict,
is_async: false,
Expand Down
4 changes: 2 additions & 2 deletions crates/perry-codegen-arkts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,9 @@ pub fn emit_index_ets(module: &mut Module) -> Result<Option<HarvestResult>> {
// expression substitutes the call. Without this, emit_widget
// hits `[unrecognized body]` for every helper-wrapped Text /
// Stack child.
let function_map_inline: HashMap<perry_types::FuncId, perry_hir::ir::Function> =
let function_map_inline: HashMap<perry_hir::types::FuncId, perry_hir::ir::Function> =
module.functions.iter().map(|f| (f.id, f.clone())).collect();
let function_lookup: HashMap<perry_types::FuncId, &perry_hir::ir::Function> =
let function_lookup: HashMap<perry_hir::types::FuncId, &perry_hir::ir::Function> =
module.functions.iter().map(|f| (f.id, f)).collect();
// Start view-builder Phase B remap counter ABOVE the highest
// LocalId already used by `analysis_init` (Phase A + B inlining
Expand Down
8 changes: 4 additions & 4 deletions crates/perry-codegen-arkts/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ pub(crate) fn app_with_body(body: Expr) -> Stmt {

pub(crate) fn closure_stub() -> Expr {
Expr::Closure {
func_id: 0 as perry_types::FuncId,
func_id: 0 as perry_hir::types::FuncId,
params: vec![],
return_type: perry_types::Type::Any,
return_type: perry_hir::types::Type::Any,
body: vec![],
captures: vec![],
mutable_captures: vec![],
Expand Down Expand Up @@ -136,7 +136,7 @@ pub(crate) fn let_widget(id: LocalId, name: &str, init: Expr) -> Stmt {
Stmt::Let {
id,
name: name.to_string(),
ty: perry_types::Type::Any,
ty: perry_hir::types::Type::Any,
mutable: false,
init: Some(init),
}
Expand All @@ -161,7 +161,7 @@ pub(crate) fn declare_const(id: LocalId, name: &str) -> Stmt {
Stmt::Let {
id,
name: name.to_string(),
ty: perry_types::Type::Any,
ty: perry_hir::types::Type::Any,
mutable: false,
init: None,
}
Expand Down
34 changes: 17 additions & 17 deletions crates/perry-codegen-arkts/src/tests/containers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ fn navstack_emits_state_driven_branches() {
m.init.push(Stmt::Let {
id: 5,
name: "route".to_string(),
ty: perry_types::Type::Any,
ty: perry_hir::types::Type::Any,
mutable: false,
init: Some(state_call(Expr::String("home".into()))),
});
Expand Down Expand Up @@ -169,7 +169,7 @@ fn navstack_no_state_falls_back_to_first_route() {
m.init.push(Stmt::Let {
id: 7,
name: "x".to_string(),
ty: perry_types::Type::Any,
ty: perry_hir::types::Type::Any,
mutable: false,
init: Some(Expr::String("home".into())),
});
Expand Down Expand Up @@ -202,7 +202,7 @@ fn navstack_empty_routes_emits_empty_column_with_comment() {
m.init.push(Stmt::Let {
id: 5,
name: "route".to_string(),
ty: perry_types::Type::Any,
ty: perry_hir::types::Type::Any,
mutable: false,
init: Some(state_call(Expr::String("home".into()))),
});
Expand All @@ -224,7 +224,7 @@ fn navstack_set_in_closure_rewrites_to_settext() {
m.init.push(Stmt::Let {
id: 5,
name: "route".to_string(),
ty: perry_types::Type::Any,
ty: perry_hir::types::Type::Any,
mutable: false,
init: Some(state_call(Expr::String("home".into()))),
});
Expand All @@ -233,9 +233,9 @@ fn navstack_set_in_closure_rewrites_to_settext() {
vec![
Expr::String("Go".into()),
Expr::Closure {
func_id: 0 as perry_types::FuncId,
func_id: 0 as perry_hir::types::FuncId,
params: vec![],
return_type: perry_types::Type::Any,
return_type: perry_hir::types::Type::Any,
body: vec![Stmt::Expr(state_method_call(
5,
"set",
Expand Down Expand Up @@ -297,7 +297,7 @@ fn state_text_emits_reactive_text_with_synth_id() {
m.init.push(Stmt::Let {
id: 5,
name: "count".to_string(),
ty: perry_types::Type::Any,
ty: perry_hir::types::Type::Any,
mutable: false,
init: Some(state_call(Expr::Number(0.0))),
});
Expand All @@ -318,15 +318,15 @@ fn state_set_in_closure_rewrites_to_settext() {
m.init.push(Stmt::Let {
id: 5,
name: "count".to_string(),
ty: perry_types::Type::Any,
ty: perry_hir::types::Type::Any,
mutable: false,
init: Some(state_call(Expr::Number(0.0))),
});
// Closure body: Stmt::Expr(count.set(5))
let closure = Expr::Closure {
func_id: 0 as perry_types::FuncId,
func_id: 0 as perry_hir::types::FuncId,
params: vec![],
return_type: perry_types::Type::Any,
return_type: perry_hir::types::Type::Any,
body: vec![Stmt::Expr(state_method_call(
5,
"set",
Expand Down Expand Up @@ -372,14 +372,14 @@ fn multiple_state_decls_get_unique_ids() {
m.init.push(Stmt::Let {
id: 1,
name: "count".to_string(),
ty: perry_types::Type::Any,
ty: perry_hir::types::Type::Any,
mutable: false,
init: Some(state_call(Expr::Number(0.0))),
});
m.init.push(Stmt::Let {
id: 2,
name: "name".to_string(),
ty: perry_types::Type::Any,
ty: perry_hir::types::Type::Any,
mutable: false,
init: Some(state_call(Expr::String("Alice".into()))),
});
Expand Down Expand Up @@ -489,7 +489,7 @@ fn lazyvstack_with_array_map_emits_lazy_for_each() {
let item_param = perry_hir::ir::Param {
id: 99,
name: "item".to_string(),
ty: perry_types::Type::Any,
ty: perry_hir::types::Type::Any,
default: None,
decorators: Vec::new(),
is_rest: false,
Expand All @@ -502,9 +502,9 @@ fn lazyvstack_with_array_map_emits_lazy_for_each() {
Expr::String("b".into()),
])),
callback: Box::new(Expr::Closure {
func_id: 0 as perry_types::FuncId,
func_id: 0 as perry_hir::types::FuncId,
params: vec![item_param],
return_type: perry_types::Type::Any,
return_type: perry_hir::types::Type::Any,
body: vec![Stmt::Return(Some(inner_text))],
captures: vec![],
mutable_captures: vec![],
Expand Down Expand Up @@ -842,9 +842,9 @@ fn media_call_inside_button_closure_also_triggers_glue() {
// walker must descend into Closure bodies via stmt_uses → Closure.
let mut m = empty_module();
let play_closure = Expr::Closure {
func_id: 0 as perry_types::FuncId,
func_id: 0 as perry_hir::types::FuncId,
params: vec![],
return_type: perry_types::Type::Any,
return_type: perry_hir::types::Type::Any,
body: vec![Stmt::Expr(media_call("play", vec![Expr::Number(1.0)]))],
captures: vec![],
mutable_captures: vec![],
Expand Down
2 changes: 1 addition & 1 deletion crates/perry-codegen-arkts/src/tests/mutations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ fn phase2_v35_widget_set_hidden_in_closure_emits_state_binding() {
let onclick = Expr::Closure {
func_id: 0,
params: vec![],
return_type: perry_types::Type::Any,
return_type: perry_hir::types::Type::Any,
body: vec![mutator_stmt(
"widgetSetHidden",
vec![Expr::LocalGet(target_id), Expr::Number(0.0)],
Expand Down
8 changes: 4 additions & 4 deletions crates/perry-codegen-arkts/src/tests/widgets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ fn local_get_escape_follows_const_binding() {
m.init.push(Stmt::Let {
id: 7,
name: "t".to_string(),
ty: perry_types::Type::Any,
ty: perry_hir::types::Type::Any,
mutable: false,
init: Some(nmc("Text", vec![Expr::String("via let".into())])),
});
Expand Down Expand Up @@ -545,7 +545,7 @@ fn for_each_lowers_array_map_in_vstack() {
let item_param = perry_hir::ir::Param {
id: 42,
name: "item".to_string(),
ty: perry_types::Type::Any,
ty: perry_hir::types::Type::Any,
default: None,
decorators: Vec::new(),
is_rest: false,
Expand All @@ -559,9 +559,9 @@ fn for_each_lowers_array_map_in_vstack() {
Expr::String("c".into()),
])),
callback: Box::new(Expr::Closure {
func_id: 0 as perry_types::FuncId,
func_id: 0 as perry_hir::types::FuncId,
params: vec![item_param],
return_type: perry_types::Type::Any,
return_type: perry_hir::types::Type::Any,
body: vec![Stmt::Return(Some(inner_text))],
captures: vec![],
mutable_captures: vec![],
Expand Down
4 changes: 2 additions & 2 deletions crates/perry-codegen-arkts/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use perry_hir::ir::Expr;

// LocalId is `u32` upstream; re-import directly so we don't carry a
// transitive dep on perry-types just for the type alias.
// HIR owns the function identifier used by view builders.
pub(crate) type LocalId = u32;

/// Result of harvesting an `App({body: ...})` call: the emitted ArkUI
Expand Down Expand Up @@ -197,7 +197,7 @@ pub(crate) struct VisibilityBinding {
#[derive(Debug, Clone)]
pub(crate) struct ViewBuilder {
/// Function id (matches `Function::id` in the HIR).
pub(crate) func_id: perry_types::FuncId,
pub(crate) func_id: perry_hir::types::FuncId,
/// Function name (used for the synth view id when sanitized).
// #854: stashed on the harvest instance for a future diagnostic pass; the
// view id is currently derived inline at emit time, not read back here.
Expand Down
Loading