mirror of
https://github.com/SpaceManiac/SpacemanDMM.git
synced 2025-12-23 05:36:47 +00:00
Store only presence/absence of code rather than builtin/invalid flag
This commit is contained in:
parent
3682e04389
commit
f2345b6c1f
4 changed files with 13 additions and 34 deletions
|
|
@ -57,7 +57,7 @@ impl ReferencesTable {
|
|||
}
|
||||
|
||||
for proc in ty.iter_self_procs() {
|
||||
if let dm::objtree::Code::Present(ref code) = proc.code {
|
||||
if let Some(ref code) = proc.code {
|
||||
WalkProc::from_proc(&mut tab, objtree, proc).run(proc, code);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
extern crate dreammaker as dm;
|
||||
use dm::{Context, DMError, Location, Severity};
|
||||
use dm::objtree::{ObjectTree, TypeRef, ProcRef, Code};
|
||||
use dm::objtree::{ObjectTree, TypeRef, ProcRef};
|
||||
use dm::constants::{Constant, ConstFn};
|
||||
use dm::ast::*;
|
||||
|
||||
|
|
@ -330,15 +330,11 @@ fn run_inner(context: &Context, objtree: &ObjectTree, cli: bool) {
|
|||
|
||||
let mut analyzer = AnalyzeObjectTree::new(context, objtree);
|
||||
|
||||
let mut present = 0;
|
||||
let mut invalid = 0;
|
||||
let mut builtin = 0;
|
||||
|
||||
cli_println!("============================================================");
|
||||
cli_println!("Gathering proc settings...\n");
|
||||
objtree.root().recurse(&mut |ty| {
|
||||
for proc in ty.iter_self_procs() {
|
||||
if let Code::Present(ref code) = proc.get().code {
|
||||
if let Some(ref code) = proc.get().code {
|
||||
analyzer.gather_settings(proc, code);
|
||||
}
|
||||
}
|
||||
|
|
@ -348,20 +344,12 @@ fn run_inner(context: &Context, objtree: &ObjectTree, cli: bool) {
|
|||
cli_println!("Analyzing proc bodies...\n");
|
||||
objtree.root().recurse(&mut |ty| {
|
||||
for proc in ty.iter_self_procs() {
|
||||
match proc.get().code {
|
||||
Code::Present(ref code) => {
|
||||
present += 1;
|
||||
analyzer.check_proc(proc, code);
|
||||
}
|
||||
Code::Invalid => invalid += 1,
|
||||
Code::Builtin => builtin += 1,
|
||||
Code::Disabled => panic!("proc parsing was enabled, but also disabled. this is a bug"),
|
||||
if let Some(ref code) = proc.get().code {
|
||||
analyzer.check_proc(proc, code);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cli_println!("Procs analyzed: {}. Errored: {}. Builtins: {}.\n", present, invalid, builtin);
|
||||
|
||||
cli_println!("============================================================");
|
||||
cli_println!("Analyzing proc override validity...\n");
|
||||
objtree.root().recurse(&mut |ty| {
|
||||
|
|
|
|||
|
|
@ -85,15 +85,7 @@ pub struct ProcValue {
|
|||
pub location: Location,
|
||||
pub parameters: Vec<Parameter>,
|
||||
pub docs: DocCollection,
|
||||
pub code: Code,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum Code {
|
||||
Present(Block),
|
||||
Invalid,
|
||||
Builtin,
|
||||
Disabled,
|
||||
pub code: Option<Block>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
|
|
@ -742,7 +734,7 @@ impl ObjectTree {
|
|||
for node in self.graph.iter_mut() {
|
||||
for (_, typroc) in node.procs.iter_mut() {
|
||||
for proc in typroc.value.iter_mut() {
|
||||
proc.code = Code::Disabled;
|
||||
proc.code = None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1102,7 +1094,7 @@ impl ObjectTreeBuilder {
|
|||
name: &str,
|
||||
declaration: Option<ProcDeclKind>,
|
||||
parameters: Vec<Parameter>,
|
||||
code: Code,
|
||||
code: Option<Block>,
|
||||
) -> Result<(usize, &mut ProcValue), DMError> {
|
||||
let node = &mut self.inner.graph[parent.index()];
|
||||
let proc = node.procs.entry(name.to_owned()).or_insert_with(Default::default);
|
||||
|
|
@ -1213,7 +1205,7 @@ impl ObjectTreeBuilder {
|
|||
elems.iter().copied(),
|
||||
elems.len() + 1,
|
||||
params.iter().copied().map(|param| Parameter { name: param.into(), .. Default::default() }).collect(),
|
||||
Code::Builtin,
|
||||
None,
|
||||
).unwrap().1
|
||||
}
|
||||
|
||||
|
|
@ -1225,7 +1217,7 @@ impl ObjectTreeBuilder {
|
|||
mut path: I,
|
||||
len: usize,
|
||||
parameters: Vec<Parameter>,
|
||||
code: Code,
|
||||
code: Option<Block>,
|
||||
) -> Result<(usize, &mut ProcValue), DMError> {
|
||||
let (parent, mut proc_name) = self.get_from_path(location, &mut path, len)?;
|
||||
let mut declaration = None;
|
||||
|
|
|
|||
|
|
@ -948,7 +948,6 @@ impl<'ctx, 'an, 'inp> Parser<'ctx, 'an, 'inp> {
|
|||
fn proc_params_and_body(&mut self, current: NodeIndex, proc_kind: Option<ProcDeclKind>, name: &str, entry_start: Location, absolute: bool) -> Status<()> {
|
||||
use super::lexer::Token::*;
|
||||
use super::lexer::Punctuation::*;
|
||||
use super::objtree::Code;
|
||||
|
||||
leading!(self.exact(Punct(LParen)));
|
||||
|
||||
|
|
@ -995,14 +994,14 @@ impl<'ctx, 'an, 'inp> Parser<'ctx, 'an, 'inp> {
|
|||
match result {
|
||||
Err(err) => {
|
||||
self.context.register_error(err);
|
||||
Code::Invalid
|
||||
None
|
||||
},
|
||||
Ok(code) => {
|
||||
Code::Present(code)
|
||||
Some(code)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Code::Disabled
|
||||
None
|
||||
};
|
||||
|
||||
match self.tree.register_proc(self.context, location, current, name, proc_kind, parameters, code) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue