diff --git a/src/hx/cppia/Cppia.cpp b/src/hx/cppia/Cppia.cpp index f9c6cefc0..4ef92a0a7 100644 --- a/src/hx/cppia/Cppia.cpp +++ b/src/hx/cppia/Cppia.cpp @@ -4277,7 +4277,7 @@ struct MemReferenceCrement : public CppiaExpr break; case locThis: - ioPtr = sJitThis.star() + offset; + ioPtr = JitThisPos(offset); break; case locAbsolute: diff --git a/test/cppia/Client.hx b/test/cppia/Client.hx index af77a301f..7242f9a21 100644 --- a/test/cppia/Client.hx +++ b/test/cppia/Client.hx @@ -35,7 +35,8 @@ class Client { Common.CLIENT_CASES = [ new TestClient(), new LocalFunctionExceptions(), - new ReturnExpressions() + new ReturnExpressions(), + new MemberCrements() ]; } } diff --git a/test/cppia/cases/client/MemberCrements.hx b/test/cppia/cases/client/MemberCrements.hx new file mode 100644 index 000000000..b2f529d6c --- /dev/null +++ b/test/cppia/cases/client/MemberCrements.hx @@ -0,0 +1,55 @@ +package cases.client; + +private class Counter { + public var n = 0; + + public function new() {} + + // Each of these only touches `this` through the increment/decrement itself + + public function postInc() { + n++; + } + + public function preInc() { + ++n; + } + + public function postDec() { + n--; + } + + public function preDec() { + --n; + } + + public function postIncValue() { + return n++; + } + + public function preIncValue() { + return ++n; + } +} + +class MemberCrements extends Test { + function testVoid() { + final c = new Counter(); + c.postInc(); + Assert.equals(1, c.n); + c.preInc(); + Assert.equals(2, c.n); + c.postDec(); + Assert.equals(1, c.n); + c.preDec(); + Assert.equals(0, c.n); + } + + function testValue() { + final c = new Counter(); + Assert.equals(0, c.postIncValue()); + Assert.equals(1, c.n); + Assert.equals(2, c.preIncValue()); + Assert.equals(2, c.n); + } +}