protected virtual void _visit( JsNodeList node )
 {
     throw new NotImplementedException( "JsNodeList" );
 }
Пример #2
0
 public virtual JsNode _Visit(IEvent me)
 {
     if (me.DeclaringType.Kind == TypeKind.Interface)
         return null;
     var list2 = new JsNodeList { Nodes = new List<JsNode>() };
     if (me.AddAccessor != null)
         list2.Nodes.Add(Visit(me.AddAccessor));
     if (me.RemoveAccessor != null)
         list2.Nodes.Add(Visit(me.RemoveAccessor));
     return list2;
 }
 protected override void _visit( JsNodeList node )
 {
     if( node != null )
     {
         foreach (JsNode jsnode in node.Nodes)
         {
             visit( jsnode );
         }
     }
 }
Пример #4
0
 void _Visit(JsNodeList node)
 {
     VisitEachJoin(node.Nodes, Comma);
 }
Пример #5
0
 public override JsNode _Visit(IProperty pe)
 {
     if (Sk.IsNativeField(pe))
     {
         if (Sk.InlineFields(pe.GetDeclaringTypeDefinition()))
         {
             var fe = GenerateFakeField(pe);
             var value = AstNodeConverter.Visit(GetCreateInitializer(fe));
             return Js.JsonNameValue(pe.Name, (JsExpression)value);
         }
         throw new Exception();
     }
     else
     {
         var list2 = new JsNodeList { Nodes = new List<JsNode>() };
         var node2 = ExportPropertyInfo(pe);
         if (node2 != null)
             list2.Nodes.Add(node2);
         var list = GetAccessorsToExport(pe);
         if (list.Count > 0)
         {
             foreach (var accessor in list)
             {
                 var pair = (JsJsonNameValue)ExportMethod(accessor);
                 list2.Nodes.Add(pair);
             }
         }
         //else if (pe.IsAutomaticProperty())
         //{
         //    throw new NotImplementedException();
         //    //var def = CurrentType.GetDefinition(pe.IsStatic);
         //    var getter = Js.Code(String.Format("function(){{return this._{0};}}", pe.Name)); ;
         //    var setter = Js.Code(String.Format("function(value){{this._{0} = value;}}", pe.Name));
         //    list2.Nodes.Add(new JsJsonNameValue { Name = new JsJsonMember { Name = SkJs.GetEntityJsName(pe.Getter) }, Value = getter });
         //    list2.Nodes.Add(new JsJsonNameValue { Name = new JsJsonMember { Name = SkJs.GetEntityJsName(pe.Setter) }, Value = setter });
         //}
         return list2;
     }
 }
Пример #6
0
        public override JsNode _Visit(IEvent ee)
        {
            if (ee.DeclaringType.Kind == TypeKind.Interface)
                return null;
            var list2 = new JsNodeList { Nodes = new List<JsNode>() };
            if (ee.IsAutomatic(Compiler.Project))
            {
                var adder = GenerateAutomaticEventAccessor(ee, false);
                var remover = GenerateAutomaticEventAccessor(ee, true);
                //TODO:
                //var adder = Js.Code(String.Format("function(value){{this.{0}=CombineDelegates(this.{0}, value);}}", ee.Name));
                //var remover = Js.Code(String.Format("function(value){{this.{0}=RemoveDelegate(this.{0}, value);}}", ee.Name));
                list2.Nodes.Add(Js.JsonNameValue("add_" + ee.Name, adder));
                list2.Nodes.Add(Js.JsonNameValue("remove_" + ee.Name, remover));
            }
            else
            {
                var list = new List<IMethod>();
                if (ee.AddAccessor != null)
                {
                    if (ee.AddAccessor.Name == null)
                    {
                        throw new NotImplementedException();
                        //ee.AddAccessor.Name = "add_" + ee.Name;
                    }
                    list.Add(ee.AddAccessor);
                }
                if (ee.RemoveAccessor != null)
                {
                    if (ee.RemoveAccessor.Name == null)
                        throw new NotImplementedException();
                    //ee.RemoveAccessor.name = "remove_" + ee.name;
                    list.Add(ee.RemoveAccessor);
                }
                foreach (var node in list)
                {
                    var node2 = Visit(node);
                    //if (node2 == null)
                    //    throw new CompilerException(ee, "Export of event accessor returned null");
                    list2.Nodes.Add(node2);
                }

            }
            return list2;
        }