callnode.java
来自「一个JAVA编写的简单编译器」· Java 代码 · 共 63 行
JAVA
63 行
package ast.binaryExpr;
// children [0] : 1. Parameter
// children [1] : 2. Parameter
public class CallNode extends ast.JSubNode {
private ast.declaration.StaticMethod calledmethod;
public CallNode (ast.declaration.JSubObject calledmethod) {
this.calledmethod = (ast.declaration.StaticMethod)calledmethod;
}
public String toString () {
return "()";
}
public void codegen () {
int k = getNumChildren ();
for (int i = 0; i < k; i++) {
ast.IJSubNode nextvalue = (ast.IJSubNode)getChild (i);
nextvalue.codegen ();
}
codegen.WriteCode.genstaticCall (
calledmethod.getMethodName(),
calledmethod.getSignature(),
calledmethod.getType());
}
public int getDepth () {
int depth = 0;
for (int i = 0; i < children.size(); i++) {
ast.IJSubNode node = (ast.IJSubNode)children.elementAt(i);
int ndepth = node.getDepth() + i + 1;
if (depth < ndepth)
depth = ndepth;
}
return depth;
}
public void dump (String prefix) {
System.out.println (prefix + calledmethod.toString());
super.dump (prefix + " ");
}
public String getXMLType () {
return "call";
}
public void genXML (java.io.PrintStream p, String prefix) {
p.println (prefix + "<" + getXMLType () + ">");
p.println (prefix + "<calledmethod name = \"" + calledmethod.getName () +"\">");
p.println (prefix + "</calledmethod>");
p.println (prefix + "<parameters>");
for (int i = 0; i < children.size(); i++) {
ast.IJSubNode n = (ast.IJSubNode)children.elementAt(i);
n.genXML (p, prefix + " ");
}
p.println (prefix + "</parameters>");
p.println (prefix + "</" + getXMLType () + ">");
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?