Skip to content

Commit ae42c09

Browse files
committed
Ability to include from resources
1 parent fcb21f6 commit ae42c09

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

ownlang-parser/src/main/java/com/annimon/ownlang/parser/ast/IncludeStatement.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import com.annimon.ownlang.stages.*;
99
import com.annimon.ownlang.util.Range;
1010
import com.annimon.ownlang.util.SourceLocation;
11-
import com.annimon.ownlang.util.input.InputSourceFile;
11+
import com.annimon.ownlang.util.input.InputSourceDetector;
1212
import com.annimon.ownlang.util.input.SourceLoaderStage;
1313

1414
/**
@@ -18,10 +18,12 @@
1818
public final class IncludeStatement extends InterruptableNode implements Statement, SourceLocation {
1919

2020
public final Node expression;
21+
private final InputSourceDetector inputSourceDetector;
2122
private Range range;
22-
23+
2324
public IncludeStatement(Node expression) {
2425
this.expression = expression;
26+
inputSourceDetector = new InputSourceDetector();
2527
}
2628

2729
public void setRange(Range range) {
@@ -46,7 +48,7 @@ public Value eval() {
4648
// TODO LinterStage based on main context
4749
.then(new FunctionAddingStage())
4850
.then(new ExecutionStage())
49-
.perform(stagesData, new InputSourceFile(path));
51+
.perform(stagesData, inputSourceDetector.toInputSource(path));
5052
} catch (OwnLangParserException ex) {
5153
final var error = new ParseErrorsFormatterStage()
5254
.perform(stagesData, ex.getParseErrors());

0 commit comments

Comments
 (0)