Exemple #1
0
        public override base_function_call copy()
        {
            common_method_call cmc_copy = new common_method_call(this.function_node, this.obj, this.location);

            cmc_copy.parameters.AddRange(this.parameters);
            return(cmc_copy);
        }
        public static expression_node convert_delegate_to_return_value_type(location call_location, params expression_node[] parameters)
        {
            expression_node             par = parameters[0];
            internal_interface          ii  = par.type.get_internal_interface(internal_interface_kind.delegate_interface);
            delegate_internal_interface dii = (delegate_internal_interface)ii;
            common_method_node          cmn = dii.invoke_method as common_method_node;

            if (cmn != null)
            {
                expression_node exp = new common_method_call(cmn, par, call_location);
                return(exp);
            }
            compiled_function_node cfn = dii.invoke_method as compiled_function_node;

            if (cfn != null)
            {
                expression_node exp = new compiled_function_call(cfn, par, call_location);
                return(exp);
            }
            return(null);
        }
            public expression_node convert_delegates_to_delegates(location call_location, expression_node[] parameters)
            {
                if (parameters.Length != 1)
                {
                    throw new PascalSharp.Internal.TreeConverter.CompilerInternalError("Invalid delegates convertion");
                }
                delegate_internal_interface dii_to =
                    (delegate_internal_interface)_to.get_internal_interface(internal_interface_kind.delegate_interface);
                delegate_internal_interface dii =
                    (delegate_internal_interface)parameters[0].type.get_internal_interface(internal_interface_kind.delegate_interface);

                expression_node pr = parameters[0];

                base_function_call ifnotnull = null;

                if (_to.semantic_node_type == semantic_node_type.compiled_type_node)
                {
                    ifnotnull = new compiled_constructor_call((compiled_constructor_node)dii_to.constructor, call_location);
                }
                else
                {
                    ifnotnull = new common_constructor_call((common_method_node)dii_to.constructor, call_location);
                }
                //ccc = new common_constructor_call(dii_to.constructor, call_location);

                expression_node par = null;

                if (parameters[0].type.semantic_node_type == semantic_node_type.compiled_type_node)
                {
                    par = new compiled_function_call((compiled_function_node)dii.invoke_method, parameters[0], call_location);
                }
                else
                {
                    par = new common_method_call((common_method_node)dii.invoke_method, parameters[0], call_location);
                }
                ifnotnull.parameters.AddElement(par);

                null_const_node ncn  = new null_const_node(_to, call_location);
                null_const_node ncn2 = new null_const_node(_to, call_location);

                SymbolInfo si = pr.type.find_first_in_type(compiler_string_consts.eq_name);

                basic_function_node fn        = si.sym_info as basic_function_node;
                expression_node     condition = null;

                if (fn != null)
                {
                    basic_function_call condition_bfc = new basic_function_call(fn, call_location);
                    condition_bfc.parameters.AddElement(pr);
                    condition_bfc.parameters.AddElement(ncn);
                    condition = condition_bfc;
                }
                else if (si.sym_info is compiled_function_node)
                {
                    compiled_static_method_call condition_cfc = new compiled_static_method_call(si.sym_info as compiled_function_node, call_location);
                    condition_cfc.parameters.AddElement(pr);
                    condition_cfc.parameters.AddElement(ncn);
                    condition = condition_cfc;
                }

                question_colon_expression qce = new question_colon_expression(condition, ncn2, ifnotnull, call_location);

                return(qce);
            }