mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 10:50:00 +00:00
llr: Add a helper function
This commit is contained in:
parent
76a1bf8d7d
commit
9e938046ca
3 changed files with 25 additions and 22 deletions
|
@ -1473,14 +1473,11 @@ fn generate_global(file: &mut File, global: &llr::GlobalComponent, root: &llr::P
|
|||
|
||||
let mut init = vec![];
|
||||
|
||||
let ctx = EvaluationContext {
|
||||
public_component: root,
|
||||
current_sub_component: None,
|
||||
current_global: Some(global),
|
||||
generator_state: "\n#error can't access root from global\n".into(),
|
||||
parent: None,
|
||||
argument_types: &[],
|
||||
};
|
||||
let ctx = EvaluationContext::new_global(
|
||||
root,
|
||||
global,
|
||||
"\n#error can't access root from global\n".into(),
|
||||
);
|
||||
|
||||
for (property_index, expression) in global.init_values.iter().enumerate() {
|
||||
if let Some(expression) = expression.as_ref() {
|
||||
|
|
|
@ -797,14 +797,11 @@ fn generate_global(global: &llr::GlobalComponent, root: &llr::PublicComponent) -
|
|||
|
||||
let mut init = vec![];
|
||||
|
||||
let ctx = EvaluationContext {
|
||||
public_component: root,
|
||||
current_sub_component: None,
|
||||
current_global: Some(global),
|
||||
generator_state: quote!(compilation_error("can't access root from global")),
|
||||
parent: None,
|
||||
argument_types: &[],
|
||||
};
|
||||
let ctx = EvaluationContext::new_global(
|
||||
root,
|
||||
global,
|
||||
quote!(compilation_error("can't access root from global")),
|
||||
);
|
||||
|
||||
for (property_index, expression) in global.init_values.iter().enumerate() {
|
||||
if let Some(expression) = expression.as_ref() {
|
||||
|
|
|
@ -406,12 +406,6 @@ impl<'a, T> EvaluationContext<'a, T> {
|
|||
generator_state: T,
|
||||
parent: Option<ParentCtx<'a, T>>,
|
||||
) -> Self {
|
||||
/*let generator_state = if let Some(parent) = &parent {
|
||||
let p = &parent.ctx.generator_state;
|
||||
quote!(parent.)
|
||||
} else {
|
||||
quote!(_self)
|
||||
};*/
|
||||
Self {
|
||||
public_component,
|
||||
current_sub_component: Some(sub_component),
|
||||
|
@ -421,6 +415,21 @@ impl<'a, T> EvaluationContext<'a, T> {
|
|||
argument_types: &[],
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_global(
|
||||
public_component: &'a super::PublicComponent,
|
||||
global: &'a super::GlobalComponent,
|
||||
generator_state: T,
|
||||
) -> Self {
|
||||
Self {
|
||||
public_component,
|
||||
current_sub_component: None,
|
||||
current_global: Some(global),
|
||||
generator_state,
|
||||
parent: None,
|
||||
argument_types: &[],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T> TypeResolutionContext for EvaluationContext<'a, T> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue