예제 #1
0
        /// <include file='Doc/Nodes.xml' path='doc/method[@name="Emit"]/*'/>
        internal override void Emit(CodeGenerator /*!*/ codeGenerator)
        {
            Statistics.AST.AddNode("FunctionDecl");

            // marks a sequence point if function is declared here (i.e. is m-decl):
            //Note: this sequence point goes to the function where this function is declared not to this declared function!
            if (!function.IsLambda && function.Declaration.IsConditional)
            {
                codeGenerator.MarkSequencePoint(position.FirstLine, position.FirstColumn, position.LastLine, position.LastColumn + 2);
            }

            // emits attributes on the function itself, its return value, type parameters and regular parameters:
            attributes.Emit(codeGenerator, this);
            signature.Emit(codeGenerator);
            typeSignature.Emit(codeGenerator);

            // prepares code generator for emitting arg-full overload;
            // false is returned when the body should not be emitted:
            if (!codeGenerator.EnterFunctionDeclaration(function))
            {
                return;
            }

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

            // restores original code generator settings:
            codeGenerator.LeaveFunctionDeclaration();

            // emits function declaration (if needed):
            // ignore s-decl function declarations except for __autoload;
            // __autoload function is declared in order to avoid using callbacks when called:
            if (function.Declaration.IsConditional && !function.QualifiedName.IsAutoloadName)
            {
                Debug.Assert(!function.IsLambda);
                codeGenerator.EmitDeclareFunction(function);
            }
        }