本文整理汇总了C#中Mono.CSharp.FieldSpec类的典型用法代码示例。如果您正苦于以下问题:C# FieldSpec类的具体用法?C# FieldSpec怎么用?C# FieldSpec使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FieldSpec类属于Mono.CSharp命名空间,在下文中一共展示了FieldSpec类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Define
public override bool Define()
{
if (!base.Define ())
return false;
try {
Type[] required_modifier = null;
if ((ModFlags & Modifiers.VOLATILE) != 0) {
if (TypeManager.isvolatile_type == null)
TypeManager.isvolatile_type = TypeManager.CoreLookupType (Compiler,
"System.Runtime.CompilerServices", "IsVolatile", MemberKind.Class, true);
if (TypeManager.isvolatile_type != null)
required_modifier = new Type[] { TypeManager.isvolatile_type.GetMetaInfo () };
}
FieldBuilder = Parent.TypeBuilder.DefineField (
Name, member_type.GetMetaInfo (), required_modifier, null, ModifiersExtensions.FieldAttr (ModFlags));
spec = new FieldSpec (Parent.Definition, this, MemberType, FieldBuilder, ModFlags);
// Don't cache inaccessible fields
if ((ModFlags & Modifiers.BACKING_FIELD) == 0) {
Parent.MemberCache.AddMember (spec);
}
}
catch (ArgumentException) {
Report.RuntimeMissingSupport (Location, "`void' or `void*' field type");
return false;
}
if (initializer != null) {
((TypeContainer) Parent).RegisterFieldForInitialization (this,
new FieldInitializer (this, initializer, this));
}
return true;
}
示例2: Define
public override bool Define ()
{
if (!base.Define ())
return false;
MetaType[] required_modifier = null;
if ((ModFlags & Modifiers.VOLATILE) != 0) {
var mod = Module.PredefinedTypes.IsVolatile.Resolve ();
if (mod != null)
required_modifier = new MetaType[] { mod.GetMetaInfo () };
}
FieldBuilder = Parent.TypeBuilder.DefineField (
Name, member_type.GetMetaInfo (), required_modifier, null, ModifiersExtensions.FieldAttr (ModFlags));
spec = new FieldSpec (Parent.Definition, this, MemberType, FieldBuilder, ModFlags);
//
// Don't cache inaccessible fields except for struct where we
// need them for definitive assignment checks
//
if ((ModFlags & Modifiers.BACKING_FIELD) == 0 || Parent.Kind == MemberKind.Struct) {
Parent.MemberCache.AddMember (spec);
}
if (initializer != null) {
((TypeContainer) Parent).RegisterFieldForInitialization (this,
new FieldInitializer (spec, initializer, this));
}
if (declarators != null) {
var t = new TypeExpression (MemberType, TypeExpression.Location);
int index = Parent.PartialContainer.Fields.IndexOf (this);
foreach (var d in declarators) {
var f = new Field (Parent, t, ModFlags, new MemberName (d.Name.Value, d.Name.Location), OptAttributes);
if (d.Initializer != null)
f.initializer = d.Initializer;
Parent.PartialContainer.Fields.Insert (++index, f);
}
}
return true;
}
示例3: FixedFieldSpec
public FixedFieldSpec (TypeSpec declaringType, IMemberDefinition definition, FieldInfo info, FieldSpec element, Modifiers modifiers)
: base (declaringType, definition, element.MemberType, info, modifiers)
{
this.element = element;
// It's never CLS-Compliant
state &= ~StateFlags.CLSCompliant_Undetected;
}
示例4: Emit
public void Emit (OpCode opcode, FieldSpec field)
{
if (IsAnonymousStoreyMutateRequired)
field = field.Mutate (CurrentAnonymousMethod.Storey.Mutator);
ig.Emit (opcode, field.GetMetaInfo ());
}
示例5: FieldInitializer
public FieldInitializer (FieldSpec spec, Expression expression, IMemberContext mc)
: base (new FieldExpr (spec, expression.Location), expression, expression.Location)
{
this.mc = mc;
if (!spec.IsStatic)
((FieldExpr)target).InstanceExpression = CompilerGeneratedThis.Instance;
}
示例6: FieldExpr
public FieldExpr(FieldSpec spec, Location loc)
{
this.spec = spec;
this.loc = loc;
type = spec.MemberType;
}
示例7: Define
public override bool Define ()
{
if (!base.Define ())
return false;
Type[] required_modifier = null;
if ((ModFlags & Modifiers.VOLATILE) != 0) {
if (TypeManager.isvolatile_type == null)
TypeManager.isvolatile_type = TypeManager.CoreLookupType (Compiler,
"System.Runtime.CompilerServices", "IsVolatile", MemberKind.Class, true);
if (TypeManager.isvolatile_type != null)
required_modifier = new Type[] { TypeManager.isvolatile_type.GetMetaInfo () };
}
FieldBuilder = Parent.TypeBuilder.DefineField (
Name, member_type.GetMetaInfo (), required_modifier, null, ModifiersExtensions.FieldAttr (ModFlags));
spec = new FieldSpec (Parent.Definition, this, MemberType, FieldBuilder, ModFlags);
// Don't cache inaccessible fields
if ((ModFlags & Modifiers.BACKING_FIELD) == 0) {
Parent.MemberCache.AddMember (spec);
}
if (initializer != null) {
((TypeContainer) Parent).RegisterFieldForInitialization (this,
new FieldInitializer (spec, initializer, this));
}
if (declarators != null) {
var t = new TypeExpression (MemberType, TypeExpression.Location);
int index = Parent.PartialContainer.Fields.IndexOf (this);
foreach (var d in declarators) {
var f = new Field (Parent, t, ModFlags, new MemberName (d.Name.Value, d.Name.Location), OptAttributes);
if (d.Initializer != null)
f.initializer = d.Initializer;
Parent.PartialContainer.Fields.Insert (++index, f);
}
}
return true;
}
示例8: Define
public override bool Define ()
{
if (!base.Define ())
return false;
MetaType[] required_modifier = null;
if ((ModFlags & Modifiers.VOLATILE) != 0) {
var mod = Module.PredefinedTypes.IsVolatile.Resolve ();
if (mod != null)
required_modifier = new MetaType[] { mod.GetMetaInfo () };
}
FieldBuilder = Parent.TypeBuilder.DefineField (
Name, member_type.GetMetaInfo (), required_modifier, null, ModifiersExtensions.FieldAttr (ModFlags));
spec = new FieldSpec (Parent.Definition, this, MemberType, FieldBuilder, ModFlags);
// Don't cache inaccessible fields
if ((ModFlags & Modifiers.BACKING_FIELD) == 0) {
Parent.MemberCache.AddMember (spec);
}
if (initializer != null) {
((TypeContainer) Parent).RegisterFieldForInitialization (this,
new FieldInitializer (spec, initializer, this));
}
if (declarators != null) {
var t = new TypeExpression (MemberType, TypeExpression.Location);
int index = Parent.PartialContainer.Fields.IndexOf (this);
foreach (var d in declarators) {
var f = new Field (Parent, t, ModFlags, new MemberName (d.Name.Value, d.Name.Location), OptAttributes);
if (d.Initializer != null)
f.initializer = d.Initializer;
Parent.PartialContainer.Fields.Insert (++index, f);
}
}
/*
if ((ModFlags & (Modifiers.STATIC | Modifiers.READONLY | Modifiers.COMPILER_GENERATED)) == Modifiers.STATIC)
Console.WriteLine ("{0}: {1}", Location.ToString (), GetSignatureForError ());
*/
return true;
}
示例9: Mutate
public FieldInfo Mutate (FieldSpec fs)
{
// TODO:
return fs.GetMetaInfo ();
}
示例10: Emit
public void Emit (OpCode opcode, FieldSpec field)
{
if (IsAnonymousStoreyMutateRequired)
field = field.Mutate (CurrentAnonymousMethod.Storey.Mutator);
ig.Emit (opcode, field.GetMetaInfo ());
if (TrackStackTypes) {
switch (opcode.StackBehaviourPush) {
case StackBehaviour.Push0:
// nothing
break;
case StackBehaviour.Push1:
SetStackType (field.MemberType);
break;
case StackBehaviour.Pushi:
SetStackType (ReferenceContainer.MakeType (Module, field.MemberType));
break;
default:
throw new NotImplementedException ();
}
}
}
示例11: DefineInitializedData
public FieldSpec DefineInitializedData (byte[] data, Location loc)
{
Struct size_type;
if (!size_types.TryGetValue (data.Length, out size_type)) {
//
// Build common type for this data length. We cannot use
// DefineInitializedData because it creates public type,
// and its name is not unique among modules
//
size_type = new Struct (this, new MemberName ("$ArrayType=" + data.Length, loc), Modifiers.PRIVATE | Modifiers.COMPILER_GENERATED, null);
size_type.CreateContainer ();
size_type.DefineContainer ();
size_types.Add (data.Length, size_type);
// It has to work even if StructLayoutAttribute does not exist
size_type.TypeBuilder.__SetLayout (1, data.Length);
}
FieldSpec fs;
var data_hash = GenerateDataFieldName (data);
if (!data_hashes.TryGetValue (data_hash, out fs)) {
var name = "$field-" + data_hash;
const Modifiers fmod = Modifiers.STATIC | Modifiers.INTERNAL | Modifiers.READONLY;
var fbuilder = TypeBuilder.DefineField (name, size_type.CurrentType.GetMetaInfo (), ModifiersExtensions.FieldAttr (fmod) | FieldAttributes.HasFieldRVA);
fbuilder.__SetDataAndRVA (data);
fs = new FieldSpec (CurrentType, null, size_type.CurrentType, fbuilder, fmod);
data_hashes.Add (data_hash, fs);
}
return fs;
}
示例12: Reset
static public void Reset ()
{
// object_type = null;
// TODO: I am really bored by all this static stuff
system_type_get_type_from_handle =
bool_movenext_void =
void_dispose_void =
void_monitor_enter_object =
void_monitor_exit_object =
void_initializearray_array_fieldhandle =
int_interlocked_compare_exchange =
gen_interlocked_compare_exchange =
methodbase_get_type_from_handle =
methodbase_get_type_from_handle_generic =
fieldinfo_get_field_from_handle =
fieldinfo_get_field_from_handle_generic =
activator_create_instance =
delegate_combine_delegate_delegate =
delegate_remove_delegate_delegate = null;
int_get_offset_to_string_data =
ienumerator_getcurrent = null;
void_decimal_ctor_five_args =
void_decimal_ctor_int_arg =
void_decimal_ctor_long_arg = null;
string_empty = null;
typed_reference_type = arg_iterator_type = mbr_type =
generic_ilist_type = generic_icollection_type = generic_ienumerator_type =
generic_ienumerable_type = generic_nullable_type = expression_type = null;
}
示例13: Reset
static public void Reset ()
{
// object_type = null;
assembly_internals_vis_attrs = new Dictionary<Assembly, bool> ();
// TODO: I am really bored by all this static stuff
system_type_get_type_from_handle =
bool_movenext_void =
void_dispose_void =
void_monitor_enter_object =
void_monitor_exit_object =
void_initializearray_array_fieldhandle =
int_interlocked_compare_exchange =
methodbase_get_type_from_handle =
methodbase_get_type_from_handle_generic =
fieldinfo_get_field_from_handle =
fieldinfo_get_field_from_handle_generic =
activator_create_instance =
delegate_combine_delegate_delegate =
delegate_remove_delegate_delegate = null;
int_get_offset_to_string_data =
ienumerator_getcurrent = null;
void_decimal_ctor_five_args =
void_decimal_ctor_int_arg =
void_decimal_ctor_long_arg = null;
string_empty = null;
call_site_type =
generic_call_site_type =
binder_flags = null;
binder_type = null;
typed_reference_type = arg_iterator_type = mbr_type =
runtime_helpers_type = iasyncresult_type = asynccallback_type =
runtime_argument_handle_type = void_ptr_type = isvolatile_type =
generic_ilist_type = generic_icollection_type = generic_ienumerator_type =
generic_ienumerable_type = generic_nullable_type = expression_type =
parameter_expression_type = fieldinfo_type = methodinfo_type = ctorinfo_type = null;
expression_type_expr = null;
}