Example #1
0
        public void Add(RppClass clazz)
        {
            _classes.Add(clazz);

            if (clazz.Modifiers.Contains(ObjectModifier.OmCase))
            {
                _classes.Add(CreateCompanion(clazz.Name, clazz.ClassParams));
            }
        }
Example #2
0
        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;
        }
Example #3
0
 public virtual void VisitExit(RppClass node)
 {
 }
Example #4
0
        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;
        }
Example #5
0
 public virtual void VisitEnter(RppClass node)
 {
 }