Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,26 @@
class [static] ARootClass{ // A top level class, no instances
class A{ self.println(" constructor"); } // a regular class
class B(A){ // ditto
var x;
fcn init(x=123){ self.x=x }
fcn toString{ "x is "+x }
}
}
ARootClass.B(456).println(); // create an instance
// prints:
Class(A) constructor
x is 456
f:=File("object.dat","wb");
Compiler.Asm.writeRootClass(ARootClass,f); // serialize to file
f.close();
f:=File("object.dat","rb");
rc:=Compiler.Asm.readRootClass(f); // read and re-create
// prints (readRootClass calls all constructors by default):
Class(A) constructor
f.close();
rc.B().println(); // create a new instance of B
// prints:
x is 123