예제 #1
0
        public override void FieldReference(FieldReferenceOpcode opcode, FieldInfo field)
        {
            OpCode emitOpCode;

            opcode.GetReflectionEmitOpCode(out emitOpCode);
            generator.Emit(emitOpCode, field);
        }
예제 #2
0
        public override void FieldReference(FieldReferenceOpcode opcode, FieldInfo field)
        {
            if (opcode.IsStatic && !field.IsStatic)
            {
                throw Error("Static field reference to non-static field {0}.", GetFullName(field));
            }
            if (field.DeclaringType.IsGenericTypeDefinition)
            {
                throw Error("Field reference to a field from a generic type definition: {0}.", GetFullName(field));
            }

            if (opcode.ReferenceKind == LocationReferenceKind.Store)
            {
                stack.PopAssignableTo(opcode, field.FieldType);
            }

            if (!field.IsStatic)
            {
                stack.PopAssignableTo(opcode, field.DeclaringType);
            }

            if (opcode.ReferenceKind == LocationReferenceKind.Load)
            {
                stack.Push(field.FieldType);
            }
            else if (opcode.ReferenceKind == LocationReferenceKind.LoadAddress)
            {
                var managedPointerType = field.FieldType.MakeByRefType();
                // InitOnly fields are loaded a controlled-mutability managed pointers unless in the constructor
                bool mutable = !field.IsInitOnly ||
                               (method is ConstructorInfo && method.DeclaringType == field.DeclaringType);
                stack.PushManagedPointer(managedPointerType, mutable);
            }

            if (sink != null)
            {
                sink.FieldReference(opcode, field);
            }
        }
예제 #3
0
 public override void VisitFieldReference(FieldReferenceOpcode opcode, VisitorParam param)
 {
     throw RequiresSymbolicOverload(opcode);
 }
예제 #4
0
 public override void FieldReference(FieldReferenceOpcode opcode, FieldInfo field)
 {
     stringBuilder.AppendLine(opcode.Name + ' ' + field.DeclaringType.FullName + '.' + field.Name);
 }
예제 #5
0
 public abstract void FieldReference(FieldReferenceOpcode opcode, FieldInfo field);