コード例 #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);
        }
コード例 #2
0
 public SymbolInfo(basic_function_node value)
 {
     //_name_information_type=name_information_type.nit_basic_function;
     _sym_info     = value;
     _access_level = access_level.al_public;
     _symbol_kind  = get_function_kind(value);
 }
コード例 #3
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);
        }
コード例 #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));
        }
コード例 #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);
        }
コード例 #6
0
        private symbol_kind get_function_kind(function_node fn)
        {
            common_function_node cfn = fn as common_function_node;

            if (cfn != null)
            {
                return(get_function_kind(cfn, cfn.is_overload));
            }
            basic_function_node bfn = fn as basic_function_node;

            if (bfn != null)
            {
                return(get_function_kind(bfn, bfn.is_overload));
            }
            return(symbol_kind.sk_none);
        }
コード例 #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));
        }
コード例 #8
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));
        }
コード例 #9
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);
        }
コード例 #10
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));
		}
コード例 #11
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;
		}
コード例 #12
0
 public basic_parameter(string name, type_node type, parameter_type par_type,
                        basic_function_node cont_function) : base(name, type)
 {
     _cont_function = cont_function;
     _par_type      = par_type;
 }
コード例 #13
0
		private void initialize_types()
		{
			_integer_type=compiled_type_node.get_type_node(typeof(int));
			_bool_type=compiled_type_node.get_type_node(typeof(bool));
			_real_type=compiled_type_node.get_type_node(typeof(double));
			_char_type=compiled_type_node.get_type_node(typeof(char));
			_string_type=compiled_type_node.get_type_node(typeof(string));

			_pointer_type=compiled_type_node.get_type_node(Type.GetType("System.Void*"));
			NetInitialize();

			//Преобразования типов.
			make_type_conversion(_integer_type,_real_type,type_compare.less_type,SemanticTree.basic_function_type.itod);

			//Операции для типа integer.
			//Присваивание для integer.
			make_assign_operator(_integer_type,SemanticTree.basic_function_type.iassign);

			//Унарные операции.
			make_unary_operator(compiler_string_consts.minus_name,_integer_type,SemanticTree.basic_function_type.iunmin);
			make_unary_operator(compiler_string_consts.not_name,_integer_type,SemanticTree.basic_function_type.inot);
			make_empty_operator(compiler_string_consts.plus_name,_integer_type);
			
			//Арифметические операции.
			_int_add=make_binary_operator(compiler_string_consts.plus_name,_integer_type,SemanticTree.basic_function_type.iadd);
			_int_sub=make_binary_operator(compiler_string_consts.minus_name,_integer_type,SemanticTree.basic_function_type.isub);
			make_binary_operator(compiler_string_consts.mul_name,_integer_type,SemanticTree.basic_function_type.imul);
			make_binary_operator(compiler_string_consts.idiv_name,_integer_type,SemanticTree.basic_function_type.idiv);
			make_binary_operator(compiler_string_consts.mod_name,_integer_type,SemanticTree.basic_function_type.imod);
			//Операция / для integer.
			make_common_binary_operation(compiler_string_consts.div_name,_integer_type,_real_type,_real_type,
				SemanticTree.basic_function_type.ddiv,_real_type);

			//Опрерации сравнения.
			make_binary_operator(compiler_string_consts.gr_name,_integer_type,SemanticTree.basic_function_type.igr,_bool_type);
			make_binary_operator(compiler_string_consts.greq_name,_integer_type,SemanticTree.basic_function_type.igreq,_bool_type);
			make_binary_operator(compiler_string_consts.sm_name,_integer_type,SemanticTree.basic_function_type.ism,_bool_type);
			make_binary_operator(compiler_string_consts.smeq_name,_integer_type,SemanticTree.basic_function_type.ismeq,_bool_type);
			make_binary_operator(compiler_string_consts.eq_name,_integer_type,SemanticTree.basic_function_type.ieq,_bool_type);
			make_binary_operator(compiler_string_consts.noteq_name,_integer_type,SemanticTree.basic_function_type.inoteq,_bool_type);

			//Логические опреции.
			make_binary_operator(compiler_string_consts.and_name,_integer_type,SemanticTree.basic_function_type.iand);
			make_binary_operator(compiler_string_consts.or_name,_integer_type,SemanticTree.basic_function_type.ior);
			make_binary_operator(compiler_string_consts.xor_name,_integer_type,SemanticTree.basic_function_type.ixor);
			make_binary_operator(compiler_string_consts.shl_name,_integer_type,SemanticTree.basic_function_type.ishl);
			make_binary_operator(compiler_string_consts.shr_name,_integer_type,SemanticTree.basic_function_type.ishr);

			//real type.
			//Assign.
			make_assign_operator(_real_type,SemanticTree.basic_function_type.dassign);

			//Унарные операции.
			make_unary_operator(compiler_string_consts.minus_name,_real_type,SemanticTree.basic_function_type.dunmin);
			make_empty_operator(compiler_string_consts.plus_name,_real_type);

			//Арифметические операции.
			make_binary_operator(compiler_string_consts.plus_name,_real_type,SemanticTree.basic_function_type.dadd);
			make_binary_operator(compiler_string_consts.minus_name,_real_type,SemanticTree.basic_function_type.dsub);
			make_binary_operator(compiler_string_consts.mul_name,_real_type,SemanticTree.basic_function_type.dmul);
			make_binary_operator(compiler_string_consts.div_name,_real_type,SemanticTree.basic_function_type.ddiv);

			//Опрерации сравнения.
			make_binary_operator(compiler_string_consts.gr_name,_real_type,SemanticTree.basic_function_type.dgr,_bool_type);
			make_binary_operator(compiler_string_consts.greq_name,_real_type,SemanticTree.basic_function_type.dgreq,_bool_type);
			make_binary_operator(compiler_string_consts.sm_name,_real_type,SemanticTree.basic_function_type.dsm,_bool_type);
			make_binary_operator(compiler_string_consts.smeq_name,_real_type,SemanticTree.basic_function_type.dsmeq,_bool_type);
			make_binary_operator(compiler_string_consts.eq_name,_real_type,SemanticTree.basic_function_type.deq,_bool_type);
			make_binary_operator(compiler_string_consts.noteq_name,_real_type,SemanticTree.basic_function_type.dnoteq,_bool_type);

			//char type.
			//Assign.
			make_assign_operator(_char_type,SemanticTree.basic_function_type.charassign);

			//Опрерации сравнения.
			make_binary_operator(compiler_string_consts.gr_name,_char_type,SemanticTree.basic_function_type.chargr,_bool_type);
			make_binary_operator(compiler_string_consts.greq_name,_char_type,SemanticTree.basic_function_type.chargreq,_bool_type);
			make_binary_operator(compiler_string_consts.sm_name,_char_type,SemanticTree.basic_function_type.charsm,_bool_type);
			make_binary_operator(compiler_string_consts.smeq_name,_char_type,SemanticTree.basic_function_type.charsmeq,_bool_type);
			make_binary_operator(compiler_string_consts.eq_name,_char_type,SemanticTree.basic_function_type.chareq,_bool_type);
			make_binary_operator(compiler_string_consts.noteq_name,_char_type,SemanticTree.basic_function_type.charnoteq,_bool_type);

			//boolean type.
			//Assign.
			make_assign_operator(_bool_type,SemanticTree.basic_function_type.boolassign);

			//Логические операции.
			//Унарные операции.
			make_unary_operator(compiler_string_consts.not_name,_bool_type,SemanticTree.basic_function_type.bnot);

			//Логическме операции.
			make_binary_operator(compiler_string_consts.and_name,_bool_type,SemanticTree.basic_function_type.band);
			make_binary_operator(compiler_string_consts.or_name,_bool_type,SemanticTree.basic_function_type.bor);
			make_binary_operator(compiler_string_consts.xor_name,_bool_type,SemanticTree.basic_function_type.bxor);
			make_unary_operator(compiler_string_consts.not_name,_bool_type,SemanticTree.basic_function_type.boolnot);

			//Опрерации сравнения.
			make_binary_operator(compiler_string_consts.gr_name,_bool_type,SemanticTree.basic_function_type.boolgr);
			make_binary_operator(compiler_string_consts.greq_name,_bool_type,SemanticTree.basic_function_type.boolgreq);
			make_binary_operator(compiler_string_consts.sm_name,_bool_type,SemanticTree.basic_function_type.boolsm);
			make_binary_operator(compiler_string_consts.smeq_name,_bool_type,SemanticTree.basic_function_type.boolsmeq);
			make_binary_operator(compiler_string_consts.eq_name,_bool_type,SemanticTree.basic_function_type.booleq);
			make_binary_operator(compiler_string_consts.noteq_name,_bool_type,SemanticTree.basic_function_type.boolnoteq);

			mark_int_as_ordinal();
			mark_char_as_ordinal();
		}
