private common_method_node CreateInterfaceMethod(string name, int offset)
        {
            definition_node dn = null;
            if (members.TryGetValue(offset, out dn))
                return dn as common_method_node;
            common_method_node cmn = new common_method_node(name,null,null);
            //members[offset] = cmn;
            AddMember(cmn, offset);
            
            int name_ref = br.ReadInt32();

            cmn.is_final = br.ReadByte() == 1;
            cmn.newslot_awaited = br.ReadByte() == 1;

            ReadGenericFunctionInformation(cmn);
            //if (CanReadObject())
            //{
            //    cmn.generic_params = ReadGenericParams(cun.namespaces[0]);
            //    foreach (common_type_node par in cmn.generic_params)
            //    {
            //        par.generic_function_container = cmn;
            //        ReadTypeParameterEliminations(par);
            //    }
            //}

            if (br.ReadByte() == 1) //return_value_type
            {
                cmn.return_value_type = GetTypeReference();
                if (br.ReadByte() == 1)
                {
                    cmn.return_variable = GetLocalVariable(cmn);
                    cmn.var_definition_nodes_list.AddElement(cmn.return_variable);
                }
            }
            int num_par = br.ReadInt32();
            for (int i = 0; i < num_par; i++)
                cmn.parameters.AddElement(GetParameter(cmn));
            cmn.cont_type = (common_type_node)GetTypeReference(br.ReadInt32());
            if (name==null || true)
                cmn.SetName(GetStringInClass(cmn.cont_type, name_ref));
            cmn.attributes.AddRange(GetAttributes());
            cmn.is_constructor = br.ReadBoolean();
            cmn.is_forward = br.ReadBoolean();
            cmn.is_overload = br.ReadBoolean();
            cmn.set_access_level((SemanticTree.field_access_level)br.ReadByte());
            cmn.polymorphic_state = (SemanticTree.polymorphic_state)br.ReadByte();
            if (cmn.is_constructor && cmn.polymorphic_state == SemanticTree.polymorphic_state.ps_static)
                cmn.cont_type.static_constr = cmn;
            cmn.num_of_default_variables = br.ReadInt32();
            cmn.num_of_for_cycles = br.ReadInt32();
            br.ReadBoolean();
            int num_var = br.ReadInt32();
            for (int i = 0; i < num_var; i++)
            {
                local_variable lv = GetLocalVariable(cmn);
                if (lv != cmn.return_variable)
                    cmn.var_definition_nodes_list.AddElement(lv);
            }
            int num_consts = br.ReadInt32();
            for (int i = 0; i < num_consts; i++)
            {
                function_constant_definition fcd = GetFunctionConstant(cmn);
                cmn.constants.AddElement(fcd);
            }
            int num_nest_funcs = br.ReadInt32();
            for (int i = 0; i < num_nest_funcs; i++)
                cmn.functions_nodes_list.AddElement(GetNestedFunction());
            //br.ReadInt32();//code;
            cmn.loc = ReadDebugInfo();
            cmn.function_code = GetCode(br.ReadInt32());
            cmn.cont_type.methods.AddElement(cmn);
            
            return cmn;
        }
Ejemplo n.º 2
0
        public void set_override(common_method_node cmn)
        {
            cmn.polymorphic_state = SemanticTree.polymorphic_state.ps_virtual;
            type_node base_class = cmn.cont_type.base_type;
            if (base_class == null)
            {
                throw new NoMethodToOverride(cmn);
            }
            SymbolInfo si = base_class.find_in_type(cmn.name);
            function_node fn = null;
            while (si != null)
            {
                if (si.sym_info.general_node_type != general_node_type.function_node)
                {
                    throw new NoMethodToOverride(cmn);
                }
                fn = si.sym_info as function_node;
                if (convertion_data_and_alghoritms.function_eq_params(cmn, fn))
                {
                    break;
                }
                si = si.Next;
            }
            if (si == null)
            {
                throw new NoMethodToOverride(cmn);
            }

            common_method_node cmn_sec = fn as common_method_node;
            if (cmn_sec != null)
            {
                if (cmn_sec.polymorphic_state != SemanticTree.polymorphic_state.ps_virtual)
                {
                    throw new NoMethodToOverride(cmn);
                }
            }
            else
            {
                compiled_function_node cfn_sec = fn as compiled_function_node;
                if (cfn_sec != null)
                {
                    if (cfn_sec.polymorphic_state != SemanticTree.polymorphic_state.ps_virtual)
                    {
                        throw new NoMethodToOverride(cmn);
                    }
                }
                else
                {
                    throw new CompilerInternalError("Undefined method type.");
                }
            }

            cmn.overrided_method = fn;
            cmn.SetName(fn.name);
        }
 public void set_override(common_method_node cmn)
 {
     cmn.polymorphic_state = SemanticTree.polymorphic_state.ps_virtual;
     cmn.overrided_method = FindMethodToOverride(cmn);
     if (cmn.overrided_method == null)
         AddError(cmn.loc, "NO_METHOD_TO_OVERRIDE");
     cmn.SetName(cmn.overrided_method.name);
 }