public common_event(string name, type_node del_type, common_type_node cont_type, common_method_node add_method, common_method_node remove_method, common_method_node raise_method, SemanticTree.field_access_level fal, SemanticTree.polymorphic_state ps, location loc) { this._name = name; this.del_type = del_type; this._add_method = add_method; this._remove_method = remove_method; this._raise_method = raise_method; this._field_access_level = fal; this._polymorphic_state = ps; this._cont_type = cont_type; this._loc = loc; }
public array_initializer(List <expression_node> element_values, location loc) : base(null, loc) { this._element_values = element_values; }
internal static expression_node delegated_empty_method(location call_loc,expression_node[] expr) { if (expr.Length != 1) { return null; } return expr[0]; }
private static bool compare_ordinal_type(constant_node left,constant_node right,compile_time_executor cte, location call_location) { expression_node ret_expr=cte(call_location,left,right); if (ret_expr == null) { throw new CompilerInternalError("Expected compile-time executed expression."); } bool_const_node bcn = ret_expr as bool_const_node; if (bcn == null) { throw new CompilerInternalError("Expected bool value."); } return bcn.constant_value; }
public return_node(expression_node return_expr,location loc) : base(loc) { _return_expr=return_expr; }
/// <summary> /// Конструктор узла. /// </summary> /// <param name="name">Имя функции.</param> /// <param name="ret_type"></param> /// <param name="loc">Расположение имени метода в программе.</param> /// <param name="cont_type">Тип, который содержит этот метод.</param> /// <param name="polymorphic_state">Обычный, виртуальный или статический метод.</param> /// <param name="field_access_level">Уровень доступа к методу.</param> /// <param name="scope">Пространство имен функции.</param> public common_method_node(string name,type_node ret_type, location loc, common_type_node cont_type, SemanticTree.polymorphic_state polymorphic_state, SemanticTree.field_access_level field_access_level, SymbolTable.Scope scope) : base(name,ret_type,loc,scope) { _cont_type=cont_type; _field_access_level = field_access_level; _polymorphic_state = polymorphic_state; }
public indefinite_function_call(function_node fn, location loc) : base(fn.return_value_type, loc) { _function_node = fn; }
private void CheckConstantRecordNotBeContainsMethods(common_type_node ctn, location loc) { if (ctn.is_value) { if (ctn.methods.Count > 0) { for (int i=0; i<ctn.methods.Count; i++) if (ctn.methods[i].loc != null) AddError(loc, "CONSTANT_RECORD_CAN_NOT_CONTAINS_METHODS"); } //if (!(ctn.methods.Count == 2 && ctn.methods[0] is common_method_node && (ctn.methods[0] as common_method_node).is_constructor && ctn.methods[0].loc == null // && ctn.methods[1] is common_method_node && ctn.methods[1].loc == null)) // throw new ConstantRecordCanNotContainsMethods(loc); if (ctn.base_type is common_type_node) CheckConstantRecordNotBeContainsMethods(ctn.base_type as common_type_node, loc); } else { if (IsBoundedArray(ctn) && ctn.element_type is common_type_node) CheckConstantRecordNotBeContainsMethods(ctn.element_type as common_type_node, loc); } }
public statement_node(location loc) { _loc = loc; }
public rethrow_statement_node(location loc) : base(loc) { }
public throw_statement_node(expression_node exception, location loc) : base(loc) { _excpetion = exception; }
public namespace_unit_node(using_namespace namespace_name, location loc) { this.namespace_name = namespace_name; this.loc = loc; }
public is_node(expression_node left, type_node right, location loc) : base(compiled_type_node.get_type_node(typeof(bool)), loc) { _left = left; _right = right; }
internal record_initializer(List <SyntaxTree.record_const_definition> record_const_definition_list, location loc) : base(null, loc) { this.record_const_definition_list = record_const_definition_list; }
public record_initializer(List <expression_node> field_values, location loc) : base(null, loc) { _field_values = field_values; }
private int_const_node convert_const_to_switch(expression_node switch_expr, ordinal_type_interface oti, type_node case_expr_type, location loc) { convertion_data_and_alghoritms.convert_type(switch_expr, case_expr_type, loc); if (switch_expr is int_const_node) return switch_expr as int_const_node; //switch_expr = convertion_data_and_alghoritms.create_simple_function_call(oti.value_to_int, // loc, switch_expr); int_const_node icn = null;//switch_expr as constant_node; if (switch_expr is byte_const_node) icn = new int_const_node((switch_expr as byte_const_node).constant_value, loc); else if (switch_expr is sbyte_const_node) icn = new int_const_node(Convert.ToInt32((switch_expr as sbyte_const_node).constant_value), loc); else if (switch_expr is short_const_node) icn = new int_const_node(Convert.ToInt32((switch_expr as short_const_node).constant_value), loc); else if (switch_expr is ushort_const_node) icn = new int_const_node(Convert.ToInt32((switch_expr as ushort_const_node).constant_value), loc); /*else if (switch_expr is uint_const_node) icn = new int_const_node(Convert.ToInt32((switch_expr as uint_const_node).constant_value),loc); else if (switch_expr is long_const_node) icn = new int_const_node(Convert.ToInt32((switch_expr as long_const_node).constant_value),loc); else if (switch_expr is ulong_const_node) icn = new int_const_node(Convert.ToInt32((switch_expr as ulong_const_node).constant_value),loc);*/ else if (switch_expr is bool_const_node) icn = new int_const_node(Convert.ToInt32((switch_expr as bool_const_node).constant_value), loc); else if (switch_expr is char_const_node) icn = new int_const_node(Convert.ToInt32((switch_expr as char_const_node).constant_value), loc); else if (switch_expr is enum_const_node) icn = new int_const_node((switch_expr as enum_const_node).constant_value, loc); else if (switch_expr is static_compiled_variable_reference && (switch_expr as static_compiled_variable_reference).var.compiled_field.IsLiteral) icn = new int_const_node((int)(switch_expr as static_compiled_variable_reference).var.compiled_field.GetRawConstantValue(), loc); //учти здесь модет быть и long! //-DarkStar Add if (icn == null) { AddError(loc, "CONSTANT_EXPRESSION_EXPECTED"); } return icn; }
//TODO: Обратить внимание на эту функцию. Ее вызовы не приводят к созданиям узлов преобразования типов. private function_node find_function(string name, location loc, params expression_node[] exprs) { expressions_list exprs_list = new expressions_list(); exprs_list.AddRange(exprs); return find_function(name, loc, exprs_list); }
public expression_node(type_node tn, location loc) : base(loc) { _tn = tn; }
private common_type_node convert_function_type(SyntaxTree.procedure_header proc_header, location loc, string type_name, common_type_node del_type) { return convert_function_type(proc_header.parameters, null, loc, type_name, del_type); }
public typed_expression(type_node type, location loc) : base(type, loc) { }
/// <summary> /// Конструктор узла. /// </summary> /// <param name="name">Имя функции.</param> /// <param name="ret_type">Тип возвращааемого знчения функции.</param> /// <param name="loc">Расположение функции.</param> /// <param name="nsp">Пространство имен, в котором определена функция.</param> /// <param name="scope">Пространство имен функции.</param> public common_namespace_function_node(string name, type_node ret_type, location loc, common_namespace_node nsp, SymbolTable.Scope scope) : base(name,ret_type,loc,scope) { _namespace=nsp; }
/// <summary> /// Конструктор адресного выражения. /// </summary> /// <param name="tn">Тип выражжения.</param> /// <param name="loc">Расположение выражения.</param> public addressed_expression(type_node tn, location loc) : base(tn, loc) { }
public override function_node get_instance(List<type_node> param_types, bool stop_on_error, location loc) { if (generic_parameters_count != param_types.Count) { if (stop_on_error) { throw new TreeConverter.SimpleSemanticError(loc, "FUNCTION_{0}_DEPEND_FROM_{1}_TYPE_PARAMS", name, this.generic_parameters_count); } return null; } int num; TreeConverter.CompilationErrorWithLocation err = generic_parameter_eliminations.check_type_list(param_types, parameters_eliminations, true, out num); if (err != null) { if (stop_on_error) { err.loc = loc; throw err; } return null; } return generic_convertions.get_function_instance(this, param_types); }
/// <summary> /// Конструктор this_node. /// </summary> /// <param name="type">Тип объекта.</param> /// <param name="loc">Расположение выражения.</param> public this_node(type_node type, location loc) : base(type, loc) { }
/// <summary> /// Конструктор узла. /// </summary> /// <param name="name">Имя функции.</param> /// <param name="ret_type">Тип возвращаемого значения функции.</param> /// <param name="loc">Расположение функции.</param> /// <param name="scope">Пространство имен этой функции.</param> public common_function_node(string name,type_node ret_type,location loc, SymbolTable.Scope scope) : base(ret_type) { _name=name; _loc = loc; _scope = scope; }
/// <summary> /// Конструктор узла. /// </summary> /// <param name="addr_of">Выражение, адрес которого мы получаем.</param> /// <param name="loc">Расположение узла.</param> public get_addr_node(expression_node addr_of, location loc) : base(addr_of.type.ref_type, loc) { _addr_of = addr_of; }
public static expression_node get_empty_method_call(location loc) { return new basic_function_call(_empty_method, loc); }
/// <summary> /// Конструктор узла. /// </summary> /// <param name="deref_expr">Выражение-указатель.</param> /// <param name="loc">Расположение выражения.</param> public dereference_node(expression_node deref_expr, location loc) : //base(PascalABCCompiler.SystemLibrary.SystemLibrary.get_pointed_type_by_type(deref_expr.type),loc) base((deref_expr.type as ref_type_node).pointed_type, loc) { _deref_expr = deref_expr; }
private void AddWarning(string message, location loc) { warns.Add(new GenericWarning(message, loc)); }
/// <summary> /// Конструктор узла. /// </summary> /// <param name="value">Значение константы.</param> /// <param name="tn">Тип константы.</param> public concrete_constant(ConstantType value, location loc) : base(compiled_type_node.get_type_node(typeof(ConstantType)), loc) { _constant_value = value; }
private string_const_node convert_string_const_to_switch(expression_node switch_expr, location loc) { if (switch_expr is string_const_node) return switch_expr as string_const_node; string_const_node scn = null; if (switch_expr is static_compiled_variable_reference && (switch_expr as static_compiled_variable_reference).var.compiled_field.IsLiteral) scn = new string_const_node((string)(switch_expr as static_compiled_variable_reference).var.compiled_field.GetRawConstantValue(), loc); if (scn == null) { AddError(loc, "CONSTANT_EXPRESSION_EXPECTED"); } return scn; }
public common_namespace_function_call_as_constant(common_namespace_function_call method_call, location loc) : base(method_call.type, loc) { _method_call = method_call; }
//Последний параметер - выходной. Он слдержит список параметров с преобразованиями типов. private function_node find_function(string name, location loc, PascalABCCompiler.TreeRealization.expressions_list parameters) { SymbolInfo si = context.find(name); if (si == null) { AddError(new NoFunctionWithThisName(loc)); } if (si.sym_info.general_node_type != general_node_type.function_node) { AddError(new ThisIsNotFunctionName(loc)); } function_node fn = convertion_data_and_alghoritms.select_function(parameters, si, loc); return fn; }
public basic_function_call_as_constant(basic_function_call method_call, location loc) : base(method_call.type, loc) { _method_call = method_call; }
private expression_node find_operator(SyntaxTree.Operators ot, expression_node expr, location loc) { string name = name_reflector.get_name(ot); //#if (DEBUG) if (name == null) { if (ot == PascalABCCompiler.SyntaxTree.Operators.AddressOf) { if (expr.is_addressed == false) { AddError(expr.location, "CAN_NOT_GET_ADDRESS_FROM_EXPRESSION"); } expression_node res = new get_addr_node(expr, loc); return res; } if (ot == PascalABCCompiler.SyntaxTree.Operators.Dereference) { } throw new CompilerInternalError("Invalid operator name"); } //#endif SymbolInfo si = expr.type.find(name, context.CurrentScope); if (si == null || si.sym_info is wrapped_definition_node) { AddError(new OperatorCanNotBeAppliedToThisType(name, expr)); } expressions_list pars = new expressions_list(); pars.AddElement(expr); function_node fn = convertion_data_and_alghoritms.select_function(pars, si, loc); expr = pars[0]; if (fn == null) { AddError(new OperatorCanNotBeAppliedToThisType(name, expr)); } #if (DEBUG) convertion_data_and_alghoritms.check_operator(fn); #endif expression_node exp_node = convertion_data_and_alghoritms.create_simple_function_call(fn, loc, expr); return exp_node; }
public compiled_constructor_call_as_constant(compiled_constructor_call method_call, location loc) : base(method_call.type, loc) { _method_call = method_call; }
private common_type_node convert_function_type(SyntaxTree.function_header func_header, location loc, string type_name, common_type_node del_type) { return convert_function_type(func_header.parameters, func_header.return_type, loc, type_name, del_type); }
public namespace_constant_reference(namespace_constant_definition cdn, location loc) : base(cdn.type, loc) { this.cdn = cdn; }
public string CreateTemplateInstance(List<type_node> instance_params, location loc) { SyntaxTree.class_definition cl_def = _type_decl.type_def as SyntaxTree.class_definition; SyntaxTree.template_type_name ttn = _type_decl.type_name as SyntaxTree.template_type_name; //if (cl_def == null) //{ // throw new PascalABCCompiler.TreeConverter.CompilerInternalError("No body definition in template class."); //} //if (cl_def.template_args == null || cl_def.template_args.idents == null) //{ // throw new PascalABCCompiler.TreeConverter.CompilerInternalError("No template arguments in syntax tree."); //} List<SyntaxTree.ident> template_formals = (_is_synonym) ? ttn.template_args.idents : cl_def.template_args.idents; if (instance_params.Count != template_formals.Count) { throw new PascalABCCompiler.TreeConverter.SimpleSemanticError(loc, "TEMPLATE_ARGUMENTS_COUNT_MISMATCH"); } return GetTemplateInstanceName(instance_params); }
public function_constant_reference(function_constant_definition cdn, location loc) : base(cdn.type, loc) { this.cdn = cdn; }
public indefinite_reference(indefinite_definition_node idn, location loc) : base(idn.cont_class, loc) { _indefinite_def = idn; }
public common_constructor_call_as_constant(common_constructor_call constructor_call, location loc) : base(constructor_call.type, loc) { _constructor_call = constructor_call; }
/// <summary> /// Конструктор узла. /// </summary> /// <param name="name">Имя функции.</param> /// <param name="ret_type">Тип возвращаемого значения функции.</param> /// <param name="loc">Расположение имени функции в программе.</param> /// <param name="up_function">Функция, в которой определена эта функция.</param> /// <param name="scope">Протсранство имен этой функции.</param> public common_in_function_function_node(string name, type_node ret_type, location loc, common_function_node up_function, SymbolTable.Scope scope) : base(name,ret_type,loc,scope) { _up_function=up_function; }
public override constant_node get_constant_copy(location loc) { return(new common_constructor_call_as_constant(this._constructor_call, loc)); }
public common_method_node(string name,location loc,SymbolTable.Scope scope) : base(name,loc,scope) { }
/// <summary> /// Конструктор узла. /// </summary> /// <param name="value">Значение константы.</param> /// <param name="loc">Расположение контанты.</param> public bool_const_node(bool value, location loc) : base(value, loc) { }
public override function_node get_instance(List<type_node> param_types, bool stop_on_error, location loc) { int count = param_types.Count; if (count != _generic_params_count) { if (stop_on_error) { throw new TreeConverter.SimpleSemanticError(loc, "FUNCTION_{0}_DEPEND_FROM_{1}_TYPE_PARAMS", name, _generic_params_count); } return null; } int num; TreeConverter.CompilationErrorWithLocation err = generic_parameter_eliminations.check_type_list(param_types, parameters_eliminations, true, out num); if (err != null) { if (stop_on_error) { err.loc = loc; throw err; } return null; } bool all_compiled = true; List<Type> ts = new List<Type>(count); int k = 0; while (k < count && all_compiled) { compiled_type_node compt = param_types[k] as compiled_type_node; if (compt == null) { all_compiled = false; } else { ts.Add(compt._compiled_type); } ++k; } if (all_compiled) { System.Reflection.MethodInfo rez_t = _mi.MakeGenericMethod(ts.ToArray()); compiled_function_node rez = compiled_function_node.get_compiled_method(rez_t); return rez; } return generic_convertions.get_function_instance(this, param_types); }
/// <summary> /// Конструктор узла. /// </summary> /// <param name="tn">Тип константы.</param> /// <param name="loc">Расположение константы.</param> public constant_node(type_node tn, location loc) : base(null, loc) { _type = tn; }
public virtual function_node get_instance(List<type_node> param_types, bool stop_on_error, location loc) { return null; }
/// <summary> /// Конструктор узла. /// </summary> /// <param name="value">Значение константы.</param> /// <param name="loc">Расположение контанты.</param> public long_const_node(long value, location loc) : base(value, loc) { }
private static expression_node set_length_compile_time_executor(location call_location, params expression_node[] pars) { array_internal_interface aii = (array_internal_interface) pars[0].type.get_internal_interface(PascalABCCompiler.TreeRealization.internal_interface_kind.unsized_array_interface); if (aii == null) { throw new SimpleSemanticError(call_location, "CAN_NOT_APPLY_SETLENGTH_TO_THIS_OPERAND_TYPE"); } compiled_static_method_call csmc = new compiled_static_method_call(_resize_func, call_location); csmc.parameters.AddRange(pars); csmc.template_parametres_list.AddElement(aii.element_type); return csmc; }
/// <summary> /// Конструктор узла. /// </summary> /// <param name="value">Значение константы.</param> /// <param name="loc">Расположение контанты.</param> public sbyte_const_node(sbyte value, location loc) : base(value, loc) { }
private static expression_node inc_value_compile_time_executor(location call_location, expression_node[] expr) { return null; /* if (expr.Length != 1) { return null; } expression_node value_to_inc = expr[0]; internal_interface ii=value_to_inc.type.get_internal_interface(internal_interface_kind.ordinal_interface); if (ii == null) { throw new CompilerInternalError("This method must be called only with ordinal types."); } ordinal_type_interface oti = (ordinal_type_interface)ii; constant_node cn = value_to_inc as constant_node; if (cn != null) { if (compare_ordinal_type(cn, oti.upper_value, oti.greater_eq_method.compile_time_executor,call_location)) { throw new CanNotIncrementOrdinalTypeValue(cn); } return (oti.internal_inc_value.compile_time_executor(call_location,cn)); } else { } */ }
/// <summary> /// Конструктор узла. /// </summary> /// <param name="value">Значение константы.</param> /// <param name="loc">Расположение контанты.</param> public ushort_const_node(ushort value, location loc) : base(value, loc) { }
private static expression_node dec_compile_time_executor(location call_location, expression_node[] expr) { return null; }
public override constant_node get_constant_copy(location loc) { return(new ushort_const_node(this.constant_value, loc)); }
private void CheckType(type_node type, expression_node initial_value, location loc) { if (type.type_special_kind == SemanticTree.type_special_kind.array_wrapper) { AddHint("DO_NOT_USE_STATIC_ARRAYS", loc); } else if (type.IsPointer && type.element_type.is_value_type && type.element_type is common_type_node) { AddHint("DO_NOT_USE_POINTERS_TO_RECORDS", loc); } else if (type.type_special_kind == SemanticTree.type_special_kind.short_string) { AddHint("DO_NOT_USE_SHORT_STRINGS", loc); } }
/// <summary> /// Конструктор узла. /// </summary> /// <param name="value">Значение константы.</param> /// <param name="loc">Расположение контанты.</param> public uint_const_node(uint value, location loc) : base(value, loc) { }
private void AddHint(string message, location loc) { warns.Add(new GenericHint(message, loc)); }
public statements_expression_node(statement_node_list statements, expression_node expression, location loc) : base(expression.type, loc) { this._statements_list = statements; this._expression = expression; }