You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.4 KiB
51 lines
1.4 KiB
package chocopy.common.astnodes;
|
|
|
|
import chocopy.common.analysis.NodeAnalyzer;
|
|
import java_cup.runtime.ComplexSymbolFactory.Location;
|
|
|
|
import java.util.List;
|
|
|
|
/** Def statements. */
|
|
public class FuncDef extends Declaration {
|
|
|
|
/** Defined name. */
|
|
public final Identifier name;
|
|
/** Formal parameters. */
|
|
public final List<TypedVar> params;
|
|
/** Return type annotation. */
|
|
public final TypeAnnotation returnType;
|
|
/** Local-variable,inner-function, global, and nonlocal declarations. */
|
|
public final List<Declaration> declarations;
|
|
/** Other statements. */
|
|
public final List<Stmt> statements;
|
|
|
|
/**
|
|
* The AST for def NAME(PARAMS) -> RETURNTYPE: DECLARATIONS STATEMENTS spanning source locations
|
|
* [LEFT..RIGHT].
|
|
*/
|
|
public FuncDef(
|
|
Location left,
|
|
Location right,
|
|
Identifier name,
|
|
List<TypedVar> params,
|
|
TypeAnnotation returnType,
|
|
List<Declaration> declarations,
|
|
List<Stmt> statements) {
|
|
super(left, right);
|
|
this.name = name;
|
|
this.params = params;
|
|
this.returnType = returnType;
|
|
this.declarations = declarations;
|
|
this.statements = statements;
|
|
}
|
|
|
|
public <T> T dispatch(NodeAnalyzer<T> analyzer) {
|
|
return analyzer.analyze(this);
|
|
}
|
|
|
|
@Override
|
|
public Identifier getIdentifier() {
|
|
return this.name;
|
|
}
|
|
}
|