示例#1
0
        internal void Emit(CodeGenerator /*!*/ codeGenerator)
        {
            attributes.Emit(codeGenerator, this);

            // persists type hint to the [TypeHint] attribute:
            if (resolvedTypeHint != null)
            {
                ParameterBuilder param_builder = routine.Builder.ParameterBuilders[routine.FirstPhpParameterIndex + index];
                DTypeSpec        spec          = resolvedTypeHint.GetTypeSpec(codeGenerator.SourceUnit);
                param_builder.SetCustomAttribute(spec.ToCustomAttributeBuilder());
            }
        }
示例#2
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);
            }
        }