Skip to content

Commit eb7d55e

Browse files
committed
can be builtin
1 parent 66c3c90 commit eb7d55e

2 files changed

Lines changed: 34 additions & 14 deletions

File tree

src/dreamchecker/lib.rs

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -402,17 +402,19 @@ struct ProcDirective<'o> {
402402
can_be_disabled: bool,
403403
set_at_definition: bool,
404404
can_be_global: bool,
405+
can_be_builtin: bool,
405406
directive_string: &'static str,
406407
}
407408

408409
impl<'o> ProcDirective<'o> {
409-
pub fn new(directive_string: &'static str, can_be_disabled: bool, set_at_definition: bool, can_be_global: bool) -> ProcDirective<'o> {
410+
pub fn new(directive_string: &'static str, can_be_disabled: bool, set_at_definition: bool, can_be_global: bool, can_be_builtin: bool) -> ProcDirective<'o> {
410411
ProcDirective {
411412
directive: Default::default(),
412413
directive_string,
413414
can_be_disabled,
414415
set_at_definition,
415416
can_be_global,
417+
can_be_builtin,
416418
}
417419
}
418420

@@ -584,14 +586,14 @@ impl<'o> AnalyzeObjectTree<'o> {
584586
context,
585587
objtree,
586588
return_type,
587-
must_call_parent: ProcDirective::new("SpacemanDMM_should_call_parent", true, false, false),
588-
must_not_override: ProcDirective::new("SpacemanDMM_should_not_override", false, false, false),
589-
private: ProcDirective::new("SpacemanDMM_private_proc", false, true, false),
590-
protected: ProcDirective::new("SpacemanDMM_protected_proc", false, true, false),
591-
must_not_sleep: ProcDirective::new("SpacemanDMM_should_not_sleep", false, true, true),
592-
sleep_exempt: ProcDirective::new("SpacemanDMM_allowed_to_sleep", false, true, true),
593-
must_be_pure: ProcDirective::new("SpacemanDMM_should_be_pure", false, true, true),
594-
can_be_redefined: ProcDirective::new("SpacemanDMM_can_be_redefined", false, false, false),
589+
must_call_parent: ProcDirective::new("SpacemanDMM_should_call_parent", true, false, false, true),
590+
must_not_override: ProcDirective::new("SpacemanDMM_should_not_override", false, false, false, false),
591+
private: ProcDirective::new("SpacemanDMM_private_proc", false, true, false, false),
592+
protected: ProcDirective::new("SpacemanDMM_protected_proc", false, true, false, false),
593+
must_not_sleep: ProcDirective::new("SpacemanDMM_should_not_sleep", false, true, true, true),
594+
sleep_exempt: ProcDirective::new("SpacemanDMM_allowed_to_sleep", false, true, true, true),
595+
must_be_pure: ProcDirective::new("SpacemanDMM_should_be_pure", false, true, true, true),
596+
can_be_redefined: ProcDirective::new("SpacemanDMM_can_be_redefined", false, false, false, false),
595597
used_kwargs: Default::default(),
596598
call_tree: Default::default(),
597599
sleeping_procs: Default::default(),
@@ -632,11 +634,13 @@ impl<'o> AnalyzeObjectTree<'o> {
632634

633635
if procdirective.set_at_definition {
634636
if let Some(procdef) = &mut proc.get_declaration() {
635-
if procdef.location != proc.get().location {
636-
error(location, format!("Can't define procs {} outside their initial definition", directive))
637-
.set_severity(Severity::Warning)
638-
.register(self.context);
639-
return
637+
if !(procdef.location.is_builtins() && procdirective.can_be_builtin) {
638+
if procdef.location != proc.get().location {
639+
error(location, format!("Can't define procs {} outside their initial definition", directive))
640+
.set_severity(Severity::Warning)
641+
.register(self.context);
642+
return
643+
}
640644
}
641645
}
642646
}

src/dreamchecker/tests/directive_tests.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,19 @@ fn no_can_be_redefined() {
108108
"##.trim();
109109
check_errors_match(code, NO_CAN_BE_REDEFINED_ERRORS);
110110
}
111+
112+
pub const BUILT_IN_SLEEP: &[(u32, u16, &str)] = &[
113+
(4, 17, "/mob/living/proc/Move sets SpacemanDMM_should_not_sleep but calls blocking built-in(s)"),
114+
];
115+
116+
#[test]
117+
fn built_in_sleep() {
118+
let code = r##"
119+
/mob/Move()
120+
set SpacemanDMM_should_not_sleep = TRUE
121+
122+
/mob/living/Move()
123+
sleep(1)
124+
"##.trim();
125+
check_errors_match(code, BUILT_IN_SLEEP);
126+
}

0 commit comments

Comments
 (0)