private void collectStructAccessors(bool isGlobalVar, Struct s,
Expression expPrefix,
string strPrefix, Class theClass)
{
if (s == null)
return;
for (int i = 0, n = s.Members.Count; i < n; i++)
{
Field f = s.Members[i] as Field;
if (f == null)
continue;
string name = strPrefix + "_" + f.Name.Name;
QualifiedIdentifier qf = new QualifiedIdentifier(expPrefix, f.Name);
TypeNode generatedType = f.Type;
if (GetTypeClassification(f.Type) == TypeClassification.Heap)
generatedType = this.ZingPtrType;
else if (!IsPredefinedType(f.Type))
generatedType = new TypeExpression(new QualifiedIdentifier(
new Identifier("Application"), f.Type.Name), f.Type.SourceContext);
QualifiedIdentifier localsInputsOrOutputs = isGlobalVar ?
new QualifiedIdentifier(new Identifier("LocType"), new Identifier("Global")) :
new QualifiedIdentifier(new Identifier("LocType"), new Identifier("Local"));
Property accessor =
GetStructAccessorProperty(isGlobalVar ? "globalAccessor" : "localAccessor",
generatedType, new Identifier("__strprops_" + name),
qf, localsInputsOrOutputs);
theClass.Members.Add(accessor);
accessor.DeclaringType = theClass;
if (accessor.Getter != null)
{
theClass.Members.Add(accessor.Getter);
accessor.Getter.DeclaringType = theClass;
}
if (accessor.Setter != null)
{
theClass.Members.Add(accessor.Setter);
accessor.Setter.DeclaringType = theClass;
}
if (f.Type is Struct && !f.Type.IsPrimitive && f.Type != SystemTypes.Decimal)
collectStructAccessors(isGlobalVar, (Struct)f.Type,
qf, name, theClass);
}
}