public Type Generate() { var ag = Generator.CurrentAssemblyGen; if (Parent == null || Builtins.IsTrue(Builtins.IsSymbolBound(Parent))) { var parent = Parent == null ? null : Builtins.SymbolValue(Parent); var rtd = Records.GenerateRecordTypeDescriptor(ag, RecordName, parent, Uid, Sealed, Opaque, Array.ConvertAll(Fields, x => ((IronSchemeConstant)x).value), FieldTypes); var type = (rtd.type as TypeBuilder).CreateType(); created = true; Builtins.SetSymbolValueFast(NameHint, rtd); return(type); } return(null); // cannot create }
public override void EmitCreation(CodeGen cg) { if (created) { return; } if (Parent == null || Builtins.IsTrue(Builtins.IsSymbolBound(Parent))) { var parent = Parent == null ? null : Builtins.SymbolValue(Parent); var rtd = Records.GenerateRecordTypeDescriptor(cg.TypeGen.AssemblyGen, RecordName, parent, Uid, Sealed, Opaque, Array.ConvertAll(Fields, x => ((IronSchemeConstant)x).value), FieldTypes); (rtd.type as TypeBuilder).CreateType(); Builtins.SetSymbolValueFast(NameHint, rtd); } else { throw new Exception(string.Format("Parent not bound: {0} of {1}", Parent, RecordName)); } }