コード例 #1
0
ファイル: TypeDecl.cs プロジェクト: Ashod/Phalanger
		internal override void Emit(CodeGenerator/*!*/ codeGenerator)
		{
			Statistics.AST.AddNode("Class.MethodDecl");

			base.Emit(codeGenerator);

			// emit attributes on return value, generic and regular parameters:
			signature.Emit(codeGenerator);
			typeSignature.Emit(codeGenerator);

            if(method.IsDllImport) {
                //TODO: Support for DllImport
                Debug.Assert(false, "DllImport - not supported");
            } else if(!method.IsAbstract)
			{
                // returns immediately if the method is abstract:
				codeGenerator.EnterMethodDeclaration(method);

				// emits the arg-full overload:
				codeGenerator.EmitArgfullOverloadBody(method, body, entireDeclarationPosition, declarationBodyPosition);

				// restores original code generator settings:
				codeGenerator.LeaveMethodDeclaration();
			}
			else
			{
				// static abstract method is non-abstract in CLR => needs to have a body:
				if (method.IsStatic)
				{
					ILEmitter il = new ILEmitter(method.ArgFullInfo);
					il.Emit(OpCodes.Ldstr, method.DeclaringType.FullName);
					il.Emit(OpCodes.Ldstr, method.FullName);
					codeGenerator.EmitPhpException(il, Methods.PhpException.AbstractMethodCalled);
					il.Emit(OpCodes.Ldnull);
					il.Emit(OpCodes.Ret);
				}
			}

			// emits stubs for overridden/implemented methods and export stubs:
			codeGenerator.EmitOverrideAndExportStubs(method);
		}