* net/loveruby/cflat/compiler/CodeGenerator.java (DereferenceNode): reduce compileLHS call.

* test/pointer4.cb: test derefering AddressNode.
* test/test.sh: run it.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3797 1b9489fe-b721-0410-924e-b54b9192deb8
This commit is contained in:
Minero Aoki 2008-01-04 22:33:14 +00:00
parent f327f73a0e
commit 6e3f520a14
4 changed files with 20 additions and 2 deletions

View File

@ -1,3 +1,12 @@
Sat Jan 5 07:33:06 2008 Minero Aoki <aamine@loveruby.net>
* net/loveruby/cflat/compiler/CodeGenerator.java
(DereferenceNode): reduce compileLHS call.
* test/pointer4.cb: test derefering AddressNode.
* test/test.sh: run it.
Sat Jan 5 07:21:18 2008 Minero Aoki <aamine@loveruby.net>
* net/loveruby/cflat/compiler/CodeGenerator.java (compileLHS):

View File

@ -414,8 +414,7 @@ static public void p(String s) { System.err.println(s); }
}
public void visit(DereferenceNode node) {
compileLHS(node.expr());
as.movq(addr(PTRREG), reg("ax"));
compile(node.expr());
loadWords(node.type(), addr("ax"), "ax");
}

9
test/pointer4.cb Normal file
View File

@ -0,0 +1,9 @@
import stdio;
int
main(int argc, char** argv)
{
int i = 777;
printf("%d\n", *&i);
return 0;
}

View File

@ -167,6 +167,7 @@ assert_out "1;2;1;1;3;4;5;6;OK" ./usertype
assert_out "5;5" ./pointer
assert_out "777" ./pointer2
assert_out "1;777;3;4;1;777;3;4" ./pointer3
assert_out "777" ./pointer4
assert_out "1;2;3;4;5;6" ./ptrmemb
assert_compile_error deref-semcheck1.cb
assert_compile_error deref-semcheck2.cb