Ejemplo n.º 1
0
 	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;
 	}
Ejemplo n.º 2
0
 public array_initializer(List <expression_node> element_values, location loc)
     :
     base(null, loc)
 {
     this._element_values = element_values;
 }
Ejemplo n.º 3
0
 internal static expression_node delegated_empty_method(location call_loc,expression_node[] expr)
 {
     if (expr.Length != 1)
     {
         return null;
     }
     return expr[0];
 }
Ejemplo n.º 4
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;
 }
Ejemplo n.º 5
0
		public return_node(expression_node return_expr,location loc) : base(loc)
		{
			_return_expr=return_expr;
		}
Ejemplo n.º 6
0
        /// <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;
		}
Ejemplo n.º 7
0
 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);
     }
 }
Ejemplo n.º 9
0
 public statement_node(location loc)
 {
     _loc = loc;
 }
Ejemplo n.º 10
0
 public rethrow_statement_node(location loc) :
     base(loc)
 {
 }
Ejemplo n.º 11
0
 public throw_statement_node(expression_node exception, location loc) :
     base(loc)
 {
     _excpetion = exception;
 }
Ejemplo n.º 12
0
 public namespace_unit_node(using_namespace namespace_name, location loc)
 {
     this.namespace_name = namespace_name;
     this.loc            = loc;
 }
Ejemplo n.º 13
0
 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;
 }
Ejemplo n.º 14
0
 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;
 }
Ejemplo n.º 15
0
 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);
 }
Ejemplo n.º 18
0
 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);
 }
Ejemplo n.º 20
0
 public typed_expression(type_node type, location loc)
     : base(type, loc)
 {
 }
Ejemplo n.º 21
0
        /// <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;
		}
Ejemplo n.º 22
0
 /// <summary>
 /// Конструктор адресного выражения.
 /// </summary>
 /// <param name="tn">Тип выражжения.</param>
 /// <param name="loc">Расположение выражения.</param>
 public addressed_expression(type_node tn, location loc) : base(tn, loc)
 {
 }
Ejemplo n.º 23
0
 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);
 }
Ejemplo n.º 24
0
 /// <summary>
 /// Конструктор this_node.
 /// </summary>
 /// <param name="type">Тип объекта.</param>
 /// <param name="loc">Расположение выражения.</param>
 public this_node(type_node type, location loc) : base(type, loc)
 {
 }
Ejemplo n.º 25
0
        /// <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;
		}
Ejemplo n.º 26
0
 /// <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;
 }
Ejemplo n.º 27
0
 public static expression_node get_empty_method_call(location loc)
 {
     return new basic_function_call(_empty_method, loc);
 }
Ejemplo n.º 28
0
 /// <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;
 }
Ejemplo n.º 29
0
 private void AddWarning(string message, location loc)
 {
     warns.Add(new GenericWarning(message, loc));
 }
Ejemplo n.º 30
0
 /// <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;
 }
Ejemplo n.º 32
0
 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;
 }
Ejemplo n.º 34
0
 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;
        }
Ejemplo n.º 36
0
 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);
 }
Ejemplo n.º 38
0
 public namespace_constant_reference(namespace_constant_definition cdn, location loc) : base(cdn.type, loc)
 {
     this.cdn = cdn;
 }
Ejemplo n.º 39
0
 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);
      
 }
Ejemplo n.º 40
0
 public function_constant_reference(function_constant_definition cdn, location loc) : base(cdn.type, loc)
 {
     this.cdn = cdn;
 }
Ejemplo n.º 41
0
 public indefinite_reference(indefinite_definition_node idn, location loc)
     : base(idn.cont_class, loc)
 {
     _indefinite_def = idn;
 }
Ejemplo n.º 42
0
 public common_constructor_call_as_constant(common_constructor_call constructor_call, location loc)
     :
     base(constructor_call.type, loc)
 {
     _constructor_call = constructor_call;
 }
Ejemplo n.º 43
0
        /// <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;
		}
Ejemplo n.º 44
0
 public override constant_node get_constant_copy(location loc)
 {
     return(new common_constructor_call_as_constant(this._constructor_call, loc));
 }
Ejemplo n.º 45
0
		public common_method_node(string name,location loc,SymbolTable.Scope scope) :
            base(name,loc,scope)
        {
        }
Ejemplo n.º 46
0
 /// <summary>
 /// Конструктор узла.
 /// </summary>
 /// <param name="value">Значение константы.</param>
 /// <param name="loc">Расположение контанты.</param>
 public bool_const_node(bool value, location loc)
     : base(value, loc)
 {
 }
Ejemplo n.º 47
0
 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);
 }
Ejemplo n.º 48
0
 /// <summary>
 /// Конструктор узла.
 /// </summary>
 /// <param name="tn">Тип константы.</param>
 /// <param name="loc">Расположение константы.</param>
 public constant_node(type_node tn, location loc) : base(null, loc)
 {
     _type = tn;
 }
Ejemplo n.º 49
0
 public virtual function_node get_instance(List<type_node> param_types, bool stop_on_error, location loc)
 {
     return null;
 }
Ejemplo n.º 50
0
 /// <summary>
 /// Конструктор узла.
 /// </summary>
 /// <param name="value">Значение константы.</param>
 /// <param name="loc">Расположение контанты.</param>
 public long_const_node(long value, location loc)
     : base(value, loc)
 {
 }
Ejemplo n.º 51
0
        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;
        }
Ejemplo n.º 52
0
 /// <summary>
 /// Конструктор узла.
 /// </summary>
 /// <param name="value">Значение константы.</param>
 /// <param name="loc">Расположение контанты.</param>
 public sbyte_const_node(sbyte value, location loc)
     : base(value, loc)
 {
 }
Ejemplo n.º 53
0
        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
            {

            }
            */
        }
Ejemplo n.º 54
0
 /// <summary>
 /// Конструктор узла.
 /// </summary>
 /// <param name="value">Значение константы.</param>
 /// <param name="loc">Расположение контанты.</param>
 public ushort_const_node(ushort value, location loc)
     : base(value, loc)
 {
 }
Ejemplo n.º 55
0
 private static expression_node dec_compile_time_executor(location call_location, expression_node[] expr)
 {
     return null;
 }
Ejemplo n.º 56
0
 public override constant_node get_constant_copy(location loc)
 {
     return(new ushort_const_node(this.constant_value, loc));
 }
Ejemplo n.º 57
0
 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);
     }
 }
Ejemplo n.º 58
0
 /// <summary>
 /// Конструктор узла.
 /// </summary>
 /// <param name="value">Значение константы.</param>
 /// <param name="loc">Расположение контанты.</param>
 public uint_const_node(uint value, location loc)
     : base(value, loc)
 {
 }
Ejemplo n.º 59
0
 private void AddHint(string message, location loc)
 {
     warns.Add(new GenericHint(message, loc));
 }
Ejemplo n.º 60
0
 public statements_expression_node(statement_node_list statements, expression_node expression, location loc)
     : base(expression.type, loc)
 {
     this._statements_list = statements;
     this._expression      = expression;
 }