Skip to content

Commit e3a6de4

Browse files
committed
save
1 parent dfc1e6f commit e3a6de4

File tree

94 files changed

+300568
-1334
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+300568
-1334
lines changed

crates/oxc_angular_compiler/src/ir/list.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,15 @@ impl<'a, T: Op> OpList<'a, T> {
276276
/// # Safety
277277
/// The `old` pointer must point to a valid operation in this list.
278278
pub unsafe fn replace(&mut self, old: NonNull<T>, new_op: T) {
279+
// SAFETY: Same preconditions apply to both functions
280+
let _ = unsafe { self.replace_returning_new(old, new_op) };
281+
}
282+
283+
/// Replaces an operation with another operation and returns a pointer to the new operation.
284+
///
285+
/// # Safety
286+
/// The `old` pointer must point to a valid operation in this list.
287+
pub unsafe fn replace_returning_new(&mut self, old: NonNull<T>, new_op: T) -> NonNull<T> {
279288
let new_ptr = self.alloc_op(new_op);
280289

281290
// SAFETY: old is a valid pointer in this list
@@ -302,6 +311,8 @@ impl<'a, T: Op> OpList<'a, T> {
302311
(*old.as_ptr()).set_prev(None);
303312
(*old.as_ptr()).set_next(None);
304313
}
314+
315+
new_ptr
305316
}
306317

307318
/// Prepends all operations from another list to the front of this list.
@@ -516,7 +527,11 @@ impl<'b, 'a, T: Op> OpListCursor<'b, 'a, T> {
516527
pub fn replace_current(&mut self, op: T) {
517528
if let Some(current) = self.current {
518529
// SAFETY: current is valid as it was obtained from the list
519-
unsafe { self.list.replace(current, op) };
530+
// We need to update self.current to point to the new node, since
531+
// the old node's next/prev pointers are cleared by replace().
532+
// This ensures move_next() works correctly after replacement.
533+
let new_ptr = unsafe { self.list.replace_returning_new(current, op) };
534+
self.current = Some(new_ptr);
520535
}
521536
}
522537
}

crates/oxc_angular_compiler/src/ir/ops.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,9 @@ pub struct ElementStartOp<'a> {
667667
pub attribute_namespace: Option<Atom<'a>>,
668668
/// Local references attached to this element.
669669
pub local_refs: Vec<'a, LocalRef<'a>>,
670+
/// Index into the consts array for local refs.
671+
/// Set by local_refs phase.
672+
pub local_refs_index: Option<u32>,
670673
/// Non-bindable element.
671674
pub non_bindable: bool,
672675
/// I18n placeholder data (start_name and close_name for paired tags).
@@ -692,6 +695,9 @@ pub struct ElementOp<'a> {
692695
pub attribute_namespace: Option<Atom<'a>>,
693696
/// Local references.
694697
pub local_refs: Vec<'a, LocalRef<'a>>,
698+
/// Index into the consts array for local refs.
699+
/// Set by local_refs phase.
700+
pub local_refs_index: Option<u32>,
695701
/// Non-bindable element.
696702
pub non_bindable: bool,
697703
/// I18n placeholder data (start_name and close_name for paired tags).
@@ -757,6 +763,9 @@ pub struct ContainerStartOp<'a> {
757763
pub xref: XrefId,
758764
/// Assigned slot.
759765
pub slot: Option<SlotId>,
766+
/// Index into the consts array for attributes.
767+
/// Set by const_collection phase.
768+
pub attributes: Option<u32>,
760769
/// Local references.
761770
pub local_refs: Vec<'a, LocalRef<'a>>,
762771
/// Non-bindable container.
@@ -774,6 +783,9 @@ pub struct ContainerOp<'a> {
774783
pub xref: XrefId,
775784
/// Assigned slot.
776785
pub slot: Option<SlotId>,
786+
/// Index into the consts array for attributes.
787+
/// Set by const_collection phase.
788+
pub attributes: Option<u32>,
777789
/// Local references.
778790
pub local_refs: Vec<'a, LocalRef<'a>>,
779791
/// Non-bindable container.
@@ -840,6 +852,9 @@ pub struct ConditionalOp<'a> {
840852
pub vars: Option<u32>,
841853
/// Local references on this element.
842854
pub local_refs: Vec<'a, LocalRef<'a>>,
855+
/// Index into the consts array for local refs.
856+
/// Set by local_refs phase.
857+
pub local_refs_index: Option<u32>,
843858
/// I18n placeholder data (start_name and close_name for @if/@switch blocks).
844859
pub i18n_placeholder: Option<I18nPlaceholder<'a>>,
845860
/// Index into the consts array for element attributes.
@@ -868,6 +883,8 @@ pub struct ConditionalBranchCreateOp<'a> {
868883
pub template_kind: TemplateKind,
869884
/// Function name suffix.
870885
pub fn_name_suffix: Atom<'a>,
886+
/// HTML tag name (for content projection).
887+
pub tag: Option<Atom<'a>>,
871888
/// The number of declaration slots used by this branch.
872889
/// Set by allocate_slots phase.
873890
pub decls: Option<u32>,
@@ -876,6 +893,9 @@ pub struct ConditionalBranchCreateOp<'a> {
876893
pub vars: Option<u32>,
877894
/// Local references on this branch.
878895
pub local_refs: Vec<'a, LocalRef<'a>>,
896+
/// Index into the consts array for local refs.
897+
/// Set by local_refs phase.
898+
pub local_refs_index: Option<u32>,
879899
/// I18n placeholder data (start_name and close_name for paired tags).
880900
pub i18n_placeholder: Option<I18nPlaceholder<'a>>,
881901
/// Index into the consts array for element attributes.
@@ -1165,8 +1185,14 @@ pub struct RepeaterCreateOp<'a> {
11651185
pub var_names: RepeaterVarNames<'a>,
11661186
/// HTML tag name (for content projection).
11671187
pub tag: Option<Atom<'a>>,
1188+
/// Const index for attributes (for content projection).
1189+
/// Set by const_collection phase.
1190+
pub attributes: Option<u32>,
11681191
/// HTML tag name for empty view (for content projection).
11691192
pub empty_tag: Option<Atom<'a>>,
1193+
/// Const index for empty view attributes (for content projection).
1194+
/// Set by const_collection phase.
1195+
pub empty_attributes: Option<u32>,
11701196
/// I18n placeholder data (start_name and close_name for @for block).
11711197
pub i18n_placeholder: Option<I18nPlaceholder<'a>>,
11721198
/// I18n placeholder data for @empty view.

crates/oxc_angular_compiler/src/parser/expression/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,9 @@ impl<'a> BindingParser<'a> {
175175
start_delimiter: &str,
176176
end_delimiter: &str,
177177
) -> Option<ParseResult<'a>> {
178-
let parser = Parser::with_offset(self.allocator, value, span.start);
178+
// Use for_interpolation to avoid tokenizing the full input including
179+
// literal text like "/ " before interpolations.
180+
let parser = Parser::for_interpolation(self.allocator, value, span.start);
179181
parser.parse_interpolation(start_delimiter, end_delimiter)
180182
}
181183

