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>{
|
||||
Node(&'a TreeNode),
|
||||
PushFolder(std::path::Component<'a>),
|
||||
PopFolder(Option<Ref>),
|
||||
PopFolder,
|
||||
Destroy(Ref),
|
||||
}
|
||||
|
||||
#[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(){
|
||||
match instruction{
|
||||
WriteStackInstruction::PushFolder(component)=>folder.push(component),
|
||||
WriteStackInstruction::PopFolder(maybe_referent)=>{
|
||||
assert!(folder.pop(),"weirdness");
|
||||
//delete from dom
|
||||
if let Some(referent)=maybe_referent{
|
||||
dom.destroy(referent);
|
||||
}
|
||||
},
|
||||
WriteStackInstruction::PopFolder=>assert!(folder.pop(),"weirdness"),
|
||||
WriteStackInstruction::Destroy(referent)=>dom.destroy(referent),
|
||||
WriteStackInstruction::Node(node)=>{
|
||||
//properties.json to override class or other simple properties
|
||||
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(&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{
|
||||
//queue item to be deleted from dom and folder to be popped
|
||||
stack.push(WriteStackInstruction::PopFolder(match node.class{
|
||||
Class::Folder=>None,
|
||||
_=>Some(node.referent),
|
||||
}));
|
||||
stack.push(WriteStackInstruction::PopFolder);
|
||||
for referent in &node.children{
|
||||
if let Some(c)=tree_refs.get(referent){
|
||||
stack.push(WriteStackInstruction::Node(c));
|
||||
|
Loading…
x
Reference in New Issue
Block a user