Closed cyborgyn closed 2 years ago
Actually, it seems to be that easy to fix, as the following patch suggests. Is there a not so obvious reason why static constructors were filtered out during C code generation?
diff --git "a/IL2C.Core/AssemblyPreparer.cs" "b/IL2C.Core/AssemblyPreparer.cs"
index 12389a6..49d824f 100644
--- "a/IL2C.Core/AssemblyPreparer.cs"
+++ "b/IL2C.Core/AssemblyPreparer.cs"
@@ -322,7 +322,7 @@ namespace IL2C
// All types
type => true,
// The methods except type initializer.
- method => !(method.IsConstructor && method.IsStatic));
+ method => true);
}
}
}
@cyborgyn Sorry for the very delay. I understood #100 work and imported it with cherry-pick. 2cbb6f1da780acb289fb9f98d7b4adda99fd06c3
For the life of me, I can't remember why I excluded the Type initializer; it may have been due to the fact that I had not checked the initialization order of the Type initializer. (I still have not been able to confirm this.) If the initialization order is affected by the ECMA335 specification, I may need to rework this area, but for now, I'll leave it at that.
In the following static class initialization:
Foo.Bar will never contain a value, the string "foobar" is not enlisted between constant strings, and related to #97 issue, no static constructor is generated, but called.