Esempio n. 1
0
        private void mark_char_as_ordinal()
        {
            ordinal_type_interface oti = new ordinal_type_interface();

            oti.inc_method = create_oti_method(SemanticTree.basic_function_type.cinc, _char_type);
            oti.dec_method = create_oti_method(SemanticTree.basic_function_type.cdec, _char_type);

            SymbolInfo          si  = _char_type.find_in_additional_names(compiler_string_consts.greq_name);
            basic_function_node bfn = (basic_function_node)si.sym_info;

            oti.greater_eq_method = bfn;

            si  = _char_type.find_in_additional_names(compiler_string_consts.smeq_name);
            bfn = (basic_function_node)si.sym_info;

            oti.lower_eq_method = bfn;

            constant_node cn_max = new int_const_node(char.MaxValue, _char_type);
            constant_node cn_min = new int_const_node(char.MinValue, _char_type);

            oti.upper_value = cn_max;
            oti.lower_value = cn_min;

            parameterArrayList pal = new parameterArrayList();

            bfn = new basic_function_node(SemanticTree.basic_function_type.chartoi, pal, _integer_type);
            common_parameter cp = new common_parameter(compiler_string_consts.unary_param_name, _char_type,
                                                       SemanticTree.parameter_type.value, null);

            oti.value_to_int        = bfn;
            oti.ordinal_type_to_int = new ordinal_type_to_int(char_to_int);
            _char_type.add_internal_interface(oti);
        }
Esempio n. 2
0
        private basic_function_node create_oti_method(SemanticTree.basic_function_type bft, type_node type)
        {
            parameterArrayList  pal = new parameterArrayList();
            basic_function_node bfn = new basic_function_node(bft, pal, type);
            common_parameter    cp  = new common_parameter(compiler_string_consts.unary_param_name, type,
                                                           SemanticTree.parameter_type.var, null);

            pal.Add(cp);
            bfn.is_overload = true;
            return(bfn);
        }
Esempio n. 3
0
        //End: No v drugom smisle reference.

        public void make_empty_operator(string name, compiled_type_node ctn)
        {
            parameterArrayList  pars = new parameterArrayList();
            empty_function_node efn  = new empty_function_node(pars, ctn);

            efn.is_overload = true;
            basic_parameter par = new basic_parameter(compiler_string_consts.unary_param_name, ctn,
                                                      SemanticTree.parameter_type.value, null);

            pars.Add(par);
            ctn.add_additional_name(name, new SymbolInfo(efn));
        }
Esempio n. 4
0
        private void make_unary_operator(string operator_name, compiled_type_node to,
                                         SemanticTree.basic_function_type bft, type_node ret_value_type)
        {
            parameterArrayList  pars = new parameterArrayList();
            basic_function_node bfn  = new basic_function_node(bft, pars, ret_value_type);

            bfn.is_overload = true;
            basic_parameter par = new basic_parameter(compiler_string_consts.unary_param_name, to,
                                                      SemanticTree.parameter_type.value, bfn);

            pars.Add(par);
            to.add_additional_name(operator_name, new SymbolInfo(bfn));
        }
Esempio n. 5
0
        private void make_type_conversion(compiled_type_node from, compiled_type_node to, type_compare tc,
                                          SemanticTree.basic_function_type bft)
        {
            parameterArrayList  pars        = new parameterArrayList();
            basic_function_node conv_method = new basic_function_node(bft, pars, to);
            basic_parameter     bp          = new basic_parameter(compiler_string_consts.unary_param_name,
                                                                  from, SemanticTree.parameter_type.value, conv_method);

            pars.Add(bp);

            type_intersection_node inter_node = new type_intersection_node(tc);

            inter_node.this_to_another = new type_conversion_factory(conv_method);
            from.add_intersection_node(to, inter_node);
        }
