private void VisitNonStaticEventReference(nonstatic_event_reference en)
 {
     VisitExpression(en.obj);
     WriteEventReference(en.en as common_event);
 }
 private expression_node ident_value_reciving(SymbolInfo si, SyntaxTree.ident _ident)
 {
     //SymbolInfo si=blocks.find(_ident.name);
     location lloc = get_location(_ident);
     definition_node dn = context.check_name_node_type(_ident.name, si, get_location(_ident), general_node_type.variable_node,
         general_node_type.function_node, general_node_type.property_node, general_node_type.constant_definition,
         general_node_type.event_node);
     switch (dn.general_node_type)
     {
         case general_node_type.constant_definition:
             {
                 constant_definition_node cdn = (constant_definition_node)dn;
                 if (cdn.const_value is array_const || cdn.const_value is record_constant || cdn.const_value is common_namespace_function_call_as_constant)
                 {
                 	return create_constant_reference(cdn,lloc);
                 }
                 if (cdn.const_value == null)
                     AddError(new UndefinedNameReference(cdn.name,get_location(_ident)));
                 constant_node cn = cdn.const_value.get_constant_copy(get_location(_ident));
                 if (cn != null) return cn;
                 return cdn.const_value;
             }
         case general_node_type.variable_node:
             {
                 local_variable lv = dn as local_variable;
                 if (lv != null && (lv.function is common_method_node))
                 {
                     //self variable
                     if ((lv.function as common_method_node).self_variable == lv)
                         //return new this_node((lv.function as common_method_node).cont_type, lloc);
                         return new this_node(lv.type, lloc);
                     //return GetCurrentObjectReference((lv.function as common_method_node).cont_type.Scope, lloc);
                 }
                 return create_variable_reference(dn, lloc);
             }
         case general_node_type.function_node:
             {
                 //return convertion_data_and_alghoritms.create_full_function_call(new expressions_list(),
                 //	si,lloc,blocks.converted_type,blocks.top_function,false);
                 if (!(si.sym_info is common_in_function_function_node))
                     return make_delegate_wrapper(null, si, lloc, ((si.sym_info is common_method_node) && ((common_method_node)si.sym_info).IsStatic));
                 return convertion_data_and_alghoritms.create_full_function_call(new expressions_list(),
                 	si,lloc,context.converted_type,context.top_function,false);
             }
         case general_node_type.property_node:
             {
                 property_node pn = (property_node)dn;
                 function_node fn = pn.get_function;
                 if (fn == null)
                 {
                     AddError(new ThisPropertyCanNotBeReaded(pn, lloc));
                 }
                 if (pn.polymorphic_state == SemanticTree.polymorphic_state.ps_static)
                 {
                     return create_static_method_call(fn, lloc, pn.comprehensive_type, false);
                 }
                 check_property_no_params(pn, lloc);
                 //this_node thisnode = new this_node(context.converted_type, lloc);
                 if (pn.comprehensive_type.Scope == null && pn is compiled_property_node)
                 	(pn.comprehensive_type as compiled_type_node).init_scope();
                 return create_not_static_method_call(fn, GetCurrentObjectReference(pn.comprehensive_type.Scope, fn, lloc), lloc, false);
             }
         case general_node_type.event_node:
             {
                 if (dn.semantic_node_type == semantic_node_type.compiled_event)
                 {
                     compiled_event ce = (compiled_event)dn;
                     if (ce.is_static)
                     {
                         static_event_reference ser = new static_event_reference(ce, get_location(_ident));
                         return ser;
                     }
                     nonstatic_event_reference nser = new nonstatic_event_reference(
                         new this_node(context.converted_type, lloc), ce, lloc);
                     return nser;
                 }
                 else if (dn.semantic_node_type == semantic_node_type.common_event)
                 {
                     common_event ce = (common_event)dn;
                     if (ce.is_static)
                     {
                         static_event_reference ser = new static_event_reference(ce, get_location(_ident));
                         return ser;
                     }
                     nonstatic_event_reference nser = new nonstatic_event_reference(
                         new this_node(context.converted_type, lloc), ce, lloc);
                     return nser;
                 }
                 else if (dn.semantic_node_type == semantic_node_type.common_namespace_event)
                 {
                     common_namespace_event cne = (common_namespace_event)dn;
                     if (_compiled_unit.namespaces.IndexOf(cne.namespace_node) != -1)
                     {
                         static_event_reference ser = new static_event_reference(cne, get_location(_ident));
                         return ser;
                     }
                     else
                         AddError(get_location(_ident), "EVENT_{0}_MUST_BE_IN_LEFT_PART", cne.name);
                 }
                 break;
             }
     }
     return null;
 }
 private addressed_expression address_expression_reciving(SyntaxTree.ident id_right, SymbolInfo si,
     expression_node en)
 {
     if (si != null && si.sym_info != null &&
         si.sym_info.semantic_node_type == semantic_node_type.indefinite_definition_node)
     {
         return new indefinite_reference(si.sym_info as indefinite_definition_node, get_location(id_right));
     }
 	definition_node dn = null;
 	if (!internal_is_assign)
         dn = context.check_name_node_type(id_right.name, si, get_location(id_right),
         general_node_type.variable_node, general_node_type.property_node, general_node_type.event_node);
     else
         dn = context.check_name_node_type(id_right.name, si, get_location(id_right),
         general_node_type.variable_node, general_node_type.property_node, general_node_type.event_node, general_node_type.constant_definition);
     if (dn.general_node_type == general_node_type.constant_definition)
     {
         AddError(get_location(id_right), "CAN_NOT_ASSIGN_TO_CONSTANT_OBJECT");
     }
     switch (dn.general_node_type)
     {
         case general_node_type.variable_node:
             {
                 return create_class_field_reference(en, dn, id_right);
             }
         case general_node_type.property_node:
             {
                 property_node pn = (property_node)dn;
                 if (pn.polymorphic_state == SemanticTree.polymorphic_state.ps_static)
                 {
                     AddError(new CanNotReferenceToStaticPropertyWithExpression(pn, get_location(id_right), pn.comprehensive_type));
                 }
                 try_convert_typed_expression_to_function_call(ref en);
                 non_static_property_reference pr = new non_static_property_reference(pn, en, get_location(id_right));
                 return pr;
             }
         case general_node_type.event_node:
             {
                 if (dn.semantic_node_type == semantic_node_type.compiled_event)
                 {
                     compiled_event ce = (compiled_event)dn;
                     if (ce.is_static)
                     {
                         //throw new NonStaticAndStaticEvevnt();
                     }
                     nonstatic_event_reference ser = new nonstatic_event_reference(en, ce, get_location(id_right));
                     return ser;
                 }
                 else if (dn.semantic_node_type == semantic_node_type.common_event)
                 {
                     common_event ce = (common_event)dn;
                     if (ce.is_static)
                     {
                         //throw new NonStaticAndStaticEvevnt();
                     }
                     nonstatic_event_reference ser = new nonstatic_event_reference(en, ce, get_location(id_right));
                     return ser;
                 }
                 break;
             }
     	default : return null;
     }
     throw new CompilerInternalError("Undefined expression to address reciving");
 }
 private addressed_expression ident_address_reciving(SymbolInfo si, SyntaxTree.ident _ident)
 {
     location lloc = get_location(_ident);
     definition_node dn = null;
     if (!internal_is_assign)
         dn = context.check_name_node_type(_ident.name, si, lloc,
         general_node_type.variable_node, general_node_type.property_node, general_node_type.event_node);
     else
         dn = context.check_name_node_type(_ident.name, si, lloc,
         general_node_type.variable_node, general_node_type.property_node, general_node_type.event_node, general_node_type.constant_definition);
     if (dn.general_node_type == general_node_type.constant_definition)
         AddError(get_location(_ident), "CAN_NOT_ASSIGN_TO_CONSTANT_OBJECT");
     switch (dn.general_node_type)
     {
         case general_node_type.variable_node:
             {
                 local_variable lv = dn as local_variable;
                 if (lv != null && (lv.function is common_method_node))
                 {
                     //self variable
                     if ((lv.function as common_method_node).self_variable == lv)
                         AddError(lloc, "VARIABLE_{0}_READONLY", lv.name);
                 }
                 return create_variable_reference(dn, lloc);
             }
         case general_node_type.property_node:
             {
                 property_node pn = (property_node)dn;
                 if (pn.polymorphic_state == SemanticTree.polymorphic_state.ps_static)
                 {
                     static_property_reference spr = new static_property_reference(pn, lloc);
                     return spr;
                 }
                 //this_node thisnode=new this_node(context.converted_type,lloc);
                 if (pn.comprehensive_type.Scope == null && pn is compiled_property_node)
                 	(pn.comprehensive_type as compiled_type_node).init_scope();
                 non_static_property_reference nspr = new non_static_property_reference(pn, GetCurrentObjectReference(pn.comprehensive_type.Scope, pn, lloc), lloc);
                 return nspr;
             }
         case general_node_type.event_node:
             {
                 if (dn.semantic_node_type == semantic_node_type.compiled_event)
                 {
                     compiled_event ce = (compiled_event)dn;
                     if (ce.is_static)
                     {
                         static_event_reference ser = new static_event_reference(ce, get_location(_ident));
                         return ser;
                     }
                     nonstatic_event_reference nser = new nonstatic_event_reference(
                         GetCurrentObjectReference(ce.comprehensive_type.Scope, ce, lloc), ce, lloc);
                     return nser;
                 }
                 else if (dn.semantic_node_type == semantic_node_type.common_event)
                 {
                 	common_event ce = (common_event)dn;
                 	if (ce.is_static)
                     {
                         static_event_reference ser = new static_event_reference(ce, get_location(_ident));
                         return ser;
                     }
                     nonstatic_event_reference nser = new nonstatic_event_reference(
                         GetCurrentObjectReference(ce.comprehensive_type.Scope, ce, lloc), ce, lloc);
                     return nser;
                 }
                 else if (dn.semantic_node_type == semantic_node_type.common_namespace_event)
                 {
                     common_namespace_event cne = (common_namespace_event)dn;
                     static_event_reference ser = new static_event_reference(cne, get_location(_ident));
                     return ser;
                 }
                 break;
             }
     }
     return null;
 }