Exemplo n.º 1
0
            /// <summary>
            /// Emits parameter loading.
            /// </summary>
            /// <param name="node">Instance.</param>
            /// <param name="il">Emitter.</param>
            /// <param name="index">The index of the parameter starting from 0.</param>
            /// <param name="codeGenerator">Code generator.</param>
            /// <param name="param">Target <see cref="ParameterInfo"/>.</param>
            /// <returns>The type of the actual argument or its value if it is a leteral.</returns>
            public object EmitLibraryLoadArgument(CallSignature /*!*/ node, ILEmitter /*!*/ il, int index, object /*!*/ codeGenerator, ParameterInfo param)
            {
                Debug.Assert(codeGenerator != null);
                Debug.Assert(index < node.Parameters.Length, "Missing arguments prevents code generation");

                // returns value if the parameter is evaluable at compile time:
                if (node.Parameters[index].Expression.HasValue())
                {
                    return(node.Parameters[index].Expression.GetValue());
                }

                // emits parameter evaluation:
                var p = node.Parameters[index];

                return(PhpTypeCodeEnum.ToType(p.NodeCompiler <ActualParamCompiler>().Emit(p, (CodeGenerator)codeGenerator, PhpRwAttribute.IsDefined(param))));
            }
Exemplo n.º 2
0
        /// <summary>
        /// Emits parameter loading.
        /// </summary>
        /// <param name="il">Emitter.</param>
        /// <param name="index">The index of the parameter starting from 0.</param>
        /// <param name="codeGenerator">Code generator.</param>
        /// <param name="param">Target <see cref="ParameterInfo"/>.</param>
        /// <returns>The type of the actual argument or its value if it is a leteral.</returns>
        internal object EmitLibraryLoadArgument(ILEmitter /*!*/ il, int index, object /*!*/ codeGenerator, ParameterInfo param)
        {
            Debug.Assert(codeGenerator != null);
            Debug.Assert(index < parameters.Count, "Missing arguments prevents code generation");

            // returns value if the parameter is evaluable at compile time:
            if (parameters[index].Expression.HasValue)
            {
                return(parameters[index].Expression.Value);
            }

            // emits parameter evaluation:
            return(PhpTypeCodeEnum.ToType(parameters[index].Emit((CodeGenerator)codeGenerator, PhpRwAttribute.IsDefined(param))));
        }