From 2f07faf00eaafac5d00b8b95870aaf42b3fb56b4 Mon Sep 17 00:00:00 2001 From: nkorslund Date: Sun, 16 Nov 2008 18:51:26 +0000 Subject: [PATCH] Updated monster to 0.10 git-svn-id: https://openmw.svn.sourceforge.net/svnroot/openmw/trunk@69 ea6a568a-9f4f-0410-981a-c910a81bb256 --- monster/compiler/tokenizer.d | 10 +++++++++- monster/{conv.sh => update.sh} | 5 +++++ monster/util/string.d | 2 ++ monster/vm/arrays.d | 2 ++ monster/vm/mclass.d | 11 ++++------- monster/vm/stack.d | 9 +++++---- monster/vm/vm.d | 8 ++++---- 7 files changed, 31 insertions(+), 16 deletions(-) rename monster/{conv.sh => update.sh} (59%) diff --git a/monster/compiler/tokenizer.d b/monster/compiler/tokenizer.d index cdc36903da..b7d2dffa63 100644 --- a/monster/compiler/tokenizer.d +++ b/monster/compiler/tokenizer.d @@ -107,7 +107,7 @@ enum TT Switch, Select, State, - Singleton, + Singleton, Clone, This, New, Static, Const, Out, Ref, Abstract, Idle, Public, Private, Protected, True, False, Native, Null, Goto, Halt, Auto, Var, In, @@ -218,6 +218,7 @@ const char[][] tokenList = TT.State : "state", TT.Typeof : "typeof", TT.Singleton : "singleton", + TT.Singleton : "clone", TT.Static : "static", TT.Const : "const", TT.Abstract : "abstract", @@ -361,6 +362,13 @@ class StreamTokenizer assert(line.length > 0); + // Skip the first line if it begins with #! + if(lineNum == 1 && line.begins("#!")) + { + line = null; + goto restart; + } + if(mode == Block) { int index = line.find("*/"); diff --git a/monster/conv.sh b/monster/update.sh similarity index 59% rename from monster/conv.sh rename to monster/update.sh index da9646624e..c814452640 100755 --- a/monster/conv.sh +++ b/monster/update.sh @@ -1,6 +1,11 @@ #!/bin/bash +svn export ../../../monster/trunk/monster/ . --force +rm -r minibos vm/c_api.d + for a in $(find -iname \*.d); do cat "$a" | sed s/monster.minibos./std./g > "$a"_new mv "$a"_new "$a" done + +svn st diff --git a/monster/util/string.d b/monster/util/string.d index 4535c59ef0..999f200e31 100644 --- a/monster/util/string.d +++ b/monster/util/string.d @@ -23,6 +23,8 @@ */ module monster.util.string; + +import std.utf; import std.string; // These functions check whether a string begins or ends with a diff --git a/monster/vm/arrays.d b/monster/vm/arrays.d index ff18656bd0..b0c938e194 100644 --- a/monster/vm/arrays.d +++ b/monster/vm/arrays.d @@ -26,6 +26,7 @@ import monster.vm.stack; import monster.util.freelist; import monster.util.flags; import monster.vm.error; +import monster.vm.mobject; import std.string; import std.uni; @@ -152,6 +153,7 @@ struct Arrays alias createT!(double) create; alias createT!(dchar) create; alias createT!(AIndex) create; + alias createT!(MIndex) create; ArrayRef *create(char[] arg) { return create(toUTF32(arg)); } diff --git a/monster/vm/mclass.d b/monster/vm/mclass.d index 5a1e7846fb..4c3e5e4f91 100644 --- a/monster/vm/mclass.d +++ b/monster/vm/mclass.d @@ -97,7 +97,7 @@ final class MonsterClass // TODO: These will probably be moved elsewhere. // Path to search for script files. Extremely simple at the moment. - static char[][] includes = [""]; + private static char[][] includes = [""]; static void addPath(char[] path) { @@ -216,7 +216,7 @@ final class MonsterClass // By default we leave the loadType at None. This leaves us open to // define the class later. Calling eg. setName will define the class - // as a manual class. + // as a manual class. This isn't supported yet though. this() {} this(MC type, char[] name1, char[] name2 = "", bool usePath = true) @@ -266,9 +266,6 @@ final class MonsterClass this(char[] nam1, char[] nam2 = "", bool usePath=true) { this(MC.File, nam1, nam2, usePath); } - // Used when binding to classes in other languages. - this(MClass cpp, char* nam1, char* nam2 = null) { assert(0); } - /******************************************************* * * @@ -324,7 +321,7 @@ final class MonsterClass { bind_locate(name, FuncType.NativeDFunc).natFunc_fn = nf; } // Used for C functions - void bind(char[] name, c_callback nf) + void bind_c(char[] name, c_callback nf) { bind_locate(name, FuncType.NativeCFunc).natFunc_c = nf; } // Bind an idle function @@ -390,7 +387,7 @@ final class MonsterClass fn_const = nf; } - void bindConst(c_callback nf) + void bindConst_c(c_callback nf) { assert(constType == FuncType.Native, "Cannot set native constructor for " ~ toString ~ ": already set"); diff --git a/monster/vm/stack.d b/monster/vm/stack.d index 61ea3ee986..9c7c8f47e2 100644 --- a/monster/vm/stack.d +++ b/monster/vm/stack.d @@ -256,6 +256,7 @@ struct CodeStack void pushFArray(float[] str) { pushArray(arrays.create(str)); } void pushDArray(double[] str) { pushArray(arrays.create(str)); } void pushAArray(AIndex[] str) { pushArray(arrays.create(str)); } + void pushMArray(AIndex[] str) { pushArray(arrays.create(str)); } alias pushCArray pushArray, pushString; alias pushIArray pushArray; @@ -278,7 +279,6 @@ struct CodeStack void pushArray(int[] str, int size) { pushArray(arrays.create(str, size)); } - // Various convenient conversion templates. These will be inlined, // so don't worry :) The *4() functions are for types that are 4 // bytes long. These are mostly intended for use in native @@ -321,9 +321,9 @@ struct CodeStack // Template conversions - alias push4!(MIndex) pushIndex; - alias pop4!(MIndex) popIndex; - alias get4!(MIndex) getIndex; + alias push4!(MIndex) pushMIndex; + alias pop4!(MIndex) popMIndex; + alias get4!(MIndex) getMIndex; alias push4!(AIndex) pushAIndex; alias pop4!(AIndex) popAIndex; @@ -391,6 +391,7 @@ struct CodeStack writefln(); } + private: void overflow(char[] func) { char[] res; diff --git a/monster/vm/vm.d b/monster/vm/vm.d index 8444406c76..6c5e490111 100644 --- a/monster/vm/vm.d +++ b/monster/vm/vm.d @@ -304,7 +304,7 @@ struct CodeThread // reference is on the stack. if(type == PT.FarDataOffs) { - int clsIndex = stack.popIndex(); + int clsIndex = stack.popInt(); // Get the object reference from the stack MonsterObject *tmp = stack.popObject(); @@ -321,7 +321,7 @@ struct CodeThread { assert(index==0); // Array indices are on the stack, not in the opcode. - index = stack.popIndex(); + index = stack.popInt(); ArrayRef *arf = stack.popArray(); assert(!arf.isNull); if(arf.isConst) @@ -537,7 +537,7 @@ struct CodeThread case BC.PushThis: // Push the index of this object. - stack.pushIndex(obj.getIndex()); + stack.pushObject(obj); break; case BC.Pop: stack.popInt(); break; @@ -957,7 +957,7 @@ struct CodeThread case BC.CastO2S: { - MIndex idx = stack.popIndex(); + MIndex idx = stack.popMIndex(); if(idx != 0) stack.pushArray(format("%s#%s", getMObject(idx).cls.getName, cast(int)idx));