public void Add(RppClass clazz) { _classes.Add(clazz); if (clazz.Modifiers.Contains(ObjectModifier.OmCase)) { _classes.Add(CreateCompanion(clazz.Name, clazz.ClassParams)); } }
private static RppClass CreateCompanion(string name, IEnumerable<RppField> classParamsCollection) { RTypeName typeName = new RTypeName(name); IEnumerable<RppField> classParams = classParamsCollection as IList<RppField> ?? classParamsCollection.ToList(); var classParamsTypes = classParams.Select(p => p.Type).ToList(); RppFunc apply = CreateApply(typeName, classParamsTypes); RppFunc unapply = CreateUnapply(typeName, classParams); var exprs = List(apply, unapply); RppClass clazz = new RppClass(ClassKind.Object, new HashSet<ObjectModifier>(), name, Collections.NoFields, exprs, Collections.NoVariantTypeParams, RppBaseConstructorCall.Object); return clazz; }
public virtual void VisitExit(RppClass node) { }
public static RppClass CreateCompanion(string name, IEnumerable<ResolvableType> classParamTypes) { RppFunc factoryFunc = CreateApply(new RTypeName(name), classParamTypes); var exprs = List(factoryFunc); RppClass clazz = new RppClass(ClassKind.Object, new HashSet<ObjectModifier>(), name, Collections.NoFields, exprs, Collections.NoVariantTypeParams, RppBaseConstructorCall.Object); return clazz; }
public virtual void VisitEnter(RppClass node) { }