mirror of https://github.com/aamine/cbc
* net/loveruby/cflat/asm/Reference.java: new constructor Reference(String) for instance.
* net/loveruby/cflat/ast/AST.java: #declarations should include vardecls. * net/loveruby/cflat/ast/UndefinedVariable.java: #address should return variable symbol. * net/loveruby/cflat/compiler/LocalReferenceResolver.java: declarations may include variable declaration. * test/vardecl.cb: test reference of declared external variable. git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3884 1b9489fe-b721-0410-924e-b54b9192deb8
This commit is contained in:
parent
23ada77110
commit
0af37dc9cf
16
ChangeLog
16
ChangeLog
|
@ -1,3 +1,19 @@
|
|||
Sun Feb 10 22:33:15 2008 Minero Aoki <aamine@loveruby.net>
|
||||
|
||||
* net/loveruby/cflat/asm/Reference.java: new constructor
|
||||
Reference(String) for instance.
|
||||
|
||||
* net/loveruby/cflat/ast/AST.java: #declarations should include
|
||||
vardecls.
|
||||
|
||||
* net/loveruby/cflat/ast/UndefinedVariable.java: #address should
|
||||
return variable symbol.
|
||||
|
||||
* net/loveruby/cflat/compiler/LocalReferenceResolver.java:
|
||||
declarations may include variable declaration.
|
||||
|
||||
* test/vardecl.cb: test reference of declared external variable.
|
||||
|
||||
Fri Feb 8 04:59:38 2008 Minero Aoki <aamine@loveruby.net>
|
||||
|
||||
* net/loveruby/cflat/compiler/JumpResolver.java: remove
|
||||
|
|
|
@ -3,6 +3,10 @@ package net.loveruby.cflat.asm;
|
|||
public class Reference extends Address {
|
||||
protected Label label;
|
||||
|
||||
public Reference(String sym) {
|
||||
this(new Label(sym));
|
||||
}
|
||||
|
||||
public Reference(Label label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
|
|
@ -35,6 +35,13 @@ public class AST extends Node {
|
|||
return result.iterator();
|
||||
}
|
||||
|
||||
public Iterator declarations() {
|
||||
List result = new ArrayList();
|
||||
result.addAll(declarations.funcdecls());
|
||||
result.addAll(declarations.vardecls());
|
||||
return result.iterator();
|
||||
}
|
||||
|
||||
public Iterator entities() {
|
||||
List result = new ArrayList();
|
||||
result.addAll(declarations.defvars());
|
||||
|
@ -42,14 +49,6 @@ public class AST extends Node {
|
|||
return result.iterator();
|
||||
}
|
||||
|
||||
public Iterator globalVariables() {
|
||||
return scope.globalVariables().iterator();
|
||||
}
|
||||
|
||||
public Iterator commonSymbols() {
|
||||
return scope.commonSymbols().iterator();
|
||||
}
|
||||
|
||||
public Iterator variables() {
|
||||
return declarations.defvars().iterator();
|
||||
}
|
||||
|
@ -62,22 +61,18 @@ public class AST extends Node {
|
|||
return declarations.defuns().iterator();
|
||||
}
|
||||
|
||||
public void declare(UndefinedFunction f) {
|
||||
declarations.funcdecls().add(f);
|
||||
}
|
||||
|
||||
public Iterator declarations() {
|
||||
List result = new ArrayList();
|
||||
//result.addAll(declarations.defvars());
|
||||
//result.addAll(declarations.defuns());
|
||||
result.addAll(declarations.funcdecls());
|
||||
return result.iterator();
|
||||
}
|
||||
|
||||
public ToplevelScope scope() {
|
||||
return scope;
|
||||
}
|
||||
|
||||
public Iterator globalVariables() {
|
||||
return scope.globalVariables().iterator();
|
||||
}
|
||||
|
||||
public Iterator commonSymbols() {
|
||||
return scope.commonSymbols().iterator();
|
||||
}
|
||||
|
||||
public ConstantTable constantTable() {
|
||||
return constantTable;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,14 @@ public class UndefinedVariable extends Variable {
|
|||
throw new Error("UndefinedVariable#defineIn called");
|
||||
}
|
||||
|
||||
public void setAddress(AsmEntity addr) {
|
||||
throw new Error("UndefinedVariable#setAddress");
|
||||
}
|
||||
|
||||
public AsmEntity address() {
|
||||
return new Reference(symbol());
|
||||
}
|
||||
|
||||
protected void _dump(Dumper d) {
|
||||
d.printMember("name", name);
|
||||
d.printMember("isPrivate", isPrivate());
|
||||
|
|
|
@ -632,6 +632,7 @@ static public void p(String s) { System.err.println(s); }
|
|||
saveWords(node.type(), "ax", node.lhs().address());
|
||||
}
|
||||
|
||||
// FIXME: use -4(%edx,%esi,4) addressing
|
||||
public void visit(ArefNode node) {
|
||||
if (node.expr().type().isPointerAlike()) {
|
||||
compile(node.expr());
|
||||
|
|
|
@ -38,9 +38,9 @@ public class LocalReferenceResolver extends Visitor {
|
|||
}
|
||||
}
|
||||
|
||||
protected void declareToplevelEntities(Iterator funcdecls) {
|
||||
while (funcdecls.hasNext()) {
|
||||
toplevel.declare((UndefinedFunction)funcdecls.next());
|
||||
protected void declareToplevelEntities(Iterator decls) {
|
||||
while (decls.hasNext()) {
|
||||
toplevel.declare((Entity)decls.next());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
import stdio;
|
||||
import errno;
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
printf("<<%s>>\n", sys_errlist[3]);
|
||||
printf("printf=%p\n", printf);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue