private Property GetFieldAccessorProperty(TypeNode oldType, TypeNode type, Identifier name, Expression privExpr,
Expression idExpr)
{
Property accessor = null;
if (type == this.ZingPtrType) // Zing pointer type
{
accessor = Templates.GetPropertyTemplate("ptrFieldAccessor");
Replacer.Replace(accessor.Getter, "_fieldType", new Literal(oldType.Name.ToString(), SystemTypes.String));
}
else
{
accessor = Templates.GetPropertyTemplate("fieldAccessor");
}
accessor.Type = type;
accessor.Getter.ReturnType = type;
accessor.Setter.Parameters[0].Type = type;
accessor.Name = new Identifier(name.Name);
Replacer.Replace(accessor.Getter, "_fieldName", privExpr);
Replacer.Replace(accessor.Getter, "_fieldId", idExpr);
Replacer.Replace(accessor.Setter, "_fieldName", privExpr);
Replacer.Replace(accessor.Setter, "_fieldId", idExpr);
accessor.Getter.Name = Identifier.For("get_" + name.Name);
accessor.Setter.Name = Identifier.For("set_" + name.Name);
return accessor;
}