Skip to content

Commit

Permalink
Deactivate #127 bypass
Browse files Browse the repository at this point in the history
This isn't the correct solution, but the concept on this branch is better than before, and should be merged first.
  • Loading branch information
phorward committed Mar 20, 2024
1 parent 127a9cf commit 3e4baff
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 29 deletions.
5 changes: 4 additions & 1 deletion src/compiler/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ fn traverse_node_static(scope: &Scope, assign: Option<String>, node: &Dict) -> I
let emit = node["emit"].borrow();
let emit = emit.object::<Str>().unwrap().as_str();

/*
// Special case: Put a generic with an assignment name into its own parselet
if emit == "value_generic" && assign.is_some() {
// Handle anything else as an implicit parselet in its own scope
Expand All @@ -425,7 +426,9 @@ fn traverse_node_static(scope: &Scope, assign: Option<String>, node: &Dict) -> I
);
ImlValue::from(implicit_parselet)
} else if emit.starts_with("value_") {
} else
*/
if emit.starts_with("value_") {
traverse_node_value(scope, node, assign).try_resolve(scope)
} else {
// Handle anything else as an implicit parselet in its own scope
Expand Down
29 changes: 3 additions & 26 deletions src/compiler/iml/imlvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ impl ImlValue {
Self::Shared(rc) => {
match Rc::try_unwrap(rc) {
Ok(value) => {
// println!("UNCHAIN {:?}", value);
value.into_inner().resolve(scope)
}
Err(rc) => {
Expand All @@ -132,28 +131,6 @@ impl ImlValue {
*value = resolved.clone();
resolved
}

/*
let mut later = false;
match rc.try_borrow_mut() {
Ok(mut value) => {
let resolved = value.clone().resolve(scope, i + 1);
if !matches!(resolved, Self::Name { .. } | Self::Instance { .. }) {
*value = resolved.clone();
return resolved;
}
}
Err(_) => later = true,
}
if later {
ImlValue::Shared(rc).later(scope)
}
else {
ImlValue::Shared(rc)
}
*/
}
}
}
Expand Down Expand Up @@ -181,11 +158,11 @@ impl ImlValue {
// Take arguments by sequence first
let arg = if !args.is_empty() {
let arg = args.remove(0);
(arg.0, Some(arg.1.try_resolve(scope)))
(arg.0, Some(arg.1.resolve(scope)))
}
// Otherwise, take named arguments
else if let Some(narg) = nargs.shift_remove(name) {
(narg.0, Some(narg.1.try_resolve(scope)))
(narg.0, Some(narg.1.resolve(scope)))
}
// Otherwise, use default
else {
Expand Down Expand Up @@ -306,7 +283,7 @@ impl ImlValue {
true
}
}
Self::Instance { target, .. } => true,
Self::Instance { .. } => true,
_ => false,
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/parselet_generic_selfref.tok
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Assignment : @<Expression, Assignment: Assignment, ext: void> {
Expression ast("value")
}

HoldAssignment : Assignment<Int, HoldAssignment> # endless recursion!
# HoldAssignment : Assignment<Int, HoldAssignment> Empty # works!
# HoldAssignment : Assignment<Int, HoldAssignment> # fails with endless recursion!
HoldAssignment : Assignment<Int, HoldAssignment> Empty # workaround!

# ast_print(Assignment<Int>)
ast_print(HoldAssignment)
Expand Down

0 comments on commit 3e4baff

Please sign in to comment.