コード例 #14
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;
		}
コード例 #15
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);
		}
コード例 #16
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));
		}
コード例 #17
0
        private void initialize_types()
        {
            _integer_type = compiled_type_node.get_type_node(typeof(int));
            _bool_type    = compiled_type_node.get_type_node(typeof(bool));
            _real_type    = compiled_type_node.get_type_node(typeof(double));
            _char_type    = compiled_type_node.get_type_node(typeof(char));
            _string_type  = compiled_type_node.get_type_node(typeof(string));

            _pointer_type = compiled_type_node.get_type_node(Type.GetType("System.Void*"));
            NetInitialize();

            //Преобразования типов.
            make_type_conversion(_integer_type, _real_type, type_compare.less_type, SemanticTree.basic_function_type.itod);

            //Операции для типа integer.
            //Присваивание для integer.
            make_assign_operator(_integer_type, SemanticTree.basic_function_type.iassign);

            //Унарные операции.
            make_unary_operator(compiler_string_consts.minus_name, _integer_type, SemanticTree.basic_function_type.iunmin);
            make_unary_operator(compiler_string_consts.not_name, _integer_type, SemanticTree.basic_function_type.inot);
            make_empty_operator(compiler_string_consts.plus_name, _integer_type);

            //Арифметические операции.
            _int_add = make_binary_operator(compiler_string_consts.plus_name, _integer_type, SemanticTree.basic_function_type.iadd);
            _int_sub = make_binary_operator(compiler_string_consts.minus_name, _integer_type, SemanticTree.basic_function_type.isub);
            make_binary_operator(compiler_string_consts.mul_name, _integer_type, SemanticTree.basic_function_type.imul);
            make_binary_operator(compiler_string_consts.idiv_name, _integer_type, SemanticTree.basic_function_type.idiv);
            make_binary_operator(compiler_string_consts.mod_name, _integer_type, SemanticTree.basic_function_type.imod);
            //Операция / для integer.
            make_common_binary_operation(compiler_string_consts.div_name, _integer_type, _real_type, _real_type,
                                         SemanticTree.basic_function_type.ddiv, _real_type);

            //Опрерации сравнения.
            make_binary_operator(compiler_string_consts.gr_name, _integer_type, SemanticTree.basic_function_type.igr, _bool_type);
            make_binary_operator(compiler_string_consts.greq_name, _integer_type, SemanticTree.basic_function_type.igreq, _bool_type);
            make_binary_operator(compiler_string_consts.sm_name, _integer_type, SemanticTree.basic_function_type.ism, _bool_type);
            make_binary_operator(compiler_string_consts.smeq_name, _integer_type, SemanticTree.basic_function_type.ismeq, _bool_type);
            make_binary_operator(compiler_string_consts.eq_name, _integer_type, SemanticTree.basic_function_type.ieq, _bool_type);
            make_binary_operator(compiler_string_consts.noteq_name, _integer_type, SemanticTree.basic_function_type.inoteq, _bool_type);

            //Логические опреции.
            make_binary_operator(compiler_string_consts.and_name, _integer_type, SemanticTree.basic_function_type.iand);
            make_binary_operator(compiler_string_consts.or_name, _integer_type, SemanticTree.basic_function_type.ior);
            make_binary_operator(compiler_string_consts.xor_name, _integer_type, SemanticTree.basic_function_type.ixor);
            make_binary_operator(compiler_string_consts.shl_name, _integer_type, SemanticTree.basic_function_type.ishl);
            make_binary_operator(compiler_string_consts.shr_name, _integer_type, SemanticTree.basic_function_type.ishr);

            //real type.
            //Assign.
            make_assign_operator(_real_type, SemanticTree.basic_function_type.dassign);

            //Унарные операции.
            make_unary_operator(compiler_string_consts.minus_name, _real_type, SemanticTree.basic_function_type.dunmin);
            make_empty_operator(compiler_string_consts.plus_name, _real_type);

            //Арифметические операции.
            make_binary_operator(compiler_string_consts.plus_name, _real_type, SemanticTree.basic_function_type.dadd);
            make_binary_operator(compiler_string_consts.minus_name, _real_type, SemanticTree.basic_function_type.dsub);
            make_binary_operator(compiler_string_consts.mul_name, _real_type, SemanticTree.basic_function_type.dmul);
            make_binary_operator(compiler_string_consts.div_name, _real_type, SemanticTree.basic_function_type.ddiv);

            //Опрерации сравнения.
            make_binary_operator(compiler_string_consts.gr_name, _real_type, SemanticTree.basic_function_type.dgr, _bool_type);
            make_binary_operator(compiler_string_consts.greq_name, _real_type, SemanticTree.basic_function_type.dgreq, _bool_type);
            make_binary_operator(compiler_string_consts.sm_name, _real_type, SemanticTree.basic_function_type.dsm, _bool_type);
            make_binary_operator(compiler_string_consts.smeq_name, _real_type, SemanticTree.basic_function_type.dsmeq, _bool_type);
            make_binary_operator(compiler_string_consts.eq_name, _real_type, SemanticTree.basic_function_type.deq, _bool_type);
            make_binary_operator(compiler_string_consts.noteq_name, _real_type, SemanticTree.basic_function_type.dnoteq, _bool_type);

            //char type.
            //Assign.
            make_assign_operator(_char_type, SemanticTree.basic_function_type.charassign);

            //Опрерации сравнения.
            make_binary_operator(compiler_string_consts.gr_name, _char_type, SemanticTree.basic_function_type.chargr, _bool_type);
            make_binary_operator(compiler_string_consts.greq_name, _char_type, SemanticTree.basic_function_type.chargreq, _bool_type);
            make_binary_operator(compiler_string_consts.sm_name, _char_type, SemanticTree.basic_function_type.charsm, _bool_type);
            make_binary_operator(compiler_string_consts.smeq_name, _char_type, SemanticTree.basic_function_type.charsmeq, _bool_type);
            make_binary_operator(compiler_string_consts.eq_name, _char_type, SemanticTree.basic_function_type.chareq, _bool_type);
            make_binary_operator(compiler_string_consts.noteq_name, _char_type, SemanticTree.basic_function_type.charnoteq, _bool_type);

            //boolean type.
            //Assign.
            make_assign_operator(_bool_type, SemanticTree.basic_function_type.boolassign);

            //Логические операции.
            //Унарные операции.
            make_unary_operator(compiler_string_consts.not_name, _bool_type, SemanticTree.basic_function_type.bnot);

            //Логическме операции.
            make_binary_operator(compiler_string_consts.and_name, _bool_type, SemanticTree.basic_function_type.band);
            make_binary_operator(compiler_string_consts.or_name, _bool_type, SemanticTree.basic_function_type.bor);
            make_binary_operator(compiler_string_consts.xor_name, _bool_type, SemanticTree.basic_function_type.bxor);
            make_unary_operator(compiler_string_consts.not_name, _bool_type, SemanticTree.basic_function_type.boolnot);

            //Опрерации сравнения.
            make_binary_operator(compiler_string_consts.gr_name, _bool_type, SemanticTree.basic_function_type.boolgr);
            make_binary_operator(compiler_string_consts.greq_name, _bool_type, SemanticTree.basic_function_type.boolgreq);
            make_binary_operator(compiler_string_consts.sm_name, _bool_type, SemanticTree.basic_function_type.boolsm);
            make_binary_operator(compiler_string_consts.smeq_name, _bool_type, SemanticTree.basic_function_type.boolsmeq);
            make_binary_operator(compiler_string_consts.eq_name, _bool_type, SemanticTree.basic_function_type.booleq);
            make_binary_operator(compiler_string_consts.noteq_name, _bool_type, SemanticTree.basic_function_type.boolnoteq);

            mark_int_as_ordinal();
            mark_char_as_ordinal();
        }
