From e991753f1da39cdd1eae14b8f4f587b76a5d1b11 Mon Sep 17 00:00:00 2001 From: nkorslund Date: Wed, 13 May 2009 10:56:35 +0000 Subject: [PATCH] Bugfixing git-svn-id: https://openmw.svn.sourceforge.net/svnroot/openmw/trunk@109 ea6a568a-9f4f-0410-981a-c910a81bb256 --- monster/compiler/functions.d | 16 ++++++++++++++-- monster/compiler/scopes.d | 6 +++++- monster/compiler/variables.d | 2 +- monster/modules/console.d | 2 +- mscripts/sound/music.mn | 8 ++++---- 5 files changed, 25 insertions(+), 9 deletions(-) diff --git a/monster/compiler/functions.d b/monster/compiler/functions.d index 944fca215..63bb47f24 100644 --- a/monster/compiler/functions.d +++ b/monster/compiler/functions.d @@ -943,6 +943,8 @@ class FunctionCallExpr : Expression bool isVararg; + bool fResolved; // True if fname is already resolved + // Read a function parameter list (a,b,v1=c,v2=d,...). The function // expects that you have already removed the initial left paren '(' // token. @@ -1044,6 +1046,7 @@ class FunctionCallExpr : Expression getParamsConsole(toks, params, named); else getParams(toks, params, named); + fResolved = console; } /* Might be used for D-like implicit function calling, eg. someFunc; @@ -1068,7 +1071,9 @@ class FunctionCallExpr : Expression void resolve(Scope sc) { // Resolve the function lookup first - fname.resolve(sc); + if(!fResolved) + fname.resolve(sc); + assert(fname.type !is null); // Is the 'function' really a type name? if(fname.type.isMeta) @@ -1154,8 +1159,15 @@ class FunctionCallExpr : Expression // Non-vararg case. Non-vararg functions must cover at least all // the non-optional function parameters. - // Make the coverage list of all the parameters. + int parNum = fd.params.length; + + // Sanity check on the parameter number + if(params.length > parNum) + fail(format("Too many parameters to function %s(): expected %s, got %s", + name, parNum, params.length), fname.loc); + + // Make the coverage list of all the parameters. coverage = new Expression[parNum]; // Mark all the parameters which are present diff --git a/monster/compiler/scopes.d b/monster/compiler/scopes.d index 743be7433..c597c459c 100644 --- a/monster/compiler/scopes.d +++ b/monster/compiler/scopes.d @@ -377,7 +377,11 @@ abstract class Scope } // Add an import to this scope - void registerImport(ImportHolder s) { importList ~= s; } + void registerImport(ImportHolder s) + { + //writefln("Registering import %s in scope %s", s, this); + importList ~= s; + } // More user-friendly version for API-defined // imports. Eg. global.registerImport(myclass) -> makes myclass diff --git a/monster/compiler/variables.d b/monster/compiler/variables.d index f4df1dffc..adb0e5edb 100644 --- a/monster/compiler/variables.d +++ b/monster/compiler/variables.d @@ -749,7 +749,7 @@ class MemberExpr : Expression fail(name.str ~ " is not a member of " ~ ownerType.toString, loc); else - fail("Undefined identifier "~name.str, name.loc); + fail("Unknown identifier "~name.str, name.loc); } } diff --git a/monster/modules/console.d b/monster/modules/console.d index 08f224888..de1af429f 100644 --- a/monster/modules/console.d +++ b/monster/modules/console.d @@ -107,7 +107,7 @@ class Console obj = Function.getIntMO(); // Next set up the function and the scope - fn.name.str = "console"; + fn.name.str = "__console"; fn.owner = obj.cls; sc = new FuncScope(obj.cls.sc, &fn); diff --git a/mscripts/sound/music.mn b/mscripts/sound/music.mn index c7cf0a92d..b09fd97c6 100644 --- a/mscripts/sound/music.mn +++ b/mscripts/sound/music.mn @@ -36,14 +36,14 @@ toggle() { if(isBattle) { - print("Switching to normal music"); + io.print("Switching to normal music"); battle.pause(); jukebox.resume(); isBattle = false; } else { - print("Switching to battle music"); + io.print("Switching to battle music"); jukebox.pause(); battle.resume(); isBattle = true; @@ -56,14 +56,14 @@ toggleMute() { jukebox.updateVolume(0); battle.updateVolume(0); - print("Muted"); + io.print("Muted"); isMuted = true; } else { updateVolume(); isMuted = false; - print("Mute off"); + io.print("Mute off"); } }