crates/oxc_angular_compiler/src/parser/expression/parser.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,27 @@ impl<'a> Parser<'a> {
142142
parser
143143
}
144144

145+
/// Creates a parser for interpolation parsing without tokenizing.
146+
///
147+
/// Interpolation parsing doesn't need tokenization of the full input because
148+
/// it manually splits the text to find `{{` and `}}` boundaries, then creates
149+
/// sub-parsers for each expression part.
150+
pub fn for_interpolation(allocator: &'a Allocator, source: &'a str, offset: u32) -> Self {
151+
Self {
152+
allocator,
153+
tokens: std::vec::Vec::new(),
154+
index: 0,
155+
source,
156+
errors: std::vec::Vec::new(),
157+
absolute_offset: offset,
158+
rparens_expected: 0,
159+
rbrackets_expected: 0,
160+
rbraces_expected: 0,
161+
context: ParseContextFlags::NONE,
162+
action_mode: false,
163+
}
164+
}
165+
145166
/// Strips single-line comments (`//`) from the input.
146167
///
147168
/// Comments are only recognized outside of quoted strings.

crates/oxc_angular_compiler/src/pipeline/constant_pool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ impl<'a> ConstantPool<'a> {
195195
}
196196

197197
let index = self.values.len() as u32;
198-
let name = self.generate_name("_pf");
198+
let name = self.generate_name("_c");
199199

200200
// Generate parameter names: a0, a1, a2, ...
201201
let mut params = Vec::with_capacity_in(num_args as usize, self.allocator);

0 commit comments

Comments
 (0)