コード例 #18
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);
		}
コード例 #19
0
            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);
            }
コード例 #20
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));
		}
コード例 #21
0
        private static void init_temp_methods_and_consts(common_namespace_node system_namespace, SymbolTable.Scope where_add,
                                                         initialization_properties initialization_properties, location system_unit_location)
        {
            //SymbolTable.Scope sc = system_namespace.scope;
            SymbolTable.Scope             sc = where_add;
            namespace_constant_definition _true_constant_definition = new namespace_constant_definition(
                PascalABCCompiler.TreeConverter.compiler_string_consts.true_const_name, SystemLibrary.true_constant, system_unit_location, system_namespace);

            system_namespace.constants.AddElement(_true_constant_definition);

            namespace_constant_definition _false_constant_definition = new namespace_constant_definition(
                PascalABCCompiler.TreeConverter.compiler_string_consts.false_const_name, SystemLibrary.false_constant, system_unit_location, system_namespace);

            system_namespace.constants.AddElement(_false_constant_definition);

            sc.AddSymbol(PascalABCCompiler.TreeConverter.compiler_string_consts.true_const_name, new PascalABCCompiler.TreeConverter.SymbolInfo(_true_constant_definition));
            sc.AddSymbol(PascalABCCompiler.TreeConverter.compiler_string_consts.false_const_name, new PascalABCCompiler.TreeConverter.SymbolInfo(_false_constant_definition));


            //TODO: Сделано по быстрому. Переделать. Можно просто один раз сериализовать модуль system и не инициализировать его всякий раз подобным образом. Неплохо-бы использовать NetHelper.GetMethod.
            Type tp = typeof(Console);
            compiled_function_node cfn;

            System.Type[] arr = new System.Type[1];
            System.Reflection.MethodInfo mi;

            //TODO: Сделать узел или базовый метод создания и удаления объекта.
            common_namespace_function_node cnfn = new common_namespace_function_node(TreeConverter.compiler_string_consts.new_procedure_name, null, null, system_namespace, null);

            cnfn.parameters.AddElement(new common_parameter("ptr", SystemLibrary.pointer_type, SemanticTree.parameter_type.value, cnfn,
                                                            concrete_parameter_type.cpt_var, null, null));
            cnfn.SpecialFunctionKind   = SemanticTree.SpecialFunctionKind.New;
            _NewProcedure              = new PascalABCCompiler.TreeConverter.SymbolInfo(cnfn);
            _NewProcedure.symbol_kind  = PascalABCCompiler.TreeConverter.symbol_kind.sk_overload_function;
            _NewProcedure.access_level = PascalABCCompiler.TreeConverter.access_level.al_public;
            _NewProcedureDecl          = cnfn;
            sc.AddSymbol(TreeConverter.compiler_string_consts.new_procedure_name, _NewProcedure);

            cnfn = new common_namespace_function_node(TreeConverter.compiler_string_consts.dispose_procedure_name, null, null, system_namespace, null);
            cnfn.parameters.AddElement(new common_parameter("ptr", SystemLibrary.pointer_type, SemanticTree.parameter_type.value,
                                                            cnfn, concrete_parameter_type.cpt_var, null, null));
            _DisposeProcedure              = new PascalABCCompiler.TreeConverter.SymbolInfo(cnfn);
            _DisposeProcedure.symbol_kind  = PascalABCCompiler.TreeConverter.symbol_kind.sk_overload_function;
            _DisposeProcedure.access_level = PascalABCCompiler.TreeConverter.access_level.al_public;
            _DisposeProcedureDecl          = cnfn;
            cnfn.SpecialFunctionKind       = SemanticTree.SpecialFunctionKind.Dispose;
            sc.AddSymbol(TreeConverter.compiler_string_consts.dispose_procedure_name, _DisposeProcedure);

            cnfn = new common_namespace_function_node(TreeConverter.compiler_string_consts.new_array_procedure_name, compiled_type_node.get_type_node(typeof(Array)), null, system_namespace, null);
            cnfn.parameters.AddElement(new common_parameter("t", compiled_type_node.get_type_node(typeof(Type)), SemanticTree.parameter_type.value, cnfn,
                                                            concrete_parameter_type.cpt_none, null, null));
            cnfn.parameters.AddElement(new common_parameter("n", SystemLibrary.integer_type, SemanticTree.parameter_type.value, cnfn,
                                                            concrete_parameter_type.cpt_none, null, null));
            cnfn.SpecialFunctionKind = SemanticTree.SpecialFunctionKind.NewArray;
            _NewArrayProcedure       = new PascalABCCompiler.TreeConverter.SymbolInfo(cnfn);
            _NewArrayProcedureDecl   = cnfn;
            //sc.AddSymbol(TreeConverter.compiler_string_consts.new_procedure_name, _NewProcedure);

            basic_function_node break_procedure = new basic_function_node(SemanticTree.basic_function_type.none,
                                                                          null, true, PascalABCCompiler.TreeConverter.compiler_string_consts.break_procedure_name);

            break_procedure.compile_time_executor = initialization_properties.break_executor;
            sc.AddSymbol(PascalABCCompiler.TreeConverter.compiler_string_consts.break_procedure_name, new PascalABCCompiler.TreeConverter.SymbolInfo(break_procedure));

            basic_function_node continue_procedure = new basic_function_node(SemanticTree.basic_function_type.none,
                                                                             null, true, PascalABCCompiler.TreeConverter.compiler_string_consts.continue_procedure_name);

            continue_procedure.compile_time_executor = initialization_properties.continue_executor;
            sc.AddSymbol(PascalABCCompiler.TreeConverter.compiler_string_consts.continue_procedure_name, new PascalABCCompiler.TreeConverter.SymbolInfo(continue_procedure));

            basic_function_node exit_procedure = new basic_function_node(SemanticTree.basic_function_type.none,
                                                                         null, true, PascalABCCompiler.TreeConverter.compiler_string_consts.exit_procedure_name);

            exit_procedure.compile_time_executor = initialization_properties.exit_executor;
            sc.AddSymbol(PascalABCCompiler.TreeConverter.compiler_string_consts.exit_procedure_name, new PascalABCCompiler.TreeConverter.SymbolInfo(exit_procedure));

            sc.AddSymbol(PascalABCCompiler.TreeConverter.compiler_string_consts.set_length_procedure_name,
                         new PascalABCCompiler.TreeConverter.SymbolInfo(SystemLibrary.resize_func, PascalABCCompiler.TreeConverter.access_level.al_public, PascalABCCompiler.TreeConverter.symbol_kind.sk_overload_function));
        }