WriteStackInstruction::Destroy
This commit is contained in:
parent
dc3aa35805
commit
42d5efcea0
23
src/main.rs
23
src/main.rs
@ -261,7 +261,8 @@ enum TrimStackInstruction{
|
|||||||
enum WriteStackInstruction<'a>{
|
enum WriteStackInstruction<'a>{
|
||||||
Node(&'a TreeNode),
|
Node(&'a TreeNode),
|
||||||
PushFolder(std::path::Component<'a>),
|
PushFolder(std::path::Component<'a>),
|
||||||
PopFolder(Option<Ref>),
|
PopFolder,
|
||||||
|
Destroy(Ref),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default,serde::Deserialize,serde::Serialize)]
|
#[derive(Default,serde::Deserialize,serde::Serialize)]
|
||||||
@ -403,13 +404,8 @@ fn decompile(input_file:std::path::PathBuf,output_folder:std::path::PathBuf)->AR
|
|||||||
while let Some(instruction)=stack.pop(){
|
while let Some(instruction)=stack.pop(){
|
||||||
match instruction{
|
match instruction{
|
||||||
WriteStackInstruction::PushFolder(component)=>folder.push(component),
|
WriteStackInstruction::PushFolder(component)=>folder.push(component),
|
||||||
WriteStackInstruction::PopFolder(maybe_referent)=>{
|
WriteStackInstruction::PopFolder=>assert!(folder.pop(),"weirdness"),
|
||||||
assert!(folder.pop(),"weirdness");
|
WriteStackInstruction::Destroy(referent)=>dom.destroy(referent),
|
||||||
//delete from dom
|
|
||||||
if let Some(referent)=maybe_referent{
|
|
||||||
dom.destroy(referent);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
WriteStackInstruction::Node(node)=>{
|
WriteStackInstruction::Node(node)=>{
|
||||||
//properties.json to override class or other simple properties
|
//properties.json to override class or other simple properties
|
||||||
let mut properties=PropertiesOverride::default();
|
let mut properties=PropertiesOverride::default();
|
||||||
@ -445,12 +441,13 @@ fn decompile(input_file:std::path::PathBuf,output_folder:std::path::PathBuf)->AR
|
|||||||
//write item
|
//write item
|
||||||
write_item(&dom,folder.clone(),node)?;
|
write_item(&dom,folder.clone(),node)?;
|
||||||
}
|
}
|
||||||
|
//queue item to be deleted from dom after child objects are handled (stack is popped from the back)
|
||||||
|
match node.class{
|
||||||
|
Class::Folder=>(),
|
||||||
|
_=>stack.push(WriteStackInstruction::Destroy(node.referent)),
|
||||||
|
}
|
||||||
if has_children{
|
if has_children{
|
||||||
//queue item to be deleted from dom and folder to be popped
|
stack.push(WriteStackInstruction::PopFolder);
|
||||||
stack.push(WriteStackInstruction::PopFolder(match node.class{
|
|
||||||
Class::Folder=>None,
|
|
||||||
_=>Some(node.referent),
|
|
||||||
}));
|
|
||||||
for referent in &node.children{
|
for referent in &node.children{
|
||||||
if let Some(c)=tree_refs.get(referent){
|
if let Some(c)=tree_refs.get(referent){
|
||||||
stack.push(WriteStackInstruction::Node(c));
|
stack.push(WriteStackInstruction::Node(c));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user