diff --git a/src/dev/flang/air/Clazz.java b/src/dev/flang/air/Clazz.java index e493c6926..90f4375b4 100644 --- a/src/dev/flang/air/Clazz.java +++ b/src/dev/flang/air/Clazz.java @@ -152,7 +152,6 @@ public boolean action(AbstractMatch m, AbstractCase c) { var ac = actualClazzes(sc, null); var innerClazz = ac[0]; - var T = innerClazz.actualGenerics()[0]; var cf = innerClazz.feature(); if (CHECKS) check (cf == Types.resolved.f_Type_infix_colon_true || diff --git a/src/dev/flang/ast/AbstractType.java b/src/dev/flang/ast/AbstractType.java index c116dc7cf..d8f60fca3 100644 --- a/src/dev/flang/ast/AbstractType.java +++ b/src/dev/flang/ast/AbstractType.java @@ -1313,7 +1313,9 @@ public int compareToIgnoreOuter(AbstractType other) if (PRECONDITIONS) require (checkedForGeneric(), other != null, - other.checkedForGeneric()); + other.checkedForGeneric(), + !(this instanceof UnresolvedType), + !(other instanceof UnresolvedType)); int result = 0; @@ -1561,10 +1563,13 @@ AbstractType typeType(Resolution res) var g = new List(this); g.addAll(generics()); + var tf = res != null ? fot.typeFeature(res) : fot.typeFeature(); + if (CHECKS) check + (tf != null); result = ResolvedNormalType.create(g, g, outer().typeType(res), - res != null ? fot.typeFeature(res) : fot.typeFeature()); + tf); } return result; } diff --git a/src/dev/flang/ast/Types.java b/src/dev/flang/ast/Types.java index 31cc3ee5a..1e6f218cc 100644 --- a/src/dev/flang/ast/Types.java +++ b/src/dev/flang/ast/Types.java @@ -298,6 +298,99 @@ public Resolved(SrcModule mod, CreateType ct, AbstractFeature universe) res.resolveTypes(t.feature()); } } + public static interface LookupFeature + { + AbstractFeature lookup(AbstractFeature target, FeatureName fn); + } + public Resolved(LookupFeature lf, AbstractFeature universe) + { + this.universe = universe; + t_i8 = lookup(lf, "i8", 1).selfType(); + t_i16 = lookup(lf, "i16", 1).selfType(); + t_i32 = lookup(lf, "i32", 1).selfType(); + t_i64 = lookup(lf, "i64", 1).selfType(); + t_u8 = lookup(lf, "u8", 1).selfType(); + t_u16 = lookup(lf, "u16", 1).selfType(); + t_u32 = lookup(lf, "u32", 1).selfType(); + t_u64 = lookup(lf, "u64", 1).selfType(); + t_f32 = lookup(lf, "f32", 1).selfType(); + t_f64 = lookup(lf, "f64", 1).selfType(); + t_bool = lookup(lf, "bool", 0).selfType(); + t_fuzion = lookup(lf, "fuzion", 0).selfType(); + t_String = lookup(lf, FuzionConstants.STRING_NAME, 0).selfType(); + t_Const_String = lookup(lf, "Const_String", 0).selfType(); + t_Any = lookup(lf, FuzionConstants.ANY_NAME, 0).selfType(); + t_unit = lookup(lf, FuzionConstants.UNIT_NAME, 0).selfType(); + t_void = lookup(lf, "void", 0).selfType(); + t_codepoint = lookup(lf, "codepoint", 1).selfType(); + f_id = lookup(lf, "id", 2); + f_void = lookup(lf, "void", 0); + f_choice = lookup(lf, "choice", 1); + f_TRUE = lookup(lf, "TRUE", 0); + f_FALSE = lookup(lf, "FALSE", 0); + f_true = lookup(lf, "true", 0); + f_false = lookup(lf, "false", 0); + f_bool = lookup(lf, "bool", 0); + f_bool_NOT = null; + f_bool_AND = null; + f_bool_OR = null; + f_bool_IMPLIES = null; + f_bool_TERNARY = null; + f_Const_String_utf8_data = lookup(lf, lookup(lf, "Const_String", 0), "utf8_data", 0); + f_debug = lookup(lf, "debug", 0); + f_debug_level = lookup(lf, "debug_level", 0); + f_Function = lookup(lf, FUNCTION_NAME, 2); + f_Function_call = lookup(lf, f_Function, "call", 1); + f_safety = lookup(lf, "safety", 0); + f_array = lookup(lf, "array", 5); + f_array_internal_array = lookup(lf, f_array, "internal_array", 0); + f_error = lookup(lf, "error", 1); + f_error_msg = lookup(lf, f_error, "msg", 0); + f_fuzion = lookup(lf, "fuzion", 0); + f_fuzion_java = lookup(lf, f_fuzion, "java", 0); + f_fuzion_Java_Object = lookup(lf, f_fuzion_java, "Java_Object", 1); + f_fuzion_Java_Object_Ref = lookup(lf, f_fuzion_Java_Object, "Java_Ref", 0); + f_fuzion_sys = lookup(lf, f_fuzion, "sys", 0); + f_fuzion_sys_array = lookup(lf, f_fuzion_sys, "internal_array", 3); + f_fuzion_sys_array_data = lookup(lf, f_fuzion_sys_array, "data", 0); + f_fuzion_sys_array_length = lookup(lf, f_fuzion_sys_array, "length", 0); + f_concur = lookup(lf, "concur", 0); + f_concur_atomic = lookup(lf, f_concur, "atomic", 2); + f_concur_atomic_v = lookup(lf, f_concur_atomic, "v", 0); + f_Type = lookup(lf, "Type", 0); + f_Type_infix_colon = lookup(lf, f_Type, "infix :", 1); + f_Type_infix_colon_true = lookup(lf, f_Type, "infix_colon_true", 1); + f_Type_infix_colon_false = lookup(lf, f_Type, "infix_colon_false", 1); + f_type_as_value = lookup(lf, "type_as_value", 1); + f_Lazy = lookup(lf, LAZY_NAME, 1); + f_Unary = lookup(lf, UNARY_NAME, 2); + f_auto_unwrap = lookup(lf, "auto_unwrap", 2); + resolved = this; + numericTypes = new TreeSet(new List<>( + t_i8, + t_i16, + t_i32, + t_i64, + t_u8, + t_u16, + t_u32, + t_u64, + t_f32, + t_f64)); + ((ArtificialBuiltInType) t_ADDRESS ).resolveArtificialType(lookup(lf, FuzionConstants.ANY_NAME, 0)); + ((ArtificialBuiltInType) t_UNDEFINED).resolveArtificialType(universe); + ((ArtificialBuiltInType) t_ERROR ).resolveArtificialType(f_ERROR); + } + private AbstractFeature lookup(LookupFeature lf, AbstractFeature target, String name, int argCount) + { + var result = lf.lookup(target, FeatureName.get(name, argCount)); + check(result != null); + return result; + } + private AbstractFeature lookup(LookupFeature lf, String name, int argCount) + { + return lookup(lf, universe, name, argCount); + } } diff --git a/src/dev/flang/fe/FrontEnd.java b/src/dev/flang/fe/FrontEnd.java index a969df8d7..07d8367db 100644 --- a/src/dev/flang/fe/FrontEnd.java +++ b/src/dev/flang/fe/FrontEnd.java @@ -38,6 +38,7 @@ import java.util.Collection; import java.util.EnumSet; import java.util.TreeMap; +import java.util.function.Function; import dev.flang.mir.MIR; @@ -55,7 +56,6 @@ import dev.flang.util.ANY; import dev.flang.util.Errors; import dev.flang.util.FuzionConstants; -import dev.flang.util.List; import dev.flang.util.SourceDir; @@ -70,9 +70,6 @@ public class FrontEnd extends ANY /*---------------------------- constants ----------------------------*/ - static final FeatureName UNIVERSE_NAME = FeatureName.get(FuzionConstants.UNIVERSE_NAME, 0); - - /** * Offset added to global indices to detect false usage of these early on. */ @@ -94,6 +91,8 @@ public class FrontEnd extends ANY */ class Universe extends Feature { + private final FeatureName _fn = FeatureName.get(FuzionConstants.UNIVERSE_NAME, 0); + { setState(State.LOADING); } public boolean isUniverse() { @@ -102,7 +101,7 @@ public boolean isUniverse() public FeatureName featureName() { - return UNIVERSE_NAME; + return _fn; } } @@ -115,18 +114,6 @@ public FeatureName featureName() public final FrontEndOptions _options; - /** - * The universe. - */ - public final AbstractFeature _universe; - - - /** - * The base module if it was loaded from base.fum, null otherwise. - */ - public final LibraryModule _baseModule; - - /** * The library modules loaded so far. Maps the module name, e.g. "base" to * the corresponding LibraryModule instance. @@ -137,7 +124,7 @@ public FeatureName featureName() /** * The module we are compiling. null if !options._loadSources or Errors.count() != 0 */ - private final SourceModule _sourceModule; + private SourceModule _sourceModule; /** @@ -146,6 +133,12 @@ public FeatureName featureName() private int _totalModuleData = 0; + /** + * The compiled main module. + */ + private LibraryModule _mainModule; + + /*-------------------------- constructors ---------------------------*/ @@ -155,16 +148,8 @@ public FeatureName featureName() public FrontEnd(FrontEndOptions options) { _options = options; - Types.reset(options); - FeatureAndOuter.reset(); - Errors.reset(); - FeatureName.reset(); - Expr.reset(); - Call.reset(); - Contract.reset(); - HasGlobalIndex.reset(); + reset(); var universe = new Universe(); - _universe = universe; var sourcePaths = options.sourcePaths(); var sourceDirs = new SourceDir[sourcePaths.length + options._modules.size()]; @@ -172,23 +157,9 @@ public FrontEnd(FrontEndOptions options) { sourceDirs[i] = new SourceDir(sourcePaths[i]); } - var lms = new List(); - if (options._loadBaseLib) - { - _baseModule = module(FuzionConstants.BASE_MODULE_NAME, modulePath(FuzionConstants.BASE_MODULE_NAME)); - if (_baseModule != null) - { - lms.add(_baseModule); - } - } - else - { - _baseModule = null; - } - lms.addAll(options._modules.stream().map(mn -> loadModule(mn)) - .filter(m -> m != null) - .toList()); - var dependsOn = lms.toArray(LibraryModule[]::new); + + var dependsOn = loadModules(universe); + if (options._loadSources) { _sourceModule = new SourceModule(options, sourceDirs, dependsOn, universe); @@ -201,6 +172,57 @@ public FrontEnd(FrontEndOptions options) } + /** + * Load modules using universe. + * + * @param universe the universe to use to load the modules + * + * @return dependsOn, usually base module and modules explicitly specified in -modules=... + */ + private LibraryModule[] loadModules(AbstractFeature universe) + { + if (_options._loadBaseLib) + { + module(FuzionConstants.BASE_MODULE_NAME, modulePath(FuzionConstants.BASE_MODULE_NAME), universe); + } + _options._modules.stream().forEach(mn -> loadModule(mn, universe)); + + // Visibility not propagated through modules: see #484 + return _modules + .entrySet() + .stream() + .filter(kv -> { + var moduleName = kv.getKey(); + return _options._loadBaseLib && moduleName.equals(FuzionConstants.BASE_MODULE_NAME) + || _options._modules.contains(moduleName); + }) + .map(x -> x.getValue()) + .toArray(LibraryModule[]::new); + } + + + /** + * reset almost all data in the front end. + * + * NYI: CLEANUP: remove this code + */ + private void reset() + { + _totalModuleData = 0; + Types.reset(_options); + FeatureAndOuter.reset(); + Errors.reset(); + FeatureName.reset(); + Expr.reset(); + Call.reset(); + Contract.reset(); + HasGlobalIndex.reset(); + _sourceModule = null; + _modules.clear(); + _mainModule = null; + } + + /** * Determine the path of the base modules, "$(FUZION)/modules". */ @@ -236,13 +258,13 @@ private Path modulePath(String name) /** * Load module from given path. */ - private LibraryModule module(String m, Path p) + private LibraryModule module(String m, Path p, AbstractFeature universe) { LibraryModule result = null; try (var ch = (FileChannel) Files.newByteChannel(p, EnumSet.of(StandardOpenOption.READ))) { var data = ch.map(FileChannel.MapMode.READ_ONLY, 0, ch.size()); - result = libModule(data, new LibraryModule[0]); + result = libModule(data, x -> new LibraryModule[0], universe); if (!m.equals(result.name())) { Errors.error("Module name mismatch for module file '" + p + "' expected name '" + @@ -258,11 +280,10 @@ private LibraryModule module(String m, Path p) return result; } - /** * create a new LibraryModule from `data` */ - private LibraryModule libModule(ByteBuffer data, LibraryModule[] dependsOn) + private LibraryModule libModule(ByteBuffer data, Function loadDependsOn, AbstractFeature universe) { LibraryModule result; var base = _totalModuleData; @@ -270,8 +291,8 @@ private LibraryModule libModule(ByteBuffer data, LibraryModule[] dependsOn) result = new LibraryModule(GLOBAL_INDEX_OFFSET + base, this, data, - dependsOn, - _universe); + loadDependsOn, + universe); return result; } @@ -283,7 +304,7 @@ private LibraryModule libModule(ByteBuffer data, LibraryModule[] dependsOn) * * @return the loaded module or null if it was not found or an error occurred. */ - LibraryModule loadModule(String m) + LibraryModule loadModule(String m, AbstractFeature universe) { var result = _modules.get(m); if (result == null) @@ -291,7 +312,7 @@ LibraryModule loadModule(String m) var p = modulePath(m); if (p != null) { - result = module(m, p); + result = module(m, p, universe); } else { @@ -307,14 +328,26 @@ LibraryModule loadModule(String m) /*----------------------------- methods -----------------------------*/ + /** + * create the module intermediate representation + * + * @return the MIR + */ public MIR createMIR() { - return _sourceModule.createMIR(_sourceModule._main); + var main = _sourceModule._main; + var mm = mainModule(); + return mm.createMIR(main); } - public SourceModule module() + /** + * @return The source module. + */ + public SourceModule sourceModule() { + if (CHECKS) check + (_sourceModule != null); return _sourceModule; } @@ -331,9 +364,28 @@ public Collection getModules() /** * Get the compiled module main. */ - public Module mainModule() + public LibraryModule mainModule() + { + if (_mainModule == null) + { + _sourceModule.checkMain(); + Errors.showAndExit(); + + var data = _sourceModule.data("main"); + reset(); + _mainModule = libModule(data, af -> loadModules(af), null /* use universe of module */); + var ignore = new Types.Resolved((target,fn) -> _mainModule.lookupFeature(target, fn, null), _mainModule.libraryUniverse()); + } + return _mainModule; + } + + + /** + * @return The base module. + */ + public LibraryModule baseModule() { - return libModule(_sourceModule.data("main"), _modules.values().toArray(new LibraryModule[_modules.size()])); + return _modules.get("base"); } } diff --git a/src/dev/flang/fe/LibraryFeature.java b/src/dev/flang/fe/LibraryFeature.java index 77d32a957..dcf31a357 100644 --- a/src/dev/flang/fe/LibraryFeature.java +++ b/src/dev/flang/fe/LibraryFeature.java @@ -230,18 +230,29 @@ public int modifiers() } + @Override + public boolean isUniverse() + { + return featureName().baseName().equals("universe"); + } + + /** * Find the outer feature of this feature. */ public AbstractFeature outer() { - var result = _outer; - if (result == null) + AbstractFeature result = null; + if (!isUniverse()) { - result = _libModule.featureOuter(_index); - _outer = result; - } + result = _outer; + if (result == null) + { + result = _libModule.featureOuter(_index); + _outer = result; + } + } return result; } diff --git a/src/dev/flang/fe/LibraryModule.java b/src/dev/flang/fe/LibraryModule.java index e9dbd3480..913c653bb 100644 --- a/src/dev/flang/fe/LibraryModule.java +++ b/src/dev/flang/fe/LibraryModule.java @@ -35,6 +35,10 @@ import java.util.Map; import java.util.SortedMap; import java.util.TreeMap; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.stream.Collector; +import java.util.stream.Collectors; import dev.flang.ast.AbstractFeature; import dev.flang.ast.AbstractType; @@ -50,6 +54,7 @@ import dev.flang.util.Errors; import dev.flang.util.FuzionConstants; +import dev.flang.util.FuzionConstants.MirExprKind; import dev.flang.util.FuzionOptions; import static dev.flang.util.FuzionConstants.MirExprKind; @@ -162,11 +167,6 @@ public class LibraryModule extends Module implements MirModule private final ModuleRef[] _modules; - /** - * The front end that loaded this module. - */ - private final FrontEnd _fe; - /*-------------------------- constructors ---------------------------*/ @@ -174,15 +174,13 @@ public class LibraryModule extends Module implements MirModule /** * Create LibraryModule for given options and sourceDirs. */ - LibraryModule(int globalBase, FrontEnd fe, ByteBuffer data, LibraryModule[] dependsOn, AbstractFeature universe) + LibraryModule(int globalBase, FrontEnd fe, ByteBuffer data, Function loadDependsOn, AbstractFeature universe) { - super(dependsOn); + super(null /* set later, we need correct universe first */); _globalBase = globalBase; - _fe = fe; _mir = null; _data = data; - _universe = universe; _sourceFiles = new ArrayList<>(sourceFilesCount()); var sfc = sourceFilesCount(); for (int i = 0; i < sfc; i++) @@ -193,11 +191,20 @@ public class LibraryModule extends Module implements MirModule _modules = new ModuleRef[mrc]; var p = moduleRefsPos(); int moduleOffset = _data.limit(); + + this._universe = universe == null ? libraryUniverse() : universe; + if (CHECKS) check + (_universe.isUniverse()); + + _dependsOn = loadDependsOn.apply(universe()); + if (CHECKS) + check(_dependsOn != null); + for (int i = 0; i < mrc; i++) { var n = moduleRefName(p); var v = moduleRefVersion(p); - var m = fe.loadModule(n); + var m = fe.loadModule(n, universe()); var mv = m.version(); if (!Arrays.equals(v, mv)) { @@ -260,7 +267,7 @@ int globalIndex(int index) */ private AbstractFeature universe() { - return _fe._universe; + return _universe; } @@ -420,7 +427,7 @@ List features(AbstractFeature outer) /** * get the universe as persisted in this fum-file */ - private LibraryFeature libraryUniverse() + public LibraryFeature libraryUniverse() { return (LibraryFeature)innerFeatures(declFeaturesInnerPos(moduleDeclFeaturesPos())).get(0); } diff --git a/src/dev/flang/fe/Module.java b/src/dev/flang/fe/Module.java index 62ce7455f..93e53f1fe 100644 --- a/src/dev/flang/fe/Module.java +++ b/src/dev/flang/fe/Module.java @@ -42,12 +42,14 @@ import dev.flang.util.List; import dev.flang.util.SourceFile; +import java.util.Arrays; import java.util.Collection; import java.util.Set; import java.util.SortedMap; import java.util.TreeMap; import java.util.TreeSet; import java.util.function.Consumer; +import java.util.stream.Stream; /** @@ -170,12 +172,6 @@ protected static void add(SortedMap> s, Featu /*----------------------------- methods -----------------------------*/ - /** - * Create the module intermediate representation for this module. - */ - public abstract MIR createMIR(String main); - - /** * Get declared features for given outer Feature as seen by this module. * Result is null if outer has no declared features in this module. @@ -459,6 +455,14 @@ private SortedMap> declaredOrInheritedFeature } } + // This is need for "extension" features + // that are declared in different modules + // than the outer feature: + // e.g. `Any.dt => Any.this.type` + var selfAndModules = Stream + .concat(Arrays.stream(modules), Stream.of(this)) + .toArray(Module[]::new); + // first we search in additional modules for (Module libraryModule : modules) { @@ -466,7 +470,7 @@ private SortedMap> declaredOrInheritedFeature { addDeclaredOrInherited(s, outer, e.getKey(), e.getValue()); } - libraryModule.findInheritedFeatures(s, outer, modules); + libraryModule.findInheritedFeatures(s, outer, selfAndModules); } // then we search in this module @@ -599,8 +603,9 @@ public AbstractFeature lookupFeature(AbstractFeature outer, FeatureName name, Ab * * This is a fix for #978 but it might need to be removed when fixing #932. */ - return result == null && original instanceof Feature of && of._addedLate ? original - : result; + return result == null + ? original + : result; } @@ -609,27 +614,6 @@ public AbstractFeature lookupFeature(AbstractFeature outer, FeatureName name, Ab */ static MIR createMIR(MirModule mirMod, AbstractFeature universe, AbstractFeature main) { - if (main != null && !Errors.any()) - { - if (main.valueArguments().size() != 0) - { - FeErrors.mainFeatureMustNotHaveArguments(main); - } - switch (main.kind()) - { - case Field : FeErrors.mainFeatureMustNotBeField (main); break; - case Abstract : FeErrors.mainFeatureMustNotBeAbstract (main); break; - case Intrinsic: FeErrors.mainFeatureMustNotBeIntrinsic(main); break; - case Choice : FeErrors.mainFeatureMustNotBeChoice (main); break; - case Routine : - if (!main.generics().list.isEmpty()) - { - FeErrors.mainFeatureMustNotHaveTypeArguments(main); - } - break; - default : FeErrors.mainFeatureMustNot(main, "be of kind " + main.kind() + "."); - } - } var result = new MIR(universe, main, mirMod); if (!Errors.any()) { diff --git a/src/dev/flang/fe/SourceModule.java b/src/dev/flang/fe/SourceModule.java index c1d64b454..3ae606af1 100644 --- a/src/dev/flang/fe/SourceModule.java +++ b/src/dev/flang/fe/SourceModule.java @@ -63,8 +63,6 @@ import dev.flang.ast.State; import dev.flang.ast.Types; import dev.flang.ast.Visi; -import dev.flang.mir.MIR; -import dev.flang.mir.MirModule; import dev.flang.parser.Parser; @@ -81,7 +79,7 @@ * * @author Fridtjof Siebert (siebert@tokiwa.software) */ -public class SourceModule extends Module implements SrcModule, MirModule +public class SourceModule extends Module implements SrcModule { /*---------------------------- variables ----------------------------*/ @@ -274,22 +272,33 @@ void createASTandResolve() } - /** - * Create the module intermediate representation for this module. - */ - public MIR createMIR(String main) + public void checkMain() { - var d = main == null - ? _universe - : _universe.get(this, main); - - if (false) // NYI: Eventually, we might want to stop here in case of errors. This is disabled just to check the robustness of the next steps + if (_main != null) { - Errors.showAndExit(); + var main = this._universe.get(this, _main); + if (main != null && !Errors.any()) + { + if (main.valueArguments().size() != 0) + { + FeErrors.mainFeatureMustNotHaveArguments(main); + } + switch (main.kind()) + { + case Field : FeErrors.mainFeatureMustNotBeField (main); break; + case Abstract : FeErrors.mainFeatureMustNotBeAbstract (main); break; + case Intrinsic: FeErrors.mainFeatureMustNotBeIntrinsic(main); break; + case Choice : FeErrors.mainFeatureMustNotBeChoice (main); break; + case Routine : + if (!main.generics().list.isEmpty()) + { + FeErrors.mainFeatureMustNotHaveTypeArguments(main); + } + break; + default : FeErrors.mainFeatureMustNot(main, "be of kind " + main.kind() + "."); + } + } } - - _closed = true; - return createMIR(this, _universe, d); } diff --git a/src/dev/flang/tools/CheckIntrinsics.java b/src/dev/flang/tools/CheckIntrinsics.java index c0d44aee4..fdc709788 100644 --- a/src/dev/flang/tools/CheckIntrinsics.java +++ b/src/dev/flang/tools/CheckIntrinsics.java @@ -56,7 +56,7 @@ static interface Mangle CheckIntrinsics(FrontEnd fe) { var all = new TreeSet(); - getAll(all, fe, fe._universe); + getAll(all, fe, fe.baseModule().libraryUniverse()); var i = dev.flang.be.interpreter.Intrinsics.supportedIntrinsics(); checkIntrinsics(all, true, i, "Interpreter backend", x->x); @@ -73,7 +73,7 @@ static interface Mangle void getAll(TreeSet all, FrontEnd fe, AbstractFeature outer) { - var s = fe._baseModule.declaredFeatures(outer); + var s = fe.baseModule().declaredFeatures(outer); for (var f : s.values()) { getAll(all, fe, f); diff --git a/src/dev/flang/tools/Fuzion.java b/src/dev/flang/tools/Fuzion.java index bcae0e672..184fc1948 100644 --- a/src/dev/flang/tools/Fuzion.java +++ b/src/dev/flang/tools/Fuzion.java @@ -350,7 +350,7 @@ void processFrontEnd(Fuzion f, FrontEnd fe) { n = n.substring(0, n.length() - sfx.length()); } - var data = fe.module().data(n); + var data = fe.sourceModule().data(n); if (data != null) { try (var os = Files.newOutputStream(p)) diff --git a/src/dev/flang/tools/docs/Docs.java b/src/dev/flang/tools/docs/Docs.java index 5388891b7..04d025d4c 100644 --- a/src/dev/flang/tools/docs/Docs.java +++ b/src/dev/flang/tools/docs/Docs.java @@ -115,7 +115,7 @@ private void breadthFirstTraverse0(Consumer c, Queue declaredFeatures(AbstractFeature f) { - return fe.module() + return fe.sourceModule() .declaredFeatures(f) .values() .stream(); @@ -130,7 +130,7 @@ private Stream declaredFeatures(AbstractFeature f) private Stream allInnerAndInheritedFeatures(AbstractFeature f) { var result = new List(); - fe.module().forEachDeclaredOrInheritedFeature(f, af -> result.add(af)); + fe.sourceModule().forEachDeclaredOrInheritedFeature(f, af -> result.add(af)); return result .stream(); } @@ -310,7 +310,7 @@ private void run(DocsOptions config) }, universe); - var htmlTool = new Html(config, mapOfDeclaredFeatures, universe, fe.module()); + var htmlTool = new Html(config, mapOfDeclaredFeatures, universe, fe.sourceModule()); mapOfDeclaredFeatures .keySet() diff --git a/src/dev/flang/tools/fzjava/FZJava.java b/src/dev/flang/tools/fzjava/FZJava.java index ece550b4b..2d5822a01 100644 --- a/src/dev/flang/tools/fzjava/FZJava.java +++ b/src/dev/flang/tools/fzjava/FZJava.java @@ -536,7 +536,7 @@ void processClass(Class c) */ void createOuter(String jfn) { - recurseDeclaredFeature(jfn.replace("/", "."), _fe._universe); + recurseDeclaredFeature(jfn.replace("/", "."), _fe.baseModule().libraryUniverse()); var pkg = jfn.substring(0, jfn.lastIndexOf("/")); if (pkg.indexOf("/") >= 0) diff --git a/tests/compile_time_type_casts_negative2/compile_time_type_casts_negative2.fz.expected_err b/tests/compile_time_type_casts_negative2/compile_time_type_casts_negative2.fz.expected_err index 33356493f..2ae911447 100644 --- a/tests/compile_time_type_casts_negative2/compile_time_type_casts_negative2.fz.expected_err +++ b/tests/compile_time_type_casts_negative2/compile_time_type_casts_negative2.fz.expected_err @@ -7,9 +7,9 @@ fuzion.runtime.fault.cause#1 fuzion.type.runtime.type.pre_fault.type.install_default.λ.call#1 fuzion.runtime.pre_fault.cause#1 fuzion.runtime.precondition_fault#1 -(compile_time_type_casts_negative2.use_x#3 compile_time_type_casts_negative2.a).pre do_b_thing -(compile_time_type_casts_negative2.use_x#3 compile_time_type_casts_negative2.a).precall do_b_thing -compile_time_type_casts_negative2.use_x#3 compile_time_type_casts_negative2.a +(compile_time_type_casts_negative2.use_x#4 compile_time_type_casts_negative2.a).pre do_b_thing +(compile_time_type_casts_negative2.use_x#4 compile_time_type_casts_negative2.a).precall do_b_thing +compile_time_type_casts_negative2.use_x#4 compile_time_type_casts_negative2.a compile_time_type_casts_negative2 *** fatal errors encountered, stopping. diff --git a/tests/local_mutate_negative/test_local_mutate_neg.fz.expected_err b/tests/local_mutate_negative/test_local_mutate_neg.fz.expected_err index 3da4e298e..7e96fa8af 100644 --- a/tests/local_mutate_negative/test_local_mutate_neg.fz.expected_err +++ b/tests/local_mutate_negative/test_local_mutate_neg.fz.expected_err @@ -9,7 +9,7 @@ effect environment '--empty--' for call to 'test_local_mutate_neg.test_sum.sum#1 ----------^^^^^ effect environment '--empty--' for call to 'test_local_mutate_neg.test_sum.sum#1' at --CURDIR--/test_local_mutate_neg.fz:114:5: sum l0 -----^^^ +----^^^^^^ effect environment '--empty--' for call to 'test_local_mutate_neg.test_sum' at --CURDIR--/test_local_mutate_neg.fz:116:3: test_sum --^^^^^^^^ diff --git a/tests/reg_issue2273/reg_issue2273.fz.expected_err b/tests/reg_issue2273/reg_issue2273.fz.expected_err index ae5a3bfad..ac77a1dc3 100644 --- a/tests/reg_issue2273/reg_issue2273.fz.expected_err +++ b/tests/reg_issue2273/reg_issue2273.fz.expected_err @@ -4,9 +4,9 @@ $MODULE/mutate/array.fz:106:5: error 1: Failed to verify that effect 'mutate' is ----^^^^^^ Callchain that lead to this point: -effect environment '--empty--' for call to '(mutate.type.array.type door).new#3 mutate' at --CURDIR--/reg_issue2273.fz:33:26: +effect environment '--empty--' for call to '(mutate.type.array.type door).new#3 mutate' at --CURDIR--/reg_issue2273.fz:33:6: d := (mutate.array door).new mutate 100 closed --------------------------^^^ +-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ effect environment '--empty--' for call to 'universe' effect environment '--empty--' at program entry diff --git a/tests/reg_issue2564/reg_issue2564.fz.expected_err b/tests/reg_issue2564/reg_issue2564.fz.expected_err index 9d9b5a815..6bd56782d 100644 --- a/tests/reg_issue2564/reg_issue2564.fz.expected_err +++ b/tests/reg_issue2564/reg_issue2564.fz.expected_err @@ -4,9 +4,9 @@ $MODULE/mutate/array.fz:112:5: error 1: Failed to verify that effect 'mutate' is ----^^^^^^ Callchain that lead to this point: -effect environment '--empty--' for call to '(mutate.type.array.type Any).new#1 mutate' at --CURDIR--/reg_issue2564.fz:26:32: +effect environment '--empty--' for call to '(mutate.type.array.type Any).new#1 mutate' at --CURDIR--/reg_issue2564.fz:26:8: o := (mutate.array Any).type.new mutate --------------------------------^^^ +-------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ effect environment '--empty--' for call to 'reg_issue2564' effect environment '--empty--' at program entry diff --git a/tests/reg_issue3147/reg_issue3147.fz.expected_err b/tests/reg_issue3147/reg_issue3147.fz.expected_err index 740a27c45..115129d43 100644 --- a/tests/reg_issue3147/reg_issue3147.fz.expected_err +++ b/tests/reg_issue3147/reg_issue3147.fz.expected_err @@ -7,16 +7,16 @@ Feature 't.type' instantiated at : inherits or declares abstract feature 't.type.doit' declared at --CURDIR--/reg_issue3147.fz:25:8: type.doit unit => abstract -------^^^^ -which is called at --CURDIR--/reg_issue3147.fz:27:23: +which is called at --CURDIR--/reg_issue3147.fz:27:21: test(X type : t) => X.doit -----------------------^^^^ +--------------------^^^^^^ without providing an implementation Callchain that lead to this point: call 'test#1 t' at --CURDIR--/reg_issue3147.fz:29:1: test t -^^^^ +^^^^^^ call 'universe' program entry point diff --git a/tests/reg_issue3199/reg_issue3199.fz.expected_err b/tests/reg_issue3199/reg_issue3199.fz.expected_err index 1971e31c2..bc3dd6d6f 100644 --- a/tests/reg_issue3199/reg_issue3199.fz.expected_err +++ b/tests/reg_issue3199/reg_issue3199.fz.expected_err @@ -7,9 +7,9 @@ Feature 'reg_issue3199.y' instantiated at : inherits or declares abstract feature 'reg_issue3199.X.f' declared at --CURDIR--/reg_issue3199.fz:27:5: f i32 => abstract ----^ -which is called at --CURDIR--/reg_issue3199.fz:32:9: +which is called at --CURDIR--/reg_issue3199.fz:32:7: say x.f ---------^ +------^^^ without providing an implementation Callchain that lead to this point: diff --git a/tests/reg_issue3359/reg_issue3359.fz.expected_err b/tests/reg_issue3359/reg_issue3359.fz.expected_err index 09dd9e248..d4d7146e6 100644 --- a/tests/reg_issue3359/reg_issue3359.fz.expected_err +++ b/tests/reg_issue3359/reg_issue3359.fz.expected_err @@ -8,22 +8,22 @@ Feature 'reg_issue3359.i' instantiated at --CURDIR--/reg_issue3359.fz:103:5: inherits or declares abstract feature 'reg_issue3359.i.q' declared at --CURDIR--/reg_issue3359.fz:77:5: q unit => abstract ----^ -which is called at --CURDIR--/reg_issue3359.fz:96:41: +which is called at --CURDIR--/reg_issue3359.fz:96:39: if envir.args.count = 0 then v.q -----------------------------------------^ +--------------------------------------^^^ and abstract feature 'reg_issue3359.i.r' declared at --CURDIR--/reg_issue3359.fz:78:5: r unit => abstract ----^ -which is called at --CURDIR--/reg_issue3359.fz:97:41: +which is called at --CURDIR--/reg_issue3359.fz:97:39: else if envir.args.count = 1 then v.r -----------------------------------------^ +--------------------------------------^^^ without providing an implementation Callchain that lead to this point: -call 'reg_issue3359.u#1 reg_issue3359.i' at --CURDIR--/reg_issue3359.fz:103:3: +call 'reg_issue3359.u#2 reg_issue3359.i' at --CURDIR--/reg_issue3359.fz:103:3: u i ---^ +--^^^ call 'reg_issue3359' program entry point @@ -37,22 +37,22 @@ Feature 'reg_issue3359.j' instantiated at --CURDIR--/reg_issue3359.fz:106:5: inherits or declares abstract feature 'reg_issue3359.i.q' declared at --CURDIR--/reg_issue3359.fz:77:5: q unit => abstract ----^ -which is called at --CURDIR--/reg_issue3359.fz:96:41: +which is called at --CURDIR--/reg_issue3359.fz:96:39: if envir.args.count = 0 then v.q -----------------------------------------^ +--------------------------------------^^^ and abstract feature 'reg_issue3359.i.r' declared at --CURDIR--/reg_issue3359.fz:78:5: r unit => abstract ----^ -which is called at --CURDIR--/reg_issue3359.fz:97:41: +which is called at --CURDIR--/reg_issue3359.fz:97:39: else if envir.args.count = 1 then v.r -----------------------------------------^ +--------------------------------------^^^ without providing an implementation Callchain that lead to this point: -call 'reg_issue3359.u#1 reg_issue3359.j' at --CURDIR--/reg_issue3359.fz:106:3: +call 'reg_issue3359.u#2 reg_issue3359.j' at --CURDIR--/reg_issue3359.fz:106:3: u j ---^ +--^^^ call 'reg_issue3359' program entry point @@ -66,16 +66,16 @@ Feature 'reg_issue3359.k' instantiated at --CURDIR--/reg_issue3359.fz:109:5: inherits or declares abstract feature 'reg_issue3359.i.r' declared at --CURDIR--/reg_issue3359.fz:78:5: r unit => abstract ----^ -which is called at --CURDIR--/reg_issue3359.fz:97:41: +which is called at --CURDIR--/reg_issue3359.fz:97:39: else if envir.args.count = 1 then v.r -----------------------------------------^ +--------------------------------------^^^ without providing an implementation Callchain that lead to this point: -call 'reg_issue3359.u#1 reg_issue3359.k' at --CURDIR--/reg_issue3359.fz:109:3: +call 'reg_issue3359.u#2 reg_issue3359.k' at --CURDIR--/reg_issue3359.fz:109:3: u k ---^ +--^^^ call 'reg_issue3359' program entry point @@ -88,22 +88,22 @@ Feature 'reg_issue3359.f.type' instantiated at : inherits or declares abstract feature 'reg_issue3359.f.type.n' declared at --CURDIR--/reg_issue3359.fz:35:10: type.n unit => abstract ---------^ -which is called at --CURDIR--/reg_issue3359.fz:54:41: +which is called at --CURDIR--/reg_issue3359.fz:54:39: if envir.args.count = 0 then T.n -----------------------------------------^ +--------------------------------------^^^ and abstract feature 'reg_issue3359.f.type.o' declared at --CURDIR--/reg_issue3359.fz:36:10: type.o unit => abstract ---------^ -which is called at --CURDIR--/reg_issue3359.fz:55:41: +which is called at --CURDIR--/reg_issue3359.fz:55:39: else if envir.args.count = 1 then T.o -----------------------------------------^ +--------------------------------------^^^ without providing an implementation Callchain that lead to this point: call 'reg_issue3359.t#1 reg_issue3359.f' at --CURDIR--/reg_issue3359.fz:61:3: t f ---^ +--^^^ call 'reg_issue3359' program entry point @@ -116,22 +116,22 @@ Feature 'reg_issue3359.g.type' instantiated at : inherits or declares abstract feature 'reg_issue3359.f.type.n' declared at --CURDIR--/reg_issue3359.fz:35:10: type.n unit => abstract ---------^ -which is called at --CURDIR--/reg_issue3359.fz:54:41: +which is called at --CURDIR--/reg_issue3359.fz:54:39: if envir.args.count = 0 then T.n -----------------------------------------^ +--------------------------------------^^^ and abstract feature 'reg_issue3359.f.type.o' declared at --CURDIR--/reg_issue3359.fz:36:10: type.o unit => abstract ---------^ -which is called at --CURDIR--/reg_issue3359.fz:55:41: +which is called at --CURDIR--/reg_issue3359.fz:55:39: else if envir.args.count = 1 then T.o -----------------------------------------^ +--------------------------------------^^^ without providing an implementation Callchain that lead to this point: call 'reg_issue3359.t#1 reg_issue3359.g' at --CURDIR--/reg_issue3359.fz:64:3: t g ---^ +--^^^ call 'reg_issue3359' program entry point @@ -144,16 +144,16 @@ Feature 'reg_issue3359.h.type' instantiated at : inherits or declares abstract feature 'reg_issue3359.f.type.o' declared at --CURDIR--/reg_issue3359.fz:36:10: type.o unit => abstract ---------^ -which is called at --CURDIR--/reg_issue3359.fz:55:41: +which is called at --CURDIR--/reg_issue3359.fz:55:39: else if envir.args.count = 1 then T.o -----------------------------------------^ +--------------------------------------^^^ without providing an implementation Callchain that lead to this point: call 'reg_issue3359.t#1 reg_issue3359.h' at --CURDIR--/reg_issue3359.fz:67:3: t h ---^ +--^^^ call 'reg_issue3359' program entry point diff --git a/tests/reg_issue348/reg_issue348.fz.expected_err b/tests/reg_issue348/reg_issue348.fz.expected_err index 611111849..680e265cf 100644 --- a/tests/reg_issue348/reg_issue348.fz.expected_err +++ b/tests/reg_issue348/reg_issue348.fz.expected_err @@ -4,9 +4,9 @@ $MODULE/mutate/array.fz:106:5: error 1: Failed to verify that effect 'reg_issue3 ----^^^^^^ Callchain that lead to this point: -effect environment '--empty--' for call to '(mutate.type.array.type reg_issue348.a).new#3 reg_issue348.m' at --CURDIR--/reg_issue348.fz:33:32: +effect environment '--empty--' for call to '(mutate.type.array.type reg_issue348.a).new#3 reg_issue348.m' at --CURDIR--/reg_issue348.fz:33:10: arr := (mutate.array a).type.new m 10 a --------------------------------^^^ +---------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ effect environment '--empty--' for call to 'reg_issue348' effect environment '--empty--' at program entry