From be5424a2036316e7937234877041de432c441fe6 Mon Sep 17 00:00:00 2001 From: otya128 Date: Sun, 9 Jul 2017 23:32:36 +0900 Subject: [PATCH] Implement CHKLABEL(label,global) --- SMILEBASIC/VM.d | 11 ++++++++--- SMILEBASIC/builtinfunctions.d | 5 +++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/SMILEBASIC/VM.d b/SMILEBASIC/VM.d index a4e2f0c..d278749 100644 --- a/SMILEBASIC/VM.d +++ b/SMILEBASIC/VM.d @@ -438,7 +438,7 @@ class VM return true; return false; } - bool chklabel(wstring label) + bool chklabel(wstring label, bool global) { auto name = parse(label); VMSlot slot; @@ -454,10 +454,15 @@ class VM { slot = currentSlot; } + if (currentFunction) + { + if (name.name in currentFunction.label) + return true; + if (!global) + return false; + } if (name.name in slot.globalLabel) return true; - if (currentFunction && name.name in currentFunction.label) - return true; return false; } bool chkvar(wstring var) diff --git a/SMILEBASIC/builtinfunctions.d b/SMILEBASIC/builtinfunctions.d index a02f967..2fdcc33 100644 --- a/SMILEBASIC/builtinfunctions.d +++ b/SMILEBASIC/builtinfunctions.d @@ -3079,10 +3079,11 @@ class BuiltinFunction func = func.toUpper; return p.vm.chkcall(func); } - static int CHKLABEL(PetitComputer p, wstring label) + static int CHKLABEL(PetitComputer p, wstring label, DefaultValue!(int, false) global) { label = label.toUpper; - return p.vm.chklabel(label); + global.setDefaultValue(0); + return p.vm.chklabel(label, cast(bool)global); } static int CHKVAR(PetitComputer p, wstring var) {