private void GenLoadField(Runtime.IDataType data) { GenLoadConstant(data); CtorGen(new I.StoreStaticField { Name = "const" + data.GetHashCode() }); }
private void GenLoadConstant(Runtime.IDataType data) { if (data == null) { CtorGen(new I.LoadNull { }); } else if (data is Runtime.Cons cons) { GenLoadConstant(cons.car as Runtime.IDataType); GenLoadConstant(cons.cdr as Runtime.IDataType); CtorGen(new I.NewObject { Type = new RuntimeObject { Type = typeof(Runtime.Cons) } }); } else if (data is Runtime.T) { CtorGen(new I.NewObject { Type = new RuntimeObject { Type = typeof(Runtime.T) } }); } else if (data is Runtime.TInteger integer) { CtorGen(new I.LoadInt { Value = integer.Value }); CtorGen(new I.NewObject { Type = new RuntimeObject { Type = typeof(Runtime.TInteger) } }); } else if (data is Runtime.Symbol sym) { CtorGen(new I.LoadString { Value = sym.Name }); CtorGen(new I.Call { FullName = "[Runtime]Runtime.Symbol [Runtime]Runtime.Symbol::FindOrCreate(string)" }); } else if (data is Runtime.TString str) { CtorGen(new I.LoadString { Value = str.Value }); CtorGen(new I.NewObject { Type = new RuntimeObject { Type = typeof(Runtime.TString) } }); } else { // Other types are not implemented yet. throw new NotImplementedException(); } }
public void Register(Runtime.IDataType data) { Constants.Add(data); }