Skip to content

Commit

Permalink
Simplify FuncDeclStmtNode to not need funcBodySource
Browse files Browse the repository at this point in the history
  • Loading branch information
skinny85 committed Jan 9, 2025
1 parent b69d519 commit 81bf013
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import com.oracle.truffle.api.library.CachedLibrary;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.object.DynamicObjectLibrary;
import com.oracle.truffle.api.source.SourceSection;

/**
* A Node that represents the declaration of a function in EasyScript.
Expand All @@ -29,13 +28,11 @@
@NodeField(name = "frameDescriptor", type = FrameDescriptor.class)
@NodeField(name = "funcBody", type = UserFuncBodyStmtNode.class)
@NodeField(name = "argumentCount", type = int.class)
@NodeField(name = "funcBodySource", type = SourceSection.class)
public abstract class FuncDeclStmtNode extends SkippedStmtNode {
protected abstract String getFuncName();
protected abstract FrameDescriptor getFrameDescriptor();
protected abstract UserFuncBodyStmtNode getFuncBody();
protected abstract int getArgumentCount();
protected abstract SourceSection getFuncBodySource();

@CompilationFinal
private FunctionObject cachedFunction;
Expand All @@ -48,7 +45,7 @@ protected Object declareFunction(DynamicObject containerObject,

var truffleLanguage = this.currentTruffleLanguage();
var funcRootNode = new StmtBlockRootNode(truffleLanguage,
this.getFrameDescriptor(), this.getFuncBody(), this.getFuncName(), this.getFuncBodySource());
this.getFrameDescriptor(), this.getFuncBody(), this.getFuncName(), this.getFuncBody().getSourceSection());
var callTarget = funcRootNode.getCallTarget();

ShapesAndPrototypes shapesAndPrototypes = this.currentLanguageContext().shapesAndPrototypes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -492,13 +492,10 @@ private FuncDeclStmtNode parseSubroutineDecl(EasyScriptParser.Subroutine_declCon
this.state = previousParserState;
this.localScopes = previousLocalScopes;

return FuncDeclStmtNodeGen.create(
containerObjectExpr,
return FuncDeclStmtNodeGen.create(containerObjectExpr,
subroutineDecl.name.getText(),
frameDescriptor,
new UserFuncBodyStmtNode(funcStmts, this.createSourceSection(subroutineDecl)),
argumentCount,
this.createSourceSection(subroutineDecl));
frameDescriptor, new UserFuncBodyStmtNode(funcStmts, this.createSourceSection(subroutineDecl)),
argumentCount);
}

private EasyScriptExprNode parseExpr1(EasyScriptParser.Expr1Context expr1) {
Expand Down

0 comments on commit 81bf013

Please sign in to comment.