From 8641bfad759e4155bf325438a4140d9b0e03d3f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Fri, 10 Dec 2021 11:06:19 +0100 Subject: [PATCH 1/4] Replace all uses of "body" with "do". --- engine/source/dmdscript/outbuffer.d | 6 +++--- engine/source/dmdscript/value.d | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/engine/source/dmdscript/outbuffer.d b/engine/source/dmdscript/outbuffer.d index 3b26129..378fd3a 100644 --- a/engine/source/dmdscript/outbuffer.d +++ b/engine/source/dmdscript/outbuffer.d @@ -75,7 +75,7 @@ class OutBuffer { assert(offset + nbytes <= data.length); } - body + do { //c.stdio.printf("OutBuffer.reserve: length = %d, offset = %d, nbytes = %d\n", data.length, offset, nbytes); if (data.length < offset + nbytes) @@ -210,7 +210,7 @@ class OutBuffer { assert((offset & (alignsize - 1)) == 0); } - body + do { uint nbytes; nbytes = offset & (alignsize - 1); @@ -261,7 +261,7 @@ class OutBuffer { assert(index <= offset); } - body + do { reserve(nbytes); diff --git a/engine/source/dmdscript/value.d b/engine/source/dmdscript/value.d index 84b04d8..03096d8 100644 --- a/engine/source/dmdscript/value.d +++ b/engine/source/dmdscript/value.d @@ -107,7 +107,7 @@ struct Value { assert(b == 1 || b == 0); } - body + do { vtype = V_BOOLEAN; dbool = b; } @@ -178,7 +178,7 @@ struct Value static void copy(Value* to, Value* from) in { } out { assert(memcmp(to, from, Value.sizeof) == 0); } - body + do { /+version(all /*UseAsm*/) From e61503c6e1c6c9ecd53ef3eab15121957d0b3f25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Fri, 10 Dec 2021 11:07:34 +0100 Subject: [PATCH 2/4] Use "destroy" instead of "delete". --- engine/source/dmdscript/darray.d | 4 ++-- engine/source/dmdscript/ddeclaredfunction.d | 2 +- engine/source/dmdscript/dfunction.d | 2 +- engine/source/dmdscript/dglobal.d | 2 +- engine/source/dmdscript/irstate.d | 2 +- engine/source/dmdscript/iterator.d | 2 +- engine/source/dmdscript/parse.d | 4 ++-- engine/source/dmdscript/program.d | 4 ++-- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/engine/source/dmdscript/darray.d b/engine/source/dmdscript/darray.d index 124e1f5..108b149 100644 --- a/engine/source/dmdscript/darray.d +++ b/engine/source/dmdscript/darray.d @@ -753,8 +753,8 @@ void *Darray_prototype_sort(Dobject pthis, CallContext *cc, Dobject othis, Value } } - delete p1; - delete p2; + destroy(p1); + destroy(p2); ret.putVobject(othis); return null; diff --git a/engine/source/dmdscript/ddeclaredfunction.d b/engine/source/dmdscript/ddeclaredfunction.d index bb7591c..e7f9af4 100644 --- a/engine/source/dmdscript/ddeclaredfunction.d +++ b/engine/source/dmdscript/ddeclaredfunction.d @@ -148,7 +148,7 @@ class DdeclaredFunction : Dfunction result = IR.call(cc, othis, fd.code, ret, locals.ptr); - delete p1; + destroy(p1); cc.callerf = callerfsave; cc.caller = callersave; diff --git a/engine/source/dmdscript/dfunction.d b/engine/source/dmdscript/dfunction.d index 16cd94d..e087342 100644 --- a/engine/source/dmdscript/dfunction.d +++ b/engine/source/dmdscript/dfunction.d @@ -224,7 +224,7 @@ void* Dfunction_prototype_apply(Dobject pthis, CallContext *cc, Dobject othis, V v = othis.Call(cc, o, ret, alist); - delete p1; + destroy(p1); } return v; } diff --git a/engine/source/dmdscript/dglobal.d b/engine/source/dmdscript/dglobal.d index dd75c39..83efcc5 100644 --- a/engine/source/dmdscript/dglobal.d +++ b/engine/source/dmdscript/dglobal.d @@ -155,7 +155,7 @@ void* Dglobal_eval(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Va assert(cc.callerothis); result = IR.call(cc, cc.callerothis, fd.code, ret, locals.ptr); if(p1) - delete p1; + destroy(p1); fd = null; // if (result) writef("result = '%s'\n", (cast(Value* )result).toString()); return result; diff --git a/engine/source/dmdscript/irstate.d b/engine/source/dmdscript/irstate.d index d7456c4..9fb275d 100644 --- a/engine/source/dmdscript/irstate.d +++ b/engine/source/dmdscript/irstate.d @@ -485,7 +485,7 @@ struct IRstate } } - delete p1; + destroy(p1); //return; // Remove all IRnop's diff --git a/engine/source/dmdscript/iterator.d b/engine/source/dmdscript/iterator.d index 123a2e6..515a361 100644 --- a/engine/source/dmdscript/iterator.d +++ b/engine/source/dmdscript/iterator.d @@ -84,7 +84,7 @@ struct Iterator { while(keyindex == keys.length) { - delete keys; + destroy(keys); o = getPrototype(o); if(!o) return null; diff --git a/engine/source/dmdscript/parse.d b/engine/source/dmdscript/parse.d index c131310..5e2d120 100644 --- a/engine/source/dmdscript/parse.d +++ b/engine/source/dmdscript/parse.d @@ -98,7 +98,7 @@ class Parser : Lexer if(p.errinfo.message) goto Lreturn; - delete p; + destroy(p); // Parse StatementList p = new Parser("anonymous", bdy, 0); @@ -119,7 +119,7 @@ class Parser : Lexer pfd = fd; perrinfo = p.errinfo; result = (p.errinfo.message != null); - delete p; + destroy(p); p = null; return result; } diff --git a/engine/source/dmdscript/program.d b/engine/source/dmdscript/program.d index 579a8bb..c072755 100644 --- a/engine/source/dmdscript/program.d +++ b/engine/source/dmdscript/program.d @@ -227,13 +227,13 @@ class Program result.getErrInfo(cc, &errinfo, cc.linnum); cc.linnum = 0; - delete p1; + destroy(p1); throw new ScriptException(&errinfo); } //writef("-Program.execute()\n"); - delete p1; + destroy(p1); } void toBuffer(ref tchar[] buf) From 8193e0d03f386421178445df4ad240369f826c7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Fri, 10 Dec 2021 11:09:54 +0100 Subject: [PATCH 3/4] Replace opIn_r with opBinaryRight. --- engine/source/dmdscript/RandAA.d | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/engine/source/dmdscript/RandAA.d b/engine/source/dmdscript/RandAA.d index e3849a8..82d6a03 100644 --- a/engine/source/dmdscript/RandAA.d +++ b/engine/source/dmdscript/RandAA.d @@ -80,7 +80,8 @@ struct aard (K, V, bool useRandom = false) assert(0); } - V* opIn_r(K k) + + V* opBinaryRight(string op : "in")(K k) { if(imp_ is null) return null; @@ -153,7 +154,7 @@ struct aard (K, V, bool useRandom = false) V get(K k) { - V* p = opIn_r(k); + V* p = k in this; if(p !is null) { return *p; @@ -165,7 +166,7 @@ struct aard (K, V, bool useRandom = false) { if(imp_ !is null) { - V* p = opIn_r(k); + V* p = k in this; if(p !is null) { val = *p; @@ -728,7 +729,7 @@ public: } } /**Returns null if index is not found.*/ - V* opIn_r(K index) + V* opBinaryRight(string op : "in")(K index) { size_t i = findExisting(index); if(i == size_t.max) From 931364779d16161dfd05bfd0740a01e2fda0bc8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Fri, 10 Dec 2021 11:11:57 +0100 Subject: [PATCH 4/4] Fix printf argument size on x64. --- engine/source/dmdscript/irstate.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine/source/dmdscript/irstate.d b/engine/source/dmdscript/irstate.d index 9fb275d..6e9fa50 100644 --- a/engine/source/dmdscript/irstate.d +++ b/engine/source/dmdscript/irstate.d @@ -62,7 +62,7 @@ struct IRstate { assert(codebuf.offset <= codebuf.data.length); if(codebuf.data.length > codebuf.data.capacity) - printf("ptr %p, length %d, capacity %d\n", codebuf.data.ptr, codebuf.data.length, core.memory.GC.sizeOf(codebuf.data.ptr)); + printf("ptr %p, length %d, capacity %d\n", codebuf.data.ptr, cast(uint)codebuf.data.length, cast(uint)core.memory.GC.sizeOf(codebuf.data.ptr)); assert(codebuf.data.length <= codebuf.data.capacity); for(uint u = 0; u < codebuf.offset; ) {