public SymbolInfo(compiled_function_node value) { //_name_information_type=name_information_type.nit_compiled_function; _sym_info = value; _access_level = get_class_member_access_level(value); _symbol_kind = get_function_kind(value); }
public static compiled_function_node GetMethodNode(MethodInfo mi) { compiled_function_node cfn = (compiled_function_node)meth_nodes[mi]; if (cfn != null) { return(cfn); } cfn = new compiled_function_node(mi); meth_nodes[mi] = cfn; return(cfn); }
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); }
/// <summary> /// Обрабатывает случай, когда левая часть присваивания имеет тип event. /// </summary> /// <returns>True - обработка прошла, иначе False.</returns> private bool ProcessAssignmentToEventIfPossible(assign _assign, addressed_expression to, expression_node from, location loc) { if ((to.semantic_node_type == semantic_node_type.static_event_reference) || (to.semantic_node_type == semantic_node_type.nonstatic_event_reference)) { statement_node event_assign = null; static_event_reference ser = (static_event_reference)to; expression_node right_del = convertion_data_and_alghoritms.convert_type(from, ser.en.delegate_type); switch (_assign.operator_type) { case Operators.AssignmentAddition: { if (to.semantic_node_type == semantic_node_type.static_event_reference) { event_assign = convertion_data_and_alghoritms.create_simple_function_call( ser.en.add_method, loc, right_del); } else { if (ser.en.semantic_node_type == semantic_node_type.compiled_event) { nonstatic_event_reference nser = (nonstatic_event_reference)ser; compiled_function_node cfn = (compiled_function_node)ser.en.add_method; compiled_function_call tmp_event_assign = new compiled_function_call(cfn, nser.obj, loc); tmp_event_assign.parameters.AddElement(right_del); event_assign = tmp_event_assign; } else if (ser.en.semantic_node_type == semantic_node_type.common_event) { nonstatic_event_reference nser = (nonstatic_event_reference)ser; common_method_node cfn = (common_method_node)ser.en.add_method; common_method_call tmp_event_assign = new common_method_call(cfn, nser.obj, loc); tmp_event_assign.parameters.AddElement(right_del); event_assign = tmp_event_assign; } } break; } case Operators.AssignmentSubtraction: { if (to.semantic_node_type == semantic_node_type.static_event_reference) { event_assign = convertion_data_and_alghoritms.create_simple_function_call( ser.en.remove_method, loc, right_del); } else { if (ser.en.semantic_node_type == semantic_node_type.compiled_event) { nonstatic_event_reference nser = (nonstatic_event_reference)ser; compiled_function_node cfn = (compiled_function_node)ser.en.remove_method; compiled_function_call tmp_event_assign = new compiled_function_call(cfn, nser.obj, loc); tmp_event_assign.parameters.AddElement(right_del); event_assign = tmp_event_assign; } else if (ser.en.semantic_node_type == semantic_node_type.common_event) { nonstatic_event_reference nser = (nonstatic_event_reference)ser; common_method_node cfn = (common_method_node)ser.en.remove_method; common_method_call tmp_event_assign = new common_method_call(cfn, nser.obj, loc); tmp_event_assign.parameters.AddElement(right_del); event_assign = tmp_event_assign; } } break; } default: { AddError(loc, "ASSIGN_TO_EVENT"); //throw new CanNotApplyThisOperationToEvent break; } } return_value(event_assign); return(true); } return(false); }
private void init_temp_methods(SymbolTable.Scope sc) { //TODO: Сделано по быстрому. Переделать. Type tp=typeof(Console); compiled_function_node cfn; System.Type[] arr=new System.Type[1]; System.Reflection.MethodInfo mi; arr[0]=typeof(int); mi=tp.GetMethod("WriteLine",arr); cfn=new compiled_function_node(mi); cfn.parameters.Clear(); cfn.parameters.Add(new common_parameter("val",_integer_type,SemanticTree.parameter_type.value,null)); sc.AddSymbol("writeln",new SymbolInfo(cfn)); arr[0]=typeof(double); mi=tp.GetMethod("WriteLine",arr); cfn=new compiled_function_node(mi); cfn.parameters.Clear(); cfn.parameters.Add(new common_parameter("val",_real_type,SemanticTree.parameter_type.value,null)); sc.AddSymbol("writeln",new SymbolInfo(cfn)); arr[0]=typeof(char); mi=tp.GetMethod("WriteLine",arr); cfn=new compiled_function_node(mi); cfn.parameters.Clear(); cfn.parameters.Add(new common_parameter("val",_char_type,SemanticTree.parameter_type.value,null)); sc.AddSymbol("writeln",new SymbolInfo(cfn)); arr[0]=typeof(bool); mi=tp.GetMethod("WriteLine",arr); cfn=new compiled_function_node(mi); cfn.parameters.Clear(); cfn.parameters.Add(new common_parameter("val",_bool_type,SemanticTree.parameter_type.value,null)); sc.AddSymbol("writeln",new SymbolInfo(cfn)); arr[0]=typeof(string); mi=tp.GetMethod("WriteLine",arr); cfn=new compiled_function_node(mi); cfn.parameters.Clear(); cfn.parameters.Add(new common_parameter("val",_string_type,SemanticTree.parameter_type.value,null)); sc.AddSymbol("writeln",new SymbolInfo(cfn)); mi=tp.GetMethod("ReadLine",new System.Type[0]); cfn=new compiled_function_node(mi); cfn.parameters.Clear(); cfn.return_value_type=_string_type; sc.AddSymbol("readline",new SymbolInfo(cfn)); make_assign_operator(_string_type,SemanticTree.basic_function_type.objassign); tp=typeof(int); arr[0]=typeof(string); mi=tp.GetMethod("Parse",arr); cfn=new compiled_function_node(mi); cfn.parameters.Clear(); cfn.parameters.Add(new common_parameter("val",_string_type,SemanticTree.parameter_type.value,null)); cfn.return_value_type=_integer_type; sc.AddSymbol("parseint",new SymbolInfo(cfn)); tp=typeof(double); arr[0]=typeof(string); mi=tp.GetMethod("Parse",arr); cfn=new compiled_function_node(mi); cfn.parameters.Clear(); cfn.parameters.Add(new common_parameter("val",_string_type,SemanticTree.parameter_type.value,null)); cfn.return_value_type=_real_type; sc.AddSymbol("parsereal",new SymbolInfo(cfn)); tp=typeof(bool); arr[0]=typeof(string); mi=tp.GetMethod("Parse",arr); cfn=new compiled_function_node(mi); cfn.parameters.Clear(); cfn.parameters.Add(new common_parameter("val",_string_type,SemanticTree.parameter_type.value,null)); cfn.return_value_type=_bool_type; sc.AddSymbol("parsebool",new SymbolInfo(cfn)); tp=typeof(char); arr[0]=typeof(string); mi=tp.GetMethod("Parse",arr); cfn=new compiled_function_node(mi); cfn.parameters.Clear(); cfn.parameters.Add(new common_parameter("val",_string_type,SemanticTree.parameter_type.value,null)); cfn.return_value_type=_char_type; sc.AddSymbol("parsechar",new SymbolInfo(cfn)); common_namespace_function_node cnfn = new common_namespace_function_node("New",null); cnfn.parameters.Clear(); cnfn.parameters.Add(new common_parameter("ptr",_pointer_type,SemanticTree.parameter_type.value,null)); sc.AddSymbol("new",new SymbolInfo(cnfn)); cnfn = new common_namespace_function_node("Dispose",null); cnfn.parameters.Clear(); cnfn.parameters.Add(new common_parameter("ptr",_pointer_type,SemanticTree.parameter_type.value,null)); sc.AddSymbol("dispose",new SymbolInfo(cnfn)); }
private void init_temp_methods(SymbolTable.Scope sc) { //TODO: Сделано по быстрому. Переделать. Type tp = typeof(Console); compiled_function_node cfn; System.Type[] arr = new System.Type[1]; System.Reflection.MethodInfo mi; arr[0] = typeof(int); mi = tp.GetMethod("WriteLine", arr); cfn = new compiled_function_node(mi); cfn.parameters.Clear(); cfn.parameters.Add(new common_parameter("val", _integer_type, SemanticTree.parameter_type.value, null)); sc.AddSymbol("writeln", new SymbolInfo(cfn)); arr[0] = typeof(double); mi = tp.GetMethod("WriteLine", arr); cfn = new compiled_function_node(mi); cfn.parameters.Clear(); cfn.parameters.Add(new common_parameter("val", _real_type, SemanticTree.parameter_type.value, null)); sc.AddSymbol("writeln", new SymbolInfo(cfn)); arr[0] = typeof(char); mi = tp.GetMethod("WriteLine", arr); cfn = new compiled_function_node(mi); cfn.parameters.Clear(); cfn.parameters.Add(new common_parameter("val", _char_type, SemanticTree.parameter_type.value, null)); sc.AddSymbol("writeln", new SymbolInfo(cfn)); arr[0] = typeof(bool); mi = tp.GetMethod("WriteLine", arr); cfn = new compiled_function_node(mi); cfn.parameters.Clear(); cfn.parameters.Add(new common_parameter("val", _bool_type, SemanticTree.parameter_type.value, null)); sc.AddSymbol("writeln", new SymbolInfo(cfn)); arr[0] = typeof(string); mi = tp.GetMethod("WriteLine", arr); cfn = new compiled_function_node(mi); cfn.parameters.Clear(); cfn.parameters.Add(new common_parameter("val", _string_type, SemanticTree.parameter_type.value, null)); sc.AddSymbol("writeln", new SymbolInfo(cfn)); mi = tp.GetMethod("ReadLine", new System.Type[0]); cfn = new compiled_function_node(mi); cfn.parameters.Clear(); cfn.return_value_type = _string_type; sc.AddSymbol("readline", new SymbolInfo(cfn)); make_assign_operator(_string_type, SemanticTree.basic_function_type.objassign); tp = typeof(int); arr[0] = typeof(string); mi = tp.GetMethod("Parse", arr); cfn = new compiled_function_node(mi); cfn.parameters.Clear(); cfn.parameters.Add(new common_parameter("val", _string_type, SemanticTree.parameter_type.value, null)); cfn.return_value_type = _integer_type; sc.AddSymbol("parseint", new SymbolInfo(cfn)); tp = typeof(double); arr[0] = typeof(string); mi = tp.GetMethod("Parse", arr); cfn = new compiled_function_node(mi); cfn.parameters.Clear(); cfn.parameters.Add(new common_parameter("val", _string_type, SemanticTree.parameter_type.value, null)); cfn.return_value_type = _real_type; sc.AddSymbol("parsereal", new SymbolInfo(cfn)); tp = typeof(bool); arr[0] = typeof(string); mi = tp.GetMethod("Parse", arr); cfn = new compiled_function_node(mi); cfn.parameters.Clear(); cfn.parameters.Add(new common_parameter("val", _string_type, SemanticTree.parameter_type.value, null)); cfn.return_value_type = _bool_type; sc.AddSymbol("parsebool", new SymbolInfo(cfn)); tp = typeof(char); arr[0] = typeof(string); mi = tp.GetMethod("Parse", arr); cfn = new compiled_function_node(mi); cfn.parameters.Clear(); cfn.parameters.Add(new common_parameter("val", _string_type, SemanticTree.parameter_type.value, null)); cfn.return_value_type = _char_type; sc.AddSymbol("parsechar", new SymbolInfo(cfn)); common_namespace_function_node cnfn = new common_namespace_function_node("New", null); cnfn.parameters.Clear(); cnfn.parameters.Add(new common_parameter("ptr", _pointer_type, SemanticTree.parameter_type.value, null)); sc.AddSymbol("new", new SymbolInfo(cnfn)); cnfn = new common_namespace_function_node("Dispose", null); cnfn.parameters.Clear(); cnfn.parameters.Add(new common_parameter("ptr", _pointer_type, SemanticTree.parameter_type.value, null)); sc.AddSymbol("dispose", new SymbolInfo(cnfn)); }
public static compiled_function_node GetMethodNode(MethodInfo mi) { compiled_function_node cfn = (compiled_function_node)meth_nodes[mi]; if (cfn != null) return cfn; cfn = new compiled_function_node(mi); meth_nodes[mi] = cfn; return cfn; }