Esempio n. 6
0
        private void make_object_operator(common_type_node ctn, SemanticTree.basic_function_type bas_ft,
                                          string name, type_node ret_type, SemanticTree.parameter_type first_parameter_type)
        {
            parameterArrayList  pars = new parameterArrayList();
            basic_function_node bfn  = new basic_function_node(bas_ft, pars, ret_type);

            bfn.is_overload = true;
            basic_parameter to = new basic_parameter(compiler_string_consts.left_param_name, ctn,
                                                     first_parameter_type, bfn);
            basic_parameter from = new basic_parameter(compiler_string_consts.right_param_name, ctn,
                                                       SemanticTree.parameter_type.value, bfn);

            pars.Add(to);
            pars.Add(from);
            ctn.Scope.AddSymbol(name, new SymbolInfo(bfn));
        }
Esempio n. 7
0
        private void make_compiled_object_operator(string name, compiled_type_node tp, SemanticTree.basic_function_type bft,
                                                   SemanticTree.parameter_type first_param_type)
        {
            parameterArrayList  pars = new parameterArrayList();
            basic_function_node bfn  = new basic_function_node(bft, pars, tp);

            bfn.is_overload = true;
            basic_parameter to = new basic_parameter(compiler_string_consts.left_param_name, tp,
                                                     first_param_type, bfn);
            basic_parameter from = new basic_parameter(compiler_string_consts.right_param_name, tp,
                                                       SemanticTree.parameter_type.value, bfn);

            pars.Add(to);
            pars.Add(from);
            tp.add_additional_name(name, new SymbolInfo(bfn));
        }
