public PolicyData( string name, string group, string description, IClientData clientData, string typeName, string methodName, BindingFlags bindingFlags, MethodFlags methodFlags, PolicyFlags policyFlags, IPlugin plugin, long token ) { this.kind = IdentifierKind.PolicyData; this.id = AttributeOps.GetObjectId(this); this.name = name; this.group = group; this.description = description; this.clientData = clientData; this.typeName = typeName; this.methodName = methodName; this.bindingFlags = bindingFlags; this.methodFlags = methodFlags; this.policyFlags = policyFlags; this.plugin = plugin; this.token = token; }
public override Vertex WriteVertex(NodeFactory factory) { Vertex containingType = _containingTypeSig.WriteVertex(factory); Vertex methodSig = _methodSig.WriteVertex(factory); Vertex methodNameAndSig = GetNativeWriter(factory).GetMethodNameAndSigSignature(_method.Name, methodSig); Debug.Assert(_instantiationArgsSig == null || (_method.HasInstantiation && _method.Instantiation.Length == _instantiationArgsSig.Length)); Vertex[] args = null; MethodFlags flags = 0; if (_method.HasInstantiation) { flags |= MethodFlags.HasInstantiation; args = new Vertex[_method.Instantiation.Length]; for (int i = 0; i < args.Length; i++) { args[i] = _instantiationArgsSig[i].WriteVertex(factory); } } Vertex signature = GetNativeWriter(factory).GetMethodSignature((uint)flags, 0, containingType, methodNameAndSig, args); return(SetSavedVertex(factory.MetadataManager.NativeLayoutInfo.LdTokenInfoSection.Place(signature))); }
/// <summary> /// Constructs a new method declaration. /// </summary> /// <param name="handle">The method handle (may be an empty handle).</param> /// <param name="returnType">The return type.</param> /// <param name="flags">Custom method flags.</param> public MethodDeclaration( MethodHandle handle, TypeNode returnType, MethodFlags flags) : this(handle, returnType, null, flags) { }
public static MethodDefinition[] GetMethods(this TypeDefinition type , string name, MethodFlags flags = MethodFlags.All, params TypeReference[] arguments) { bool argsSpec = arguments != null && arguments.Length > 0; return type.Methods.Where(md => { if (md.Name != name) return false; if ( md.IsPublic && (flags & MethodFlags. Public) == 0) return false; if (!md.IsPublic && (flags & MethodFlags.NonPublic) == 0) return false; if ( md.IsStatic && (flags & MethodFlags.Static ) == 0) return false; if (!md.IsStatic && (flags & MethodFlags.Instance) == 0) return false; if (!argsSpec) return true; if (arguments.Length != md.Parameters.Count) return false; for (int i = 0; i < arguments.Length; i++) if (arguments[i] != md.Parameters[i].ParameterType) return false; return true; }).ToArray(); }
public void Read(MethodDef method) { gpContext = GenericParamContext.Create(method); flags = (MethodFlags)reader.ReadByte(); if (HasDelegateType) { delegateType = Resolve <TypeDef>(ReadTypeToken()); if (!DotNetUtils.DerivesFromDelegate(delegateType)) { throw new ApplicationException("Invalid delegate type"); } } if (HasLocals) { ReadLocals((int)reader.Read7BitEncodedUInt32()); } if (HasInstructions) { ReadInstructions((int)reader.Read7BitEncodedUInt32()); } if (HasExceptionHandlers) { ReadExceptionHandlers((int)reader.Read7BitEncodedUInt32()); } }
public void AddMethod(int inlet, MethodObject d) { DynamicMethodObject dyn = DynamicMethods.Create(d); m_object = dyn; methodflags |= MethodFlags.f_anything; }
/// <summary> /// Constructs a new method declaration with an implicit handle. /// </summary> /// <param name="name">The method name.</param> /// <param name="returnType">The return type.</param> /// <param name="flags">Custom method flags.</param> public MethodDeclaration( string name, TypeNode returnType, MethodFlags flags) : this(MethodHandle.Create(name), returnType, flags) { }
/// <summary> /// 获取指定类的方法 /// </summary> /// <param name="type">指定获取类的<see cref="Type"/></param> /// <param name="methodFlags">根据查找类型,获得相应方法</param> public ActionHelper(Type type, MethodFlags methodFlags) { this.MethodFlag = methodFlags; MethodInfo[] methodInfos = GetMethodInfos(type, methodFlags); this._actionDispatchers = GetMethodInfos(type, methodInfos, methodFlags); }
void AddMethod(List <uint> array, string method, string type, MethodFlags flags) { array.Add(handler(method)); // signature array.Add(handler(Regex.Replace(method, "[^,]", ""))); // parameters array.Add(handler(type)); // type array.Add(handler("")); // tag array.Add((uint)flags); // flags }
public static MethodDefinition[] GetMethods(this TypeDefinition type, CecilContext context, string name, MethodFlags flags = MethodFlags.All, params Type [] arguments) { return GetMethods(type, name, flags, arguments.Select(t => { if (context.Comparer.AssemblyEquals(type.Module.Assembly, t.Assembly)) return context.Resolver.GetType(t); return context.PrimaryAssembly.MainModule.Import(t); }).ToArray()); }
public MethodInfo(string name, PropertyInfo returnVal, MethodFlags flags, List <PropertyInfo>?arguments, List <string?>?defaultArguments) { Name = name; ReturnVal = returnVal; Flags = flags; Arguments = arguments; DefaultArguments = defaultArguments; }
internal MethodDesc(ExecutionEngine executionEngine, MethodBase reflMethod) { executionEngine.Context._methods.Add(reflMethod, this); _executionEngine = executionEngine; _reflMethod = reflMethod; _metadataToken = reflMethod.MetadataToken; _instantiation = reflMethod.IsGenericMethod ? reflMethod.GetGenericArguments().Select(t => executionEngine.ResolveType(t)).ToArray() : null; _declaringType = executionEngine.ResolveType(reflMethod.DeclaringType); _attributes = reflMethod.Attributes; _flags = GetConstructorFlags(); _returnType = executionEngine.ResolveType((reflMethod is MethodInfo methodInfo) ? methodInfo.ReturnType : typeof(void)); }
public override Vertex WriteVertex(NodeFactory factory) { Vertex containingType = GetContainingTypeVertex(factory); Vertex methodSig = _methodSig.WriteVertex(factory); Vertex methodNameAndSig = GetNativeWriter(factory).GetMethodNameAndSigSignature(_method.Name, methodSig); Vertex[] args = null; MethodFlags flags = 0; if (_method.HasInstantiation) { Debug.Assert(_instantiationArgsSig == null || (_instantiationArgsSig != null && _method.Instantiation.Length == _instantiationArgsSig.Length)); flags |= MethodFlags.HasInstantiation; args = new Vertex[_method.Instantiation.Length]; for (int i = 0; i < args.Length; i++) { if ((_flags & MethodEntryFlags.CreateInstantiatedSignature) != 0) { IEETypeNode eetypeNode = factory.NecessaryTypeSymbol(_method.Instantiation[i]); uint typeIndex = factory.MetadataManager.NativeLayoutInfo.ExternalReferences.GetIndex(eetypeNode); args[i] = GetNativeWriter(factory).GetExternalTypeSignature(typeIndex); } else { args[i] = _instantiationArgsSig[i].WriteVertex(factory); } } } uint fptrReferenceId = 0; if ((_flags & MethodEntryFlags.SaveEntryPoint) != 0) { flags |= MethodFlags.HasFunctionPointer; bool getUnboxingStub = _method.OwningType.IsValueType && !_method.Signature.IsStatic; IMethodNode methodEntryPointNode = factory.MethodEntrypoint(_method, getUnboxingStub); fptrReferenceId = factory.MetadataManager.NativeLayoutInfo.ExternalReferences.GetIndex(methodEntryPointNode); if (getUnboxingStub) { flags |= MethodFlags.IsUnboxingStub; } if (_method.IsCanonicalMethod(CanonicalFormKind.Universal)) { flags |= MethodFlags.FunctionPointerIsUSG; } } return(GetNativeWriter(factory).GetMethodSignature((uint)flags, fptrReferenceId, containingType, methodNameAndSig, args)); }
public static MethodDef[] GetMethods(this TypeDef type, string name, MethodFlags flags = MethodFlags.All, params ITypeDefOrRef[] arguments) { bool argsSpec = arguments != null && arguments.Length > 0; return(type.Methods.Where(md => { if (md.Name != name) { return false; } if (md.IsPublic && (flags & MethodFlags.Public) == 0) { return false; } if (!md.IsPublic && (flags & MethodFlags.NonPublic) == 0) { return false; } if (md.IsStatic && (flags & MethodFlags.Static) == 0) { return false; } if (!md.IsStatic && (flags & MethodFlags.Instance) == 0) { return false; } if (!argsSpec) { return true; } var start = md.IsStatic ? 0 : 1; if (arguments.Length + start != md.Parameters.Count) { return false; } for (int i = 0; i < arguments.Length; i++) { if (!comp.Equals(arguments[i], md.Parameters[i + start].Type)) { return false; } } return true; }).ToArray()); }
private static MethodInfo[] GetMethodInfos(Type type, MethodFlags methodFlags) { BindingFlags bindingFlags = BindingFlags.InvokeMethod | BindingFlags.Instance; if (methodFlags.Equals(MethodFlags.Default)) { bindingFlags |= BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; return(type.GetMethods(bindingFlags)); } if ((methodFlags & MethodFlags.Base) == MethodFlags.Default) { bindingFlags |= BindingFlags.DeclaredOnly; } if ((methodFlags & MethodFlags.Static) == MethodFlags.Static) { bindingFlags |= BindingFlags.Static; } if ((methodFlags & MethodFlags.Public) == MethodFlags.Public) { bindingFlags |= BindingFlags.Public; } if ((methodFlags & MethodFlags.Private) == MethodFlags.Private) { if ((bindingFlags & BindingFlags.NonPublic).ToVar <int>() == 0) { bindingFlags |= BindingFlags.NonPublic; } } if ((methodFlags & MethodFlags.Protected) == MethodFlags.Protected) { if ((bindingFlags & BindingFlags.NonPublic).ToVar <int>() == 0) { bindingFlags |= BindingFlags.NonPublic; } } if ((methodFlags & MethodFlags.Internal) == MethodFlags.Internal) { if ((bindingFlags & BindingFlags.NonPublic).ToVar <int>() == 0) { bindingFlags |= BindingFlags.NonPublic; } } return(type.GetMethods(bindingFlags)); }
public void AddMethod(int inlet, Symbol sel, MethodPointer d) { DynamicMethodPointer dyn = DynamicMethods.Create(d); if (inlet == 0 && sel == _pointer) { m_pointer = dyn; methodflags |= MethodFlags.f_pointer; } else { AddMethodIntern(inlet, sel, Kind.k_pointer, dyn); } }
public void Read(SignatureReader rdr) { f = (MethodFlags)rdr.ReadByte(); if ((f & MethodFlags.Generic) == MethodFlags.Generic) { gc = rdr.ReadCompressedInt(); } int c = rdr.ReadCompressedInt(); rt = new RetTypeElement(); rt.Read(rdr); ps = new ParamCollection(); ps.Read(rdr, c); }
public void AddMethod(int inlet, Symbol sel, MethodAnything d) { DynamicMethodAnything dyn = DynamicMethods.Create(d); if (inlet == 0 && sel == _) { m_anything = dyn; methodflags |= MethodFlags.f_anything; } else { AddMethodIntern(inlet, sel, Kind.k_anything, dyn); } }
public void AddMethod(int inlet, Symbol sel, MethodList d) { DynamicMethodList dyn = DynamicMethods.Create(d); if (inlet == 0 && sel == _list) { m_list = dyn; methodflags |= MethodFlags.f_list; } else { AddMethodIntern(inlet, sel, Kind.k_list, dyn); } }
internal RuntimeIshtarMethod DefineMethod(string name, VeinClass returnType, MethodFlags flags, params VeinArgumentRef[] args) { var method = new RuntimeIshtarMethod(name, flags, returnType, this, args); method.Arguments.AddRange(args); if (Methods.Any(x => x.Name.Equals(method.Name))) { throw new Exception(); } Methods.Add(method); return(method); }
public void AddMethod(int inlet, Symbol sel, MethodSymbol d) { DynamicMethodSymbol dyn = DynamicMethods.Create(d); if (inlet == 0 && sel == _symbol) { m_symbol = dyn; methodflags |= MethodFlags.f_symbol; } else { AddMethodIntern(inlet, sel, Kind.k_symbol, dyn); } }
/////////////////////////////////////////////////////////////////////// public static bool HasFlags( MethodFlags flags, MethodFlags hasFlags, bool all ) { if (all) { return((flags & hasFlags) == hasFlags); } else { return((flags & hasFlags) != MethodFlags.None); } }
internal MethodRow( int rva, MethodImplFlags implFlags, MethodFlags flags, uint name, uint signature, uint paramList) { this.RVA = rva; this.ImplFlags = implFlags; this.Flags = flags; this.Name = name; this.Signature = signature; this.ParamList = paramList; }
/// <summary> /// Constructs a new method declaration. /// </summary> /// <param name="handle">The method handle (may be an empty handle).</param> /// <param name="returnType">The return type.</param> /// <param name="source">The source method.</param> /// <param name="flags">Custom method flags.</param> public MethodDeclaration( MethodHandle handle, TypeNode returnType, MethodBase source, MethodFlags flags) { Handle = handle; ReturnType = returnType ?? throw new ArgumentNullException(nameof(returnType)); Source = source; Flags = flags; if (flags == MethodFlags.None && Source != null) { Flags = Method.ResolveMethodFlags(source); } }
public IodineMethod( IodineModule module, IodineString name, CodeObject bytecode, IodineTuple parameters, MethodFlags flags, IodineObject[] defaultValues, int defaultStart = 0 ) : base(MethodTypeDef) { Module = module; Bytecode = bytecode; ParameterCount = Parameters.Count; Variadic = (flags & MethodFlags.AcceptsVarArgs) != 0; AcceptsKeywordArgs = (flags & MethodFlags.AcceptsKwargs) != 0; HasDefaultValues = (flags & MethodFlags.HasDefaultParameters) != 0; DefaultValuesStartIndex = defaultStart; DefaultValues = defaultValues; SetParameters(Parameters, parameters); Name = name.ToString(); SetAttribute("__doc__", IodineString.Empty); SetAttribute("__invoke__", new BuiltinMethodCallback(invoke, this)); if (AcceptsKeywordArgs) { var lastParameter = Parameters.Last() as IodineNamedParameter; KwargsParameter = lastParameter.Name; if (Variadic) { var secondToLastParameter = Parameters [Parameters.Count - 2] as IodineNamedParameter; VarargsParameter = secondToLastParameter.Name; } } else if (Variadic) { var lastParameter = Parameters.Last() as IodineNamedParameter; VarargsParameter = lastParameter.Name; } }
private void AddMethodIntern(int inlet, Symbol sel, Kind k, Delegate d) { // add to map if (m_map.Length <= inlet) { ResizeArray(ref m_map, inlet + 1); } Hashtable h = m_map[inlet]; if (h == null) { m_map[inlet] = h = new Hashtable(); } h[sel] = new MapValue(k, d); methodflags |= MethodFlags.f_anything; }
public void read() { flags = (MethodFlags)reader.ReadByte(); delegateType = resolve <TypeDef>(readTypeToken()); if (!DotNetUtils.derivesFromDelegate(delegateType)) { throw new ApplicationException("Invalid delegate type"); } if (HasLocals) { readLocals((int)reader.Read7BitEncodedUInt32()); } if (HasInstructions) { ReadInstructions((int)reader.Read7BitEncodedUInt32()); } if (HasExceptionHandlers) { readExceptionHandlers((int)reader.Read7BitEncodedUInt32()); } }
internal MethodDesc GetMethod(ref NativeParser parser, out RuntimeSignature methodNameSig, out RuntimeSignature methodSig) { MethodFlags flags = (MethodFlags)parser.GetUnsigned(); IntPtr functionPointer = IntPtr.Zero; if ((flags & MethodFlags.HasFunctionPointer) != 0) { functionPointer = GetExternalReferencePointer(parser.GetUnsigned()); } DefType containingType = (DefType)GetType(ref parser); MethodNameAndSignature nameAndSignature = TypeLoaderEnvironment.Instance.GetMethodNameAndSignature(ref parser, _module.Handle, out methodNameSig, out methodSig); bool unboxingStub = (flags & MethodFlags.IsUnboxingStub) != 0; MethodDesc retVal = null; if ((flags & MethodFlags.HasInstantiation) != 0) { TypeDesc[] typeArguments = GetTypeSequence(ref parser); Debug.Assert(typeArguments.Length > 0); retVal = this._typeSystemContext.ResolveGenericMethodInstantiation(unboxingStub, containingType, nameAndSignature, new Instantiation(typeArguments), functionPointer, (flags & MethodFlags.FunctionPointerIsUSG) != 0); } else { retVal = this._typeSystemContext.ResolveRuntimeMethod(unboxingStub, containingType, nameAndSignature, functionPointer, (flags & MethodFlags.FunctionPointerIsUSG) != 0); } if ((flags & MethodFlags.FunctionPointerIsUSG) != 0) { // TODO, consider a change such that if a USG function pointer is passed in, but we have // a way to get a non-usg pointer, that may be preferable Debug.Assert(retVal.UsgFunctionPointer != IntPtr.Zero); } return(retVal); }
public void AddMethod(int inlet, Symbol sel, MethodSymbol d) { DynamicMethodSymbol dyn = DynamicMethods.Create(d); if (inlet == 0 && sel == _symbol) { m_symbol = dyn; methodflags |= MethodFlags.f_symbol; } else AddMethodIntern(inlet, sel, Kind.k_symbol, dyn); }
public void AddMethod(int inlet, Symbol sel, MethodPointer d) { DynamicMethodPointer dyn = DynamicMethods.Create(d); if (inlet == 0 && sel == _pointer) { m_pointer = dyn; methodflags |= MethodFlags.f_pointer; } else AddMethodIntern(inlet, sel, Kind.k_pointer, dyn); }
private void AddMethodIntern(int inlet, Symbol sel, Kind k, Delegate d) { // add to map if (m_map.Length <= inlet) ResizeArray(ref m_map, inlet + 1); Hashtable h = m_map[inlet]; if(h == null) m_map[inlet] = h = new Hashtable(); h[sel] = new MapValue(k, d); methodflags |= MethodFlags.f_anything; }
public void AddMethod(int inlet, Symbol sel, MethodAnything d) { DynamicMethodAnything dyn = DynamicMethods.Create(d); if (inlet == 0 && sel == _) { m_anything = dyn; methodflags |= MethodFlags.f_anything; } else AddMethodIntern(inlet, sel, Kind.k_anything, dyn); }
public void AddMethod(int inlet, Symbol sel, MethodList d) { DynamicMethodList dyn = DynamicMethods.Create(d); if (inlet == 0 && sel == _list) { m_list = dyn; methodflags |= MethodFlags.f_list; } else AddMethodIntern(inlet, sel, Kind.k_list, dyn); }
/// <summary> /// Adds the given flags to this declaration. /// </summary> /// <param name="flags">The flags to add.</param> public MethodDeclaration AddFlags(MethodFlags flags) => new MethodDeclaration(Handle, ReturnType, Source, Flags | flags);
public static MethodDefinition GetMethod(this TypeDefinition type, CecilContext context, string name, MethodFlags flags = MethodFlags.All, params Type [] arguments) { return GetMethods(type, context, name, flags, arguments).FirstOrDefault(); }
/// <summary> /// The constructor automatically registeres the plugin in FreeImage. /// To do this it prepares a FreeImage defined structure with function pointers /// to the implemented functions or null if not implemented. /// Before registing the functions they are pinned in memory so the garbage collector /// can't move them around in memory after we passed there addresses to FreeImage. /// </summary> public LocalPlugin() { implementedMethods = GetImplementedMethods(); if ((implementedMethods & MethodFlags.DescriptionProc) != 0) { plugin.descriptionProc = DescriptionProc; } if ((implementedMethods & MethodFlags.ExtensionListProc) != 0) { plugin.extensionListProc = ExtensionListProc; } if ((implementedMethods & MethodFlags.RegExprProc) != 0) { plugin.regExprProc = RegExprProc; } if ((implementedMethods & MethodFlags.OpenProc) != 0) { plugin.openProc = OpenProc; } if ((implementedMethods & MethodFlags.CloseProc) != 0) { plugin.closeProc = CloseProc; } if ((implementedMethods & MethodFlags.PageCountProc) != 0) { plugin.pageCountProc = PageCountProc; } if ((implementedMethods & MethodFlags.PageCapabilityProc) != 0) { plugin.pageCapabilityProc = PageCapabilityProc; } if ((implementedMethods & MethodFlags.LoadProc) != 0) { plugin.loadProc = LoadProc; } if ((implementedMethods & MethodFlags.SaveProc) != 0) { plugin.saveProc = SaveProc; } if ((implementedMethods & MethodFlags.ValidateProc) != 0) { plugin.validateProc = ValidateProc; } if ((implementedMethods & MethodFlags.MimeProc) != 0) { plugin.mimeProc = MimeProc; } if ((implementedMethods & MethodFlags.SupportsExportBPPProc) != 0) { plugin.supportsExportBPPProc = SupportsExportBPPProc; } if ((implementedMethods & MethodFlags.SupportsExportTypeProc) != 0) { plugin.supportsExportTypeProc = SupportsExportTypeProc; } if ((implementedMethods & MethodFlags.SupportsICCProfilesProc) != 0) { plugin.supportsICCProfilesProc = SupportsICCProfilesProc; } // FormatProc is always implemented plugin.formatProc = FormatProc; // InitProc is the register call back. initProc = RegisterProc; // Register the plugin. The result will be saved and can be accessed later. registered = FreeImage.RegisterLocalPlugin(initProc, null, null, null, null) != FREE_IMAGE_FORMAT.FIF_UNKNOWN; if (registered) { PluginRepository.RegisterLocalPlugin(this); } }
private void ParseStaticConstructor(TypeNode parentType, AttributeList attributes, TokenList modifierTokens, SourceContextList modifierContexts, MethodFlags flags, object sctx, SourceContext idCtx, TokenSet followers){ if (parentType is Interface){ this.HandleError(idCtx, Error.InterfacesCannotContainConstructors); }else{ for (int i = 0, n = modifierTokens.Length; i < n; i++){ Token tok = modifierTokens[i]; if (tok == Token.Static || tok == Token.Extern) continue; if (tok == Token.Unsafe){ if (!this.allowUnsafeCode){ this.allowUnsafeCode = true; this.HandleError(modifierContexts[i], Error.IllegalUnsafe); } this.inUnsafeCode = true; continue; } this.HandleError(modifierContexts[i], Error.StaticConstructorWithAccessModifiers); } } StaticInitializer c = new StaticInitializer(parentType, attributes, new Block(new StatementList(2), this.insideCheckedBlock, this.insideUncheckedBlock, this.inUnsafeCode), this.TypeExpressionFor(Token.Void)); c.Name = new Identifier(".cctor", idCtx); parentType.Members.Add(c); c.Flags |= flags; c.HasCompilerGeneratedSignature = false; ParameterList plist = c.Parameters = this.ParseParameters(Token.RightParenthesis, followers|Token.LeftBrace|Token.Colon); if (plist != null && plist.Count > 0){ this.HandleError(plist[0].SourceContext, Error.StaticConstParam); c.Parameters = null; } if (this.currentToken == Token.Colon){ SourceContext ctx = this.scanner.CurrentSourceContext; this.GetNextToken(); if (this.currentToken == Token.This || this.currentToken == Token.Base){ ctx.EndPos = this.scanner.endPos; this.GetNextToken(); if (this.currentToken == Token.LeftParenthesis){ SourceContext lpCtx = this.scanner.CurrentSourceContext; this.Skip(Token.LeftParenthesis); this.ParseArgumentList(followers|Token.LeftBrace, lpCtx, out ctx.EndPos); } }else this.SkipTo(followers|Token.LeftBrace, Error.None); this.HandleError(ctx, Error.StaticConstructorWithExplicitConstructorCall); } Block b = this.ParseBody(c, sctx, followers); c.Body.Statements.Add(new FieldInitializerBlock(parentType, true)); c.Body.Statements.Add(b); }
protected static MemberList WeedOutNonSpecialMethods(MemberList members, MethodFlags mask) { if(members == null) return null; bool membersOK = true; for(int i = 0, n = members.Count; i < n; i++) { Method m = members[i] as Method; if(m == null || (m.Flags & mask) == 0) { membersOK = false; break; } } if(membersOK) return members; MemberList newMembers = new MemberList(); for(int i = 0, n = members.Count; i < n; i++) { Method m = members[i] as Method; if(m == null || (m.Flags & mask) == 0) continue; newMembers.Add(m); } return newMembers; }
public static MethodFlags GetVisibilityUnion(MethodFlags vis1, MethodFlags vis2) { vis1 &= MethodFlags.MethodAccessMask; vis2 &= MethodFlags.MethodAccessMask; switch(vis1) { case MethodFlags.Public: return MethodFlags.Public; case MethodFlags.Assembly: switch(vis2) { case MethodFlags.Public: return MethodFlags.Public; case MethodFlags.FamORAssem: case MethodFlags.Family: return MethodFlags.FamORAssem; default: return vis1; } case MethodFlags.FamANDAssem: switch(vis2) { case MethodFlags.Public: return MethodFlags.Public; case MethodFlags.Assembly: return MethodFlags.Assembly; case MethodFlags.FamORAssem: return MethodFlags.FamORAssem; case MethodFlags.Family: return MethodFlags.Family; default: return vis1; } case MethodFlags.FamORAssem: switch(vis2) { case MethodFlags.Public: return MethodFlags.Public; default: return vis1; } case MethodFlags.Family: switch(vis2) { case MethodFlags.Public: return MethodFlags.Public; case MethodFlags.FamORAssem: case MethodFlags.Assembly: return MethodFlags.FamORAssem; default: return vis1; } default: return vis2; } }
private MethodFlags ParseAccessorModifiers(MethodFlags commonFlags){ MethodFlags result = (MethodFlags)0; SourceContext sctx = this.scanner.CurrentSourceContext; switch(this.currentToken){ case Token.Internal: result = MethodFlags.Assembly; this.GetNextToken(); if (this.currentToken == Token.Protected){ result = MethodFlags.FamORAssem; this.GetNextToken(); sctx.EndPos = this.scanner.endPos; } break; case Token.Protected: result = MethodFlags.Family; this.GetNextToken(); if (this.currentToken == Token.Internal){ result = MethodFlags.FamORAssem; this.GetNextToken(); sctx.EndPos = this.scanner.endPos; } break; case Token.Private: result = MethodFlags.Private; this.GetNextToken(); break; default: Debug.Assert(false); return commonFlags; } //TODO: check that result is compatible with commonFlags return result | (commonFlags & ~MethodFlags.MethodAccessMask); }
internal static bool MethodFlagsTest(MethodFlags flag, MethodFlags target) { if ((flag & target) == target) return true; else return false; }
private static void NewClass(ClassPtr ptr, Symbol sym) { Internal.pass.klass = null; try { string name = sym.ToString(); // load assembly according to name string file = SearchPath(name + ".dll"); if (file.Length == 0) return; // throw new ArgumentException("Assembly file " + name + " not found"); Assembly assembly = Assembly.LoadFile(file); if (assembly == null) return; // throw new ArgumentException("Assembly " + name + " could not be loaded"); Type exttp = assembly.GetType(name); if (exttp == null) throw new ArgumentException("Class " + name + " could not be found"); Class klass = new Class(ptr, exttp); // create dummy external ConstructorInfo ctor = exttp.GetConstructor(System.Type.EmptyTypes); if (ctor == null) throw new MissingMethodException("External class must have a default constructor"); Internal.pass.klass = klass; Internal.extptr.Clear(); External dummy = (External)ctor.Invoke(null); // reset flags methodflags = MethodFlags.f_none; // call Setup method MethodInfo setup = exttp.GetMethod("Setup",BindingFlags.NonPublic|BindingFlags.Static,null, new Type[1] { exttp },null); if (setup == null) throw new MissingMethodException("External class must have a Setup function"); object ret = setup.Invoke(exttp, new object[1] { dummy }); ClassType classflags; try { classflags = (ClassType)ret; } catch { classflags = ClassType.Default; } // set callbacks RegisterClass(ptr, sym, classflags, methodflags); } catch (Exception exc) { Internal.pass.klass = null; PostError(exc.ToString()); } }
// Changes the name of any method that's defined in a winmd that implements IClosable.Close() to 'Dispose' // so that managed consumers can call type.Dispose() directly (without casting to IDisposable). // This is identical to the behavior one sees when one uses ildasm's "/project" option to view the contents // of a winmd. void IWindowsRuntimeMetadataReaderHost.FixUpNameForMethodThatImplementsIClosable( PEFileToObjectModel peFileToObjectModel, uint methodDefRowId, MethodFlags flags, TypeBase parentModuleType, ref IName methodName ) { if (projectToCLRTypes) { INamespaceTypeDefinition parentNamespaceType = parentModuleType as INamespaceTypeDefinition; if (parentNamespaceType != null && IsWinMD(parentNamespaceType.ContainingUnitNamespace.Unit) && parentNamespaceType.IsClass) { // Is the method part of a class that is defined in a winmd? // Note: We don't care about structs since WinRT structs can't implement interfaces. uint paramCount; peFileToObjectModel.PEFileReader.GetParamInformation(methodDefRowId, out paramCount); if (paramCount == 0) { // Is this a method that takes 0 parameters? // Note: Desktop CLR doesn't check whether the method is public (or whether it is named Close) - so we don't either. uint methodImplStart, methodImplEnd; peFileToObjectModel.GetMethodImplInfoForType(parentModuleType, out methodImplStart, out methodImplEnd); // Does this method implement IClosable.Close()? for (uint methodImplIter = methodImplStart; methodImplIter < methodImplEnd; ++methodImplIter) { MethodImplRow methodImplRow = peFileToObjectModel.PEFileReader.MethodImplTable[methodImplIter]; uint tokenKind = methodImplRow.MethodBody & TokenTypeIds.TokenTypeMask; uint rowId = methodImplRow.MethodBody & TokenTypeIds.RIDMask; IMethodReference implementedMethod = peFileToObjectModel.GetMethodReferenceForToken(parentModuleType, methodImplRow.MethodDeclaration); INamespaceTypeReference implementedInterface = implementedMethod.ContainingType as INamespaceTypeReference; if (implementedInterface != null && tokenKind == TokenTypeIds.MethodDef && rowId == methodDefRowId) { string implementedInterfaceName = TypeHelper.GetTypeName(implementedInterface); // Note: We will see redirected type IDisposable here (instead of IClosable) since projection support is enabled. if (implementedInterfaceName == "System.IDisposable") { // Note: We have a bug here. We should be checking whether the class (or one of its base classes) already has a method // named Dispose before we introduce a new one with the same signature. However, CLR has the same bug - in this case, // the class ends up with two methods named Dispose with the same signature. If someone were to try calling class.Dispose() // in this case, they would see an error from the C# compiler (i.e. C# cannot resolve the ambiguity between the two identical // methods) - but calling either of the Dispose() methods via their respective interfaces (e.g. ((IDisposable)class).Dispose()) // should work. The case where we would end up with two Dispose() methods as described above should be very rare for a winmd // class. For now, we replicate the buggy CLR behavior since we want to avoid looking at all methods in the class / in all its // base classes (some of which may be in a different assembly) here. methodName = NameTable.GetNameFor("Dispose"); break; } } } } } } }
/// <summary> /// Returns true if this declaration has the given method flags. /// </summary> /// <param name="flags">The flags to check.</param> /// <returns>True, if this declaration has the given method flags.</returns> public bool HasFlags(MethodFlags flags) => (Flags & flags) != 0;
private bool HasFlag(MethodFlags flag) { EnsureMemberIsNotPending(); return (_flags & flag) == flag; }
/// <summary> /// Removes the given flags from this declaration. /// </summary> /// <param name="flags">The flags to remove.</param> public MethodDeclaration RemoveFlags(MethodFlags flags) => new MethodDeclaration(Handle, ReturnType, Source, Flags & ~flags);
/// <summary> /// The constructor automatically registeres the plugin in FreeImage. /// To do this it prepares a FreeImage defined structure with function pointers /// to the implemented functions or null if not implemented. /// Before registing the functions they are pinned in memory so the garbage collector /// can't move them around in memory after we passed there addresses to FreeImage. /// </summary> public LocalPlugin() { implementedMethods = GetImplementedMethods(); if ((implementedMethods & MethodFlags.DescriptionProc) != 0) { plugin.descriptionProc = new DescriptionProc(DescriptionProc); } if ((implementedMethods & MethodFlags.ExtensionListProc) != 0) { plugin.extensionListProc = new ExtensionListProc(ExtensionListProc); } if ((implementedMethods & MethodFlags.RegExprProc) != 0) { plugin.regExprProc = new RegExprProc(RegExprProc); } if ((implementedMethods & MethodFlags.OpenProc) != 0) { plugin.openProc = new OpenProc(OpenProc); } if ((implementedMethods & MethodFlags.CloseProc) != 0) { plugin.closeProc = new CloseProc(CloseProc); } if ((implementedMethods & MethodFlags.PageCountProc) != 0) { plugin.pageCountProc = new PageCountProc(PageCountProc); } if ((implementedMethods & MethodFlags.PageCapabilityProc) != 0) { plugin.pageCapabilityProc = new PageCapabilityProc(PageCapabilityProc); } if ((implementedMethods & MethodFlags.LoadProc) != 0) { plugin.loadProc = new LoadProc(LoadProc); } if ((implementedMethods & MethodFlags.SaveProc) != 0) { plugin.saveProc = new SaveProc(SaveProc); } if ((implementedMethods & MethodFlags.ValidateProc) != 0) { plugin.validateProc = new ValidateProc(ValidateProc); } if ((implementedMethods & MethodFlags.MimeProc) != 0) { plugin.mimeProc = new MimeProc(MimeProc); } if ((implementedMethods & MethodFlags.SupportsExportBPPProc) != 0) { plugin.supportsExportBPPProc = new SupportsExportBPPProc(SupportsExportBPPProc); } if ((implementedMethods & MethodFlags.SupportsExportTypeProc) != 0) { plugin.supportsExportTypeProc = new SupportsExportTypeProc(SupportsExportTypeProc); } if ((implementedMethods & MethodFlags.SupportsICCProfilesProc) != 0) { plugin.supportsICCProfilesProc = new SupportsICCProfilesProc(SupportsICCProfilesProc); } // FormatProc is always implemented plugin.formatProc = new FormatProc(FormatProc); // InitProc is the register call back. initProc = new InitProc(RegisterProc); // Register the plugin. The result will be saved and can be accessed later. registered = FreeImage.RegisterLocalPlugin(initProc, null, null, null, null) != FREE_IMAGE_FORMAT.FIF_UNKNOWN; if (registered) { PluginRepository.RegisterLocalPlugin(this); } }
void AddMethod(List<uint> array, string method, string type, MethodFlags flags) { array.Add(handler(method)); // signature array.Add(handler(Regex.Replace(method, "[^,]", ""))); // parameters array.Add(handler(type)); // type array.Add(handler("")); // tag array.Add((uint)flags); // flags }
private extern static bool RegisterClass(ClassPtr ptr, Symbol sym, ClassType cflags, MethodFlags mflags);