public override void Visit(IFunctionPointerTypeReference functionPointerTypeReference) { //System.Reflection has no way to construct an actual function pointer. //What it returns when reflecting on a function pointer typeBuilder is System.IntPtr. //We'll do the same. Since function pointers are unverifiable, the typeBuilder mismatch at the call site does //not actually matter. this.result = typeof(System.IntPtr); }
public override void Visit(IFunctionPointerTypeReference functionPointerTypeReference) { if (Process(functionPointerTypeReference)) { visitor.Visit(functionPointerTypeReference); } base.Visit(functionPointerTypeReference); }
public override void TraverseChildren(IPointerCall pointerCall) { IFunctionPointerTypeReference pointerType = (IFunctionPointerTypeReference)pointerCall.Pointer.Type; this.Traverse(pointerCall.Pointer); ((Expression)pointerCall.Pointer).Type = pointerType; this.Traverse(pointerCall.Arguments); ((PointerCall)pointerCall).Type = pointerType.Type; }
public override void TraverseChildren(IFunctionPointerTypeReference functionPointerTypeReference) { var typ = functionPointerTypeReference.ResolvedType; if (typ == Dummy.Type) { this.EmitError(functionPointerTypeReference, ErrorCode.FunctionPointerTypeResolution); } base.TraverseChildren(functionPointerTypeReference); }
public virtual void Visit(IFunctionPointerTypeReference functionPointerTypeReference) { this.Visit(functionPointerTypeReference.GetType(Context)); this.Visit(functionPointerTypeReference.GetParameters(Context)); this.Visit(functionPointerTypeReference.ExtraArgumentTypes); if (functionPointerTypeReference.ReturnValueIsModified) { this.Visit(functionPointerTypeReference.ReturnValueCustomModifiers); } }
public virtual void Visit(IFunctionPointerTypeReference functionPointerTypeReference) { this.Visit(functionPointerTypeReference.Signature.RefCustomModifiers); this.Visit(functionPointerTypeReference.Signature.ReturnValueCustomModifiers); this.Visit(functionPointerTypeReference.Signature.GetType(Context)); foreach (var param in functionPointerTypeReference.Signature.GetParameters(Context)) { this.Visit(param); } }
public override void Visit(IFunctionPointerTypeReference functionPointerTypeReference) { this.Visit((ISignature)functionPointerTypeReference); foreach (var extraArgument in functionPointerTypeReference.ExtraArgumentTypes) { Contract.Assume(extraArgument != null); this.Visit(extraArgument); } }
public void Visit(IFunctionPointerTypeReference functionPointerTypeReference) { throw new NotImplementedException(); }
public override void Visit(IFunctionPointerTypeReference functionPointerTypeReference) { if(Process(functionPointerTypeReference)){visitor.Visit(functionPointerTypeReference);} base.Visit(functionPointerTypeReference); }
public override void Visit(IFunctionPointerTypeReference functionPointerTypeReference) { allElements.Add(new InvokInfo(Traverser, "IFunctionPointerTypeReference", functionPointerTypeReference)); }
public override void TraverseChildren(IFunctionPointerTypeReference functionPointerTypeReference) { MethodEnter(functionPointerTypeReference); base.TraverseChildren(functionPointerTypeReference); MethodExit(); }
/// <summary> /// Traverses the function pointer type reference. /// </summary> public void Traverse(IFunctionPointerTypeReference functionPointerTypeReference) { Contract.Requires(functionPointerTypeReference != null); if (!this.objectsThatHaveAlreadyBeenTraversed.Add(functionPointerTypeReference)) return; if (this.preorderVisitor != null) this.preorderVisitor.Visit(functionPointerTypeReference); if (this.stopTraversal) return; this.TraverseChildren(functionPointerTypeReference); if (this.stopTraversal) return; if (this.postorderVisitor != null) this.postorderVisitor.Visit(functionPointerTypeReference); }
/// <summary> /// Traverses the children of the function pointer type reference. /// </summary> public virtual void TraverseChildren(IFunctionPointerTypeReference functionPointerTypeReference) { Contract.Requires(functionPointerTypeReference != null); this.TraverseChildren((ITypeReference)functionPointerTypeReference); this.Traverse(functionPointerTypeReference.Type); if (this.stopTraversal) return; this.Traverse(functionPointerTypeReference.Parameters); if (this.stopTraversal) return; this.Traverse(functionPointerTypeReference.ExtraArgumentTypes); if (this.stopTraversal) return; if (functionPointerTypeReference.ReturnValueIsModified) this.Traverse(functionPointerTypeReference.ReturnValueCustomModifiers); }
private static void InitializeArgumentsAndPushReturnResult(Instruction instruction, Stack <Instruction> stack, IFunctionPointerTypeReference funcPointer) { Contract.Requires(instruction != null); Contract.Requires(stack != null); Contract.Requires(funcPointer != null); instruction.Operand1 = stack.Pop(); //the function pointer var numArguments = IteratorHelper.EnumerableCount(funcPointer.Parameters); if (!funcPointer.IsStatic) { numArguments++; } var arguments = new Instruction[numArguments]; instruction.Operand2 = arguments; for (var i = numArguments; i > 0; i--) { arguments[i - 1] = stack.Pop(); } if (funcPointer.Type.TypeCode != PrimitiveTypeCode.Void) { stack.Push(instruction); } }
/// <summary> /// Performs some computation with the given function pointer type reference. /// </summary> public virtual void Visit(IFunctionPointerTypeReference functionPointerTypeReference) { this.Visit((ITypeReference)functionPointerTypeReference); }
/// <summary> /// Performs some computation with the given function pointer type reference. /// </summary> public virtual void Visit(IFunctionPointerTypeReference functionPointerTypeReference) { }
public IndirectMethodCallInstruction(uint label, IVariable result, IVariable pointer, IFunctionPointerTypeReference function, IEnumerable <IVariable> arguments) : base(label, result) { this.Arguments = new List <IVariable>(arguments); this.Pointer = pointer; this.Function = function; }
/// <summary> /// Rewrites the given function pointer type reference. /// </summary> public virtual IFunctionPointerTypeReference Rewrite(IFunctionPointerTypeReference functionPointerTypeReference) { return functionPointerTypeReference; }
public override string GetTypeName(ITypeReference type, NameFormattingOptions formattingOptions) { Contract.Requires(type != null); Contract.Ensures(Contract.Result <string>() != null); if (type is Dummy) { return("Microsoft.Cci.DummyTypeReference"); } if ((formattingOptions & NameFormattingOptions.UseTypeKeywords) != 0) { switch (type.TypeCode) { case PrimitiveTypeCode.Boolean: return("Boolean"); case PrimitiveTypeCode.Char: return("Char"); case PrimitiveTypeCode.Float32: return("Float"); case PrimitiveTypeCode.Float64: return("Double"); case PrimitiveTypeCode.Int16: return("Short"); case PrimitiveTypeCode.Int32: return("Integer"); case PrimitiveTypeCode.Int64: return("Long"); case PrimitiveTypeCode.Int8: return("SByte"); case PrimitiveTypeCode.String: return("String"); case PrimitiveTypeCode.UInt16: return("UShort"); case PrimitiveTypeCode.UInt32: return("UInteger"); case PrimitiveTypeCode.UInt64: return("ULong"); case PrimitiveTypeCode.UInt8: return("Byte"); case PrimitiveTypeCode.Void: { Contract.Assert(false); throw new InvalidOperationException(); } case PrimitiveTypeCode.NotPrimitive: if (TypeHelper.TypesAreEquivalent(type, type.PlatformType.SystemDecimal)) { return("Decimal"); } if (TypeHelper.TypesAreEquivalent(type, type.PlatformType.SystemObject)) { return("Object"); } break; } } IArrayTypeReference /*?*/ arrayType = type as IArrayTypeReference; if (arrayType != null) { return(this.GetArrayTypeName(arrayType, formattingOptions)); } IFunctionPointerTypeReference /*?*/ functionPointerType = type as IFunctionPointerTypeReference; if (functionPointerType != null) { return(this.GetFunctionPointerTypeName(functionPointerType, formattingOptions)); } IGenericTypeParameterReference /*?*/ genericTypeParam = type as IGenericTypeParameterReference; if (genericTypeParam != null) { return(this.GetGenericTypeParameterName(genericTypeParam, formattingOptions)); } IGenericMethodParameterReference /*?*/ genericMethodParam = type as IGenericMethodParameterReference; if (genericMethodParam != null) { return(this.GetGenericMethodParameterName(genericMethodParam, formattingOptions)); } IGenericTypeInstanceReference /*?*/ genericInstance = type as IGenericTypeInstanceReference; if (genericInstance != null) { return(this.GetGenericTypeInstanceName(genericInstance, formattingOptions)); } INestedTypeReference /*?*/ ntTypeDef = type as INestedTypeReference; if (ntTypeDef != null) { return(this.GetNestedTypeName(ntTypeDef, formattingOptions)); } INamespaceTypeReference /*?*/ nsTypeDef = type as INamespaceTypeReference; if (nsTypeDef != null) { return(this.GetNamespaceTypeName(nsTypeDef, formattingOptions)); } IPointerTypeReference /*?*/ pointerType = type as IPointerTypeReference; if (pointerType != null) { return(this.GetPointerTypeName(pointerType, formattingOptions)); } IManagedPointerTypeReference /*?*/ managedPointerType = type as IManagedPointerTypeReference; if (managedPointerType != null) { return(this.GetManagedPointerTypeName(managedPointerType, formattingOptions)); } IModifiedTypeReference /*?*/ modifiedType = type as IModifiedTypeReference; if (modifiedType != null) { return(this.GetModifiedTypeName(modifiedType, formattingOptions)); } if (type.ResolvedType != type && !(type.ResolvedType is Dummy)) { return(this.GetTypeName(type.ResolvedType, formattingOptions)); } return("unknown type: " + type.GetType().ToString()); }
public override void TraverseChildren(IFunctionPointerTypeReference functionPointerTypeReference) { base.TraverseChildren(functionPointerTypeReference); }
public virtual void onMetadataElement(IFunctionPointerTypeReference functionPointerTypeReference) { }
public IndirectMethodCallExpression(IVariable pointer, IFunctionPointerTypeReference function, IEnumerable <IVariable> arguments) { this.Arguments = new List <IVariable>(arguments); this.Pointer = pointer; this.Function = function; }
//^ ensures this.path.Count == old(this.path.Count); /// <summary> /// Performs some computation with the given function pointer type reference. /// </summary> /// <param name="functionPointerTypeReference"></param> public virtual void Visit(IFunctionPointerTypeReference functionPointerTypeReference) { if (this.stopTraversal) return; //^ int oldCount = this.path.Count; this.path.Push(functionPointerTypeReference); this.Visit(functionPointerTypeReference.Type); this.Visit(functionPointerTypeReference.Parameters); this.Visit(functionPointerTypeReference.ExtraArgumentTypes); if (functionPointerTypeReference.ReturnValueIsModified) this.Visit(functionPointerTypeReference.ReturnValueCustomModifiers); //^ assume this.path.Count == oldCount+1; //True because all of the virtual methods of this class promise not decrease this.path.Count. this.path.Pop(); }
public void Visit(IFunctionPointerTypeReference functionPointerTypeReference) { this.traverser.Traverse(functionPointerTypeReference); }
/// <summary> /// Use this routine, rather than ITypeReference.Dispatch, to call the appropriate derived overload of an ITypeReference. /// The former routine will call Visit(INamespaceTypeDefinition) rather than Visit(INamespaceTypeReference), etc., /// in the case where a definition is used as a reference to itself. /// </summary> /// <param name="typeReference">A reference to a type definition. Note that a type definition can serve as a reference to itself.</param> protected void DispatchAsReference(ITypeReference typeReference) { INamespaceTypeReference namespaceTypeReference = typeReference.AsNamespaceTypeReference; if (namespaceTypeReference != null) { this.Visit(namespaceTypeReference); return; } IGenericTypeInstanceReference genericTypeInstanceReference = typeReference.AsGenericTypeInstanceReference; if (genericTypeInstanceReference != null) { this.Visit(genericTypeInstanceReference); return; } INestedTypeReference nestedTypeReference = typeReference.AsNestedTypeReference; if (nestedTypeReference != null) { this.Visit(nestedTypeReference); return; } IArrayTypeReference arrayTypeReference = typeReference as IArrayTypeReference; if (arrayTypeReference != null) { this.Visit(arrayTypeReference); return; } IGenericTypeParameterReference genericTypeParameterReference = typeReference.AsGenericTypeParameterReference; if (genericTypeParameterReference != null) { this.Visit(genericTypeParameterReference); return; } IGenericMethodParameterReference genericMethodParameterReference = typeReference.AsGenericMethodParameterReference; if (genericMethodParameterReference != null) { this.Visit(genericMethodParameterReference); return; } IPointerTypeReference pointerTypeReference = typeReference as IPointerTypeReference; if (pointerTypeReference != null) { this.Visit(pointerTypeReference); return; } IFunctionPointerTypeReference functionPointerTypeReference = typeReference as IFunctionPointerTypeReference; if (functionPointerTypeReference != null) { this.Visit(functionPointerTypeReference); return; } IModifiedTypeReference modifiedTypeReference = typeReference as IModifiedTypeReference; if (modifiedTypeReference != null) { this.Visit(modifiedTypeReference); return; } }
/// <summary> /// Performs some computation with the given function pointer type reference. /// </summary> public void Visit(IFunctionPointerTypeReference functionPointerTypeReference) { this.Visit((ITypeReference)functionPointerTypeReference); if (functionPointerTypeReference.Type is Dummy) this.ReportError(MetadataError.IncompleteNode, functionPointerTypeReference, "Type"); if ((functionPointerTypeReference.CallingConvention & CallingConvention.ExplicitThis) != 0 && functionPointerTypeReference.IsStatic) this.ReportError(MetadataError.MethodsCalledWithExplicitThisParametersMustNotBeStatic, functionPointerTypeReference); }