public override void VisitConst(ConstDefinition constDef) { ilGenerator = constDef.Reader.GetILGenerator(); ilGenerator.Emit(OpCodes.Ldsfld, constDef.FieldBuilder); ilGenerator.Emit(OpCodes.Ret); }
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); } }
public virtual void VisitConst(ConstDefinition constDef) { }