Skip to content

Commit

Permalink
fe: library feature current, use thisType of selfType
Browse files Browse the repository at this point in the history
see also Current:
```
  public Current(SourcePosition pos, AbstractFeature f)
  {
    super(f.thisType());
    ...
  }
```

I found this bug while trying to persist the main application to fum-file then reload it from there.
  • Loading branch information
michaellilltokiwa committed Sep 12, 2024
1 parent 3893f43 commit f4be48f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/dev/flang/fe/LibraryFeature.java
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ AbstractBlock code(int at, Stack<Expr> s, int pos, int posEnd)
}
case Current:
{
x = new AbstractCurrent(selfType())
x = new AbstractCurrent(selfType().asThis())
{ public SourcePosition pos() { return LibraryFeature.this.pos(fpos, fposEnd); } };
break;
}
Expand Down
17 changes: 10 additions & 7 deletions src/dev/flang/fe/LibraryModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public class LibraryModule extends Module implements MirModule
* The base index of this module. When converting local indices to global
* indices, the _globalBase will be added.
*/
final int _globalBase;
private final int _globalBase;


/**
Expand All @@ -113,19 +113,19 @@ public class LibraryModule extends Module implements MirModule
/**
* The module intermediate representation for this module.
*/
MIR _mir;
private MIR _mir;


/**
* Map from offset in _data to LibraryFeatures for features in this module.
*/
TreeMap<Integer, LibraryFeature> _libraryFeatures = new TreeMap<>();
private final TreeMap<Integer, LibraryFeature> _libraryFeatures = new TreeMap<>();


/**
* Map from offset in _data to LibraryType for types in this module.
*/
TreeMap<Integer, LibraryType> _libraryTypes = new TreeMap<>();
private final TreeMap<Integer, LibraryType> _libraryTypes = new TreeMap<>();


/**
Expand All @@ -141,7 +141,7 @@ public class LibraryModule extends Module implements MirModule
/**
* Cache for innerFeatures created from given index
*/
Map<Integer, List<AbstractFeature>> _innerFeatures = new TreeMap<>();
private final Map<Integer, List<AbstractFeature>> _innerFeatures = new TreeMap<>();


/**
Expand All @@ -153,13 +153,13 @@ public class LibraryModule extends Module implements MirModule
/**
* The universe
*/
final AbstractFeature _universe;
private final AbstractFeature _universe;


/**
* Modules referenced from this module
*/
final ModuleRef[] _modules;
private final ModuleRef[] _modules;


/**
Expand Down Expand Up @@ -375,6 +375,9 @@ AbstractFeature libraryFeature(int offset)
*/
AbstractFeature feature(int offset)
{
if (PRECONDITIONS) require
(offset >= -1);

return
(offset == -1) ? null :
(offset == 0) ? universe()
Expand Down
4 changes: 2 additions & 2 deletions src/dev/flang/fe/Module.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

/**
* A Module represents a Fuzion module independently of whether this is loaded
* from source code, library from a .mir file or downloaded from the web.
* from source code, library from a .fum file or downloaded from the web.
*
* @author Fridtjof Siebert ([email protected])
*/
Expand Down Expand Up @@ -159,7 +159,7 @@ protected static void add(SortedMap<FeatureName, List<AbstractFeature>> s, Featu


/**
* Create SourceModule for given options and sourceDirs.
* Create Module for given options and sourceDirs.
*/
Module(LibraryModule[] dependsOn)
{
Expand Down

0 comments on commit f4be48f

Please sign in to comment.