mirror of https://github.com/aamine/cbc
67 lines
1.6 KiB
Java
67 lines
1.6 KiB
Java
package net.loveruby.cflat.entity;
|
|
import net.loveruby.cflat.type.Type;
|
|
import net.loveruby.cflat.ast.TypeNode;
|
|
import net.loveruby.cflat.ast.BlockNode;
|
|
import net.loveruby.cflat.ir.Stmt;
|
|
import net.loveruby.cflat.asm.Label;
|
|
import net.loveruby.cflat.exception.*;
|
|
import java.util.List;
|
|
|
|
public class DefinedFunction extends Function {
|
|
protected Params params;
|
|
protected BlockNode body;
|
|
protected LocalScope scope;
|
|
protected List<Stmt> ir;
|
|
|
|
public DefinedFunction(boolean priv, TypeNode type,
|
|
String name, Params params, BlockNode body) {
|
|
super(priv, type, name);
|
|
this.params = params;
|
|
this.body = body;
|
|
}
|
|
|
|
public boolean isDefined() {
|
|
return true;
|
|
}
|
|
|
|
public List<Parameter> parameters() {
|
|
return params.parameters();
|
|
}
|
|
|
|
public BlockNode body() {
|
|
return body;
|
|
}
|
|
|
|
public List<Stmt> ir() {
|
|
return ir;
|
|
}
|
|
|
|
public void setIR(List<Stmt> ir) {
|
|
this.ir = ir;
|
|
}
|
|
|
|
public void setScope(LocalScope scope) {
|
|
this.scope = scope;
|
|
}
|
|
|
|
/**
|
|
* Returns function local variables.
|
|
* Does NOT include paramters.
|
|
* Does NOT include static local variables.
|
|
*/
|
|
public List<DefinedVariable> localVariables() {
|
|
return scope.allLocalVariables();
|
|
}
|
|
|
|
protected void _dump(net.loveruby.cflat.ast.Dumper d) {
|
|
d.printMember("name", name);
|
|
d.printMember("isPrivate", isPrivate);
|
|
d.printMember("params", params);
|
|
d.printMember("body", body);
|
|
}
|
|
|
|
public <T> T accept(EntityVisitor<T> visitor) {
|
|
return visitor.visit(this);
|
|
}
|
|
}
|