public override void VisitConst(ConstDefinition constDef)
{
constDef.TypeSpecifier.Accept(this);
TypeData constType = constDef.TypeSpecifier.NodeType;
TypeBuilder typeBuilder = currentClass.TypeBuilder;
MethodAttributes readerAttributes =
MethodAttributes.Virtual | MethodAttributes.HideBySig;
switch (constDef.Modifier) {
case ConstModifier.None:
readerAttributes |= MethodAttributes.Public;
break;
case ConstModifier.Private:
readerAttributes |= MethodAttributes.Private;
break;
}
constDef.FieldBuilder =
typeBuilder.DefineField("_" + constDef.Name,
constType.RawType,
FieldAttributes.Private |
FieldAttributes.Static |
FieldAttributes.Literal);
constDef.FieldBuilder.SetConstant(constDef.Value);
try {
constDef.Reader = DefineReader(typeBuilder, constDef.Name,
readerAttributes,
constDef.TypeSpecifier);
}
catch (MethodConflictionException e) {
report.Error(constDef.Location, e.Message);
}
}