diff options
| author | Cliff Click <cliffc@acm.org> | 2026-10-12 16:46:53 -0700 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2026-10-12 16:46:53 -0700 |
| commit | 0e94cdc0c481e9312d1b5033b3597c7c262ff878 (patch) | |
| tree | 2d77b8aa47dc406407ce7ccfe95b415a68016342 /chapter25/src/main/java/com/seaofnodes/simple/Parser.java | |
| parent | 1213e8e8f359c8a1abb05ee8a220d9c56bc36051 (diff) | |
| download | Simple-clinit.tar.gz Simple-clinit.zip | |
Check for cyclic class init before we emit codeclinit
Diffstat (limited to 'chapter25/src/main/java/com/seaofnodes/simple/Parser.java')
| -rw-r--r-- | chapter25/src/main/java/com/seaofnodes/simple/Parser.java | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/chapter25/src/main/java/com/seaofnodes/simple/Parser.java b/chapter25/src/main/java/com/seaofnodes/simple/Parser.java index a6afc91f..331ff05d 100644 --- a/chapter25/src/main/java/com/seaofnodes/simple/Parser.java +++ b/chapter25/src/main/java/com/seaofnodes/simple/Parser.java @@ -1342,6 +1342,10 @@ public class Parser { TYPES.put(typeName,tself = tself.defined()); } + // Class object keeps a runtime flag to signal the <clinit> has run. + if( isClz ) + TYPES.put(typeName,tself=tself.add(Field.make("$init",TypeInteger.BOOL,_code.alias(_ref._cname),false))); + // Signature of the default constructor TypeFunPtr sig = structInitSig(isClz,tself); // Function and argument names of default constructor @@ -2304,7 +2308,7 @@ public class Parser { Kind.Func func = (Kind.Func)_scope._kinds.at(_scope.enclosingFuncOrDecl()); if( (ts==null || ts==TypeStruct.BOT || ts.isHigh() || startsClzPrefix(ts._name)) && !(ts!=null && (ts._name+".<clinit>").equals(func._name)) ) - ctrl(new CLInitNode(loc(),name,ctrl(),expr).peephole()); + ctrl(new CLInitNode(loc(),ctrl(),expr).peephole()); // With no field, we will update the bulk memory int alias = fld==null ? 1 : fld._alias; @@ -2704,6 +2708,8 @@ public class Parser { } public String position() { return _line_number+":"+(_position-_line_start+1); } + // Numeric location for diagnostics that must survive without source text. + public long lineColumn() { return ((long)_line_number<<32) | (_position-_line_start+1); } /** * Record the source text for lexing |
