public override base_function_call copy() { compiled_static_method_call csmc_copy = new compiled_static_method_call(this.function_node, this.location); csmc_copy.parameters.AddRange(this.parameters); return(csmc_copy); }
public void create_main_function(string[] used_stand_modules, Dictionary <string, object> config) { add_needed_cctors(); common_namespace_function_node temp = _main_function; _main_function = new common_namespace_function_node("Main", null, null, (common_namespace_node)_main_function.comprehensive_namespace, null); location loc = temp.loc; statements_list sl = new statements_list(loc); _main_function.function_code = sl; // if (units[0].MainArgsParameter!=null) // { // _main_function.parameters.AddElement(units[0].MainArgsParameter); // sl.statements.AddElement(units[0].MainArgsAssignExpr); // } // if (units[0].IsConsoleApplicationVariableAssignExpr!=null) // { // sl.statements.AddElement(units[0].IsConsoleApplicationVariableAssignExpr); // } statements_list sl2 = sl; sl = new statements_list(null); common_namespace_function_node init_func = new common_namespace_function_node("$_Init_", null, null, (common_namespace_node)_main_function.comprehensive_namespace, null); ((common_namespace_node)_main_function.comprehensive_namespace).functions.AddElement(init_func); namespace_variable init_var = new namespace_variable("$is_init", SystemLibrary.SystemLibrary.bool_type, (common_namespace_node)_main_function.comprehensive_namespace, null); ((common_namespace_node)_main_function.comprehensive_namespace).variables.AddElement(init_var); if (SystemLibrary.SystemLibInitializer.ConfigVariable != null && SystemLibrary.SystemLibInitializer.ConfigVariable.Found) { namespace_variable conf_nv = null; compiled_variable_definition conf_cf = null; if (SystemLibrary.SystemLibInitializer.ConfigVariable.sym_info is namespace_variable) { conf_nv = SystemLibrary.SystemLibInitializer.ConfigVariable.sym_info as namespace_variable; } else { conf_cf = SystemLibrary.SystemLibInitializer.ConfigVariable.sym_info as compiled_variable_definition; } foreach (string config_var in config.Keys) { var config_value = config[config_var]; compiled_function_call cfc = new compiled_function_call(compiled_function_node.get_compiled_method(NetHelper.NetHelper.AddToDictionaryMethod), (conf_nv != null) ? (expression_node) new namespace_variable_reference(conf_nv, null) : (expression_node) new static_compiled_variable_reference(conf_cf, null), null); cfc.parameters.AddElement(new string_const_node(config_var, null)); switch (Type.GetTypeCode(config_value.GetType())) { case TypeCode.String: cfc.parameters.AddElement(new string_const_node((string)config_value, null)); break; case TypeCode.Int32: cfc.parameters.AddElement(new int_const_node((int)config_value, null)); break; case TypeCode.Boolean: cfc.parameters.AddElement(new bool_const_node((bool)config_value, null)); break; case TypeCode.Double: cfc.parameters.AddElement(new double_const_node((double)config_value, null)); break; default: throw new NotSupportedException("Config value type is nort supported"); } sl.statements.AddElement(cfc); } } if (units[0].MainArgsParameter != null) { _main_function.parameters.AddElement(units[0].MainArgsParameter); sl.statements.AddElementFirst(units[0].MainArgsAssignExpr); } if (units[0].IsConsoleApplicationVariableAssignExpr != null) { sl.statements.AddElementFirst(units[0].IsConsoleApplicationVariableAssignExpr); } for (int i = 0; i < units.Count; i++) { if (units[i].main_function != null) { if (units[i].main_function.name != TreeConverter.compiler_string_consts.temp_main_function_name) { common_namespace_function_call cnfc = new common_namespace_function_call(units[i].main_function, loc); sl.statements.AddElement(cnfc); } else { common_namespace_function_call cnfc = new common_namespace_function_call(units[i].main_function, loc); sl2.statements.AddElement(cnfc); } } } //if (units.Count == 1) for (int i = 0; i < used_stand_modules.Length; i++) { Type t = NetHelper.NetHelper.FindRtlType(used_stand_modules[i] + "." + used_stand_modules[i]); if (t == null) { continue; } compiled_type_node ctn = compiled_type_node.get_type_node(t); System.Reflection.MethodInfo mi = ctn.compiled_type.GetMethod("__InitModule__"); if (mi == null) { continue; } compiled_static_method_call csmc = new compiled_static_method_call(compiled_function_node.get_compiled_method(mi), null); sl.statements.AddElement(csmc); } for (int i = units.Count - 1; i >= 0; i--) { if (units[i].finalization_method != null) { common_namespace_function_call cnfc = new common_namespace_function_call(units[i].finalization_method, loc); sl2.statements.AddElement(cnfc); } } //if (units.Count == 1) for (int i = 0; i < used_stand_modules.Length; i++) { Type t = NetHelper.NetHelper.FindRtlType(used_stand_modules[i] + "." + used_stand_modules[i]); if (t == null) { continue; } compiled_type_node ctn = compiled_type_node.get_type_node(t); System.Reflection.MethodInfo mi = ctn.compiled_type.GetMethod("__FinalizeModule__"); if (mi == null) { continue; } compiled_static_method_call csmc = new compiled_static_method_call(compiled_function_node.get_compiled_method(mi), null); sl2.statements.AddElement(csmc); } sl2 = new statements_list(loc); basic_function_call bfc = new basic_function_call(SystemLibrary.SystemLibrary.bool_assign as basic_function_node, null); bfc.parameters.AddElement(new namespace_variable_reference(init_var, null)); bfc.parameters.AddElement(new bool_const_node(true, null)); sl.statements.AddElementFirst(bfc); bfc = new basic_function_call(SystemLibrary.SystemLibrary.bool_not as basic_function_node, null); bfc.parameters.AddElement(new namespace_variable_reference(init_var, null)); sl2.statements.AddElement(new if_node(bfc, sl, null, null)); init_func.function_code = sl2; sl = new statements_list(null); sl.statements.AddElement(new common_namespace_function_call(init_func, null)); common_namespace_function_node init_variables_func = new common_namespace_function_node("$_InitVariables_", null, null, (common_namespace_node)_main_function.comprehensive_namespace, null); init_variables_func.function_code = new statements_list(null); ((common_namespace_node)_main_function.comprehensive_namespace).functions.AddElement(init_variables_func); sl.statements.AddElement(new common_namespace_function_call(init_variables_func, null)); _init_code = sl; }
public compiled_static_method_call_as_constant(compiled_static_method_call method_call, location loc) : base(method_call.type, loc) { _method_call = method_call; }
public expression_node convert_delegates_to_delegates(location call_location, expression_node[] parameters) { if (parameters.Length != 1) { throw new PascalABCCompiler.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); PascalABCCompiler.TreeConverter.SymbolInfo si = pr.type.find_first_in_type(PascalABCCompiler.TreeConverter.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); }