diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/constant/EnsoProjectNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/constant/EnsoProjectNode.java index 79ba87da4cde..83ea7f7435a6 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/constant/EnsoProjectNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/constant/EnsoProjectNode.java @@ -1,5 +1,6 @@ package org.enso.interpreter.node.expression.constant; +import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.TruffleFile; import com.oracle.truffle.api.TruffleLanguage; import com.oracle.truffle.api.frame.VirtualFrame; @@ -14,30 +15,38 @@ @NodeInfo(description = "Returns a language-level representation of the given Enso project.") public class EnsoProjectNode extends RootNode { - private final Object result; + private final Optional> pkgOpt; public EnsoProjectNode( TruffleLanguage language, EnsoContext context, Optional> pkgOpt) { super(language); + this.pkgOpt = pkgOpt; + } + + @Override + public Object execute(VirtualFrame frame) { + return createProjectDescription(); + } + + @CompilerDirectives.TruffleBoundary + private Object createProjectDescription() { + var context = EnsoContext.get(this); if (pkgOpt.isPresent()) { Package pkg = pkgOpt.get(); EnsoFile rootPath = new EnsoFile(pkg.root().normalize()); Object cfg = context.getEnvironment().asGuestValue(pkg.config()); - result = + var result = context .getBuiltins() .getProjectDescription() .getUniqueConstructor() .newInstance(rootPath, cfg); + return result; } else { - result = + var result = DataflowError.withoutTrace( context.getBuiltins().error().makeModuleNotInPackageError(), this); + return result; } } - - @Override - public Object execute(VirtualFrame frame) { - return result; - } }