compile
This commit is contained in:
parent
43b5dfd0d5
commit
48c2a010d8
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -1356,6 +1356,7 @@ dependencies = [
|
||||
name = "rox_compiler"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"lazy-regex",
|
||||
"rbx_dom_weak",
|
||||
"rbx_xml",
|
||||
|
@ -4,6 +4,7 @@ version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
futures = "0.3.30"
|
||||
lazy-regex = "3.1.0"
|
||||
rbx_dom_weak = "2.7.0"
|
||||
rbx_xml = "0.13.3"
|
||||
|
@ -394,6 +394,10 @@ enum TooComplicated<T>{
|
||||
Skip,
|
||||
}
|
||||
|
||||
enum CompileError{
|
||||
NullChildRef,
|
||||
}
|
||||
|
||||
async fn compile(config:CompileConfig,&mut dom:rbx_dom_weak::WeakDom)->Result<(),CompileError>{
|
||||
//add in scripts and models
|
||||
let mut folder=config.input_folder.clone();
|
||||
@ -402,7 +406,7 @@ async fn compile(config:CompileConfig,&mut dom:rbx_dom_weak::WeakDom)->Result<()
|
||||
match instruction{
|
||||
CompileStackInstruction::TraverseReferent(item_ref,blacklist)=>{
|
||||
let sans={
|
||||
let item=dom.get_by_ref(item_ref).ok_or(anyhow::Error::msg("null child ref"))?;
|
||||
let item=dom.get_by_ref(item_ref).ok_or(CompileError::NullChildRef)?;
|
||||
sanitize(item.name.as_str()).to_string()
|
||||
};
|
||||
folder.push(sans.as_str());
|
||||
@ -410,14 +414,14 @@ async fn compile(config:CompileConfig,&mut dom:rbx_dom_weak::WeakDom)->Result<()
|
||||
//check if a folder exists with item.name
|
||||
if let Ok(dir)=tokio::fs::read_dir(folder.as_path()).await{
|
||||
let mut exist_names:std::collections::HashSet<String>={
|
||||
let item=dom.get_by_ref(item_ref).ok_or(anyhow::Error::msg("null child ref"))?;
|
||||
let item=dom.get_by_ref(item_ref).ok_or(CompileError::NullChildRef)?;
|
||||
//push existing dom children objects onto stack (unrelated to exist_names)
|
||||
stack.extend(item.children().into_iter().map(|&referent|CompileStackInstruction::TraverseReferent(referent,None)));
|
||||
//get names of existing objects
|
||||
item.children().into_iter().map(|&child_ref|{
|
||||
let child=dom.get_by_ref(child_ref).ok_or(anyhow::Error::msg("null child ref"))?;
|
||||
Ok::<_,anyhow::Error>(sanitize(child.name.as_str()).to_string())
|
||||
}).collect::<AResult<_>>()?
|
||||
let child=dom.get_by_ref(child_ref).ok_or(CompileError::NullChildRef)?;
|
||||
Ok::<_,CompileError>(sanitize(child.name.as_str()).to_string())
|
||||
}).collect::<Result<_,CompileError>>()?
|
||||
};
|
||||
if let Some(dont)=blacklist{
|
||||
exist_names.insert(dont);
|
||||
|
Loading…
Reference in New Issue
Block a user