Esempio n. 8
0
        private basic_function_node make_common_binary_operation(string operator_name, compiled_type_node def_type, compiled_type_node left,
                                                                 compiled_type_node right, SemanticTree.basic_function_type bft, type_node ret_value_type)
        {
            parameterArrayList  pars = new parameterArrayList();
            basic_function_node bfn  = new basic_function_node(bft, pars, ret_value_type);

            bfn.is_overload = true;
            basic_parameter par_left = new basic_parameter(compiler_string_consts.left_param_name, left,
                                                           SemanticTree.parameter_type.value, bfn);
            basic_parameter par_right = new basic_parameter(compiler_string_consts.right_param_name, right,
                                                            SemanticTree.parameter_type.value, bfn);

            pars.Add(par_left);
            pars.Add(par_right);
            def_type.add_additional_name(operator_name, new SymbolInfo(bfn));
            return(bfn);
        }
		private void make_object_operator(common_type_node ctn,SemanticTree.basic_function_type bas_ft,
			string name,type_node ret_type,SemanticTree.parameter_type first_parameter_type)
		{
			parameterArrayList pars=new parameterArrayList();
			basic_function_node bfn=new basic_function_node(bas_ft,pars,ret_type);
			bfn.is_overload=true;
			basic_parameter to=new basic_parameter(compiler_string_consts.left_param_name,ctn,
				first_parameter_type,bfn);
			basic_parameter from=new basic_parameter(compiler_string_consts.right_param_name,ctn,
				SemanticTree.parameter_type.value,bfn);
			pars.Add(to);
			pars.Add(from);
			ctn.Scope.AddSymbol(name,new SymbolInfo(bfn));
		}
		private void mark_char_as_ordinal()
		{
			ordinal_type_interface oti=new ordinal_type_interface();
			oti.inc_method=create_oti_method(SemanticTree.basic_function_type.cinc,_char_type);
			oti.dec_method=create_oti_method(SemanticTree.basic_function_type.cdec,_char_type);
			
			SymbolInfo si=_char_type.find_in_additional_names(compiler_string_consts.greq_name);
			basic_function_node bfn=(basic_function_node)si.sym_info;
			
			oti.greater_eq_method=bfn;

			si=_char_type.find_in_additional_names(compiler_string_consts.smeq_name);
			bfn=(basic_function_node)si.sym_info;

			oti.lower_eq_method=bfn;

			constant_node cn_max=new int_const_node(char.MaxValue,_char_type);
			constant_node cn_min=new int_const_node(char.MinValue,_char_type);

			oti.upper_value=cn_max;
			oti.lower_value=cn_min;

			parameterArrayList pal=new parameterArrayList();
			bfn=new basic_function_node(SemanticTree.basic_function_type.chartoi,pal,_integer_type);
			common_parameter cp=new common_parameter(compiler_string_consts.unary_param_name,_char_type,
				SemanticTree.parameter_type.value,null);
			
			oti.value_to_int=bfn;
			oti.ordinal_type_to_int=new ordinal_type_to_int(char_to_int);
			_char_type.add_internal_interface(oti);
		}
		private basic_function_node create_oti_method(SemanticTree.basic_function_type bft,type_node type)
		{
			parameterArrayList pal=new parameterArrayList();
			basic_function_node bfn=new basic_function_node(bft,pal,type);
			common_parameter cp=new common_parameter(compiler_string_consts.unary_param_name,type,
				SemanticTree.parameter_type.var,null);
			pal.Add(cp);
			bfn.is_overload=true;
			return bfn;
		}
		//End: No v drugom smisle reference.

		public void make_empty_operator(string name,compiled_type_node ctn)
		{
			parameterArrayList pars=new parameterArrayList();
			empty_function_node efn=new empty_function_node(pars,ctn);
			efn.is_overload=true;
			basic_parameter par=new basic_parameter(compiler_string_consts.unary_param_name,ctn,
				SemanticTree.parameter_type.value,null);
			pars.Add(par);
			ctn.add_additional_name(name,new SymbolInfo(efn));
		}
		private void make_compiled_object_operator(string name,compiled_type_node tp,SemanticTree.basic_function_type bft,
			SemanticTree.parameter_type first_param_type)
		{
			parameterArrayList pars=new parameterArrayList();
			basic_function_node bfn=new basic_function_node(bft,pars,tp);
			bfn.is_overload=true;
			basic_parameter to=new basic_parameter(compiler_string_consts.left_param_name,tp,
				first_param_type,bfn);
			basic_parameter from=new basic_parameter(compiler_string_consts.right_param_name,tp,
				SemanticTree.parameter_type.value,bfn);
			pars.Add(to);
			pars.Add(from);
			tp.add_additional_name(name,new SymbolInfo(bfn));
		}
		private void make_type_conversion(compiled_type_node from,compiled_type_node to,type_compare tc,
			SemanticTree.basic_function_type bft)
		{
			parameterArrayList pars=new parameterArrayList();
			basic_function_node conv_method=new basic_function_node(bft,pars,to);
			basic_parameter bp=new basic_parameter(compiler_string_consts.unary_param_name,
				from,SemanticTree.parameter_type.value,conv_method);
			pars.Add(bp);

			type_intersection_node inter_node=new type_intersection_node(tc);
			inter_node.this_to_another=new type_conversion_factory(conv_method);
			from.add_intersection_node(to,inter_node);
		}
		private void make_unary_operator(string operator_name,compiled_type_node to,
			SemanticTree.basic_function_type bft,type_node ret_value_type)
		{
			parameterArrayList pars=new parameterArrayList();
			basic_function_node bfn=new basic_function_node(bft,pars,ret_value_type);
			bfn.is_overload=true;
			basic_parameter par=new basic_parameter(compiler_string_consts.unary_param_name,to,
				SemanticTree.parameter_type.value,bfn);
			pars.Add(par);
			to.add_additional_name(operator_name,new SymbolInfo(bfn));
		}
		private basic_function_node make_common_binary_operation(string operator_name,compiled_type_node def_type,compiled_type_node left,
			compiled_type_node right,SemanticTree.basic_function_type bft,type_node ret_value_type)
		{
			parameterArrayList pars=new parameterArrayList();
			basic_function_node bfn=new basic_function_node(bft,pars,ret_value_type);
			bfn.is_overload=true;
			basic_parameter par_left=new basic_parameter(compiler_string_consts.left_param_name,left,
				SemanticTree.parameter_type.value,bfn);
			basic_parameter par_right=new basic_parameter(compiler_string_consts.right_param_name,right,
				SemanticTree.parameter_type.value,bfn);
			pars.Add(par_left);
			pars.Add(par_right);
			def_type.add_additional_name(operator_name,new SymbolInfo(bfn));
			return bfn;
		}