Пример #1
0
		public static bool DetermineIsInlinable(CompilerContext compiler, MemberCore method)
		{
			bool isInlinable = false;

			if (compiler.Settings.Inlining == InliningMode.None) {

				isInlinable = false;

			} else {

				bool potentiallyInlinable = false;

				if ((method.ModFlags & (Modifiers.STATIC | Modifiers.SEALED)) != 0 || 
				    (method.Parent.ModFlags & Modifiers.SEALED) != 0 || (method.ModFlags & Modifiers.VIRTUAL) == 0) {
					potentiallyInlinable = true;
				}

				bool isExplicit = false;

				if (potentiallyInlinable && (method.OptAttributes != null)) {
					isExplicit = method.OptAttributes.Contains (method.Parent.Module.PredefinedAttributes.InlineAttribute);
					if (compiler.Settings.Inlining == InliningMode.Explicit && isExplicit == false) {
						potentiallyInlinable = false;
					}
				}

				if (potentiallyInlinable) {
					var validator = new InlinableValidator (method);
					isInlinable = validator.Validate (compiler, isExplicit);
				}
			}

			return isInlinable;
		}