// these methods call the worker methods in TreeTransform. They are only
 // here because their names and parameters are generated differently
 public override void ExitEntity([NotNull] XP.EntityContext context)
 {
     if (context.GetChild(0) is XP.XppclassContext)
     {
         // classes are handled separately because we need to add the external methods to their members
         // so suppress call to base implementation. We will bind them later from ExitSource by calling bindClasses
         return;
     }
     base.ExitEntity(context);
 }
Пример #2
0
        public override void ExitFoxsource([NotNull] XP.FoxsourceContext context)
        {
            if (context.StmtBlk != null && context.StmtBlk._Stmts.Count > 0)
            {
                // Generate leading code for the file
                // Function needs at least an Id and a Statement Block
                // The rest is default
                var name   = System.IO.Path.GetFileNameWithoutExtension(_fileName);
                var entity = new XP.EntityContext(context, 0);
                var func   = new XP.FuncprocContext(entity, 0);
                var id     = new XP.IdentifierContext(func, 0);
                var token  = new XSharpToken(XP.FUNCTION, "FUNCTION");
                var sig    = new XP.SignatureContext(func, 0);
                sig.Id     = id;
                func.Sig   = sig;
                token.line = 1;
                token.charPositionInLine = 1;
                func.T     = token;
                token      = new XSharpToken(XP.ID, name);
                token.line = 1;
                token.charPositionInLine = 1;
                id.Start = id.Stop = token;
                sig.AddChild(sig.Id);
                ExitIdentifier(id);    // Generate SyntaxToken
                if (string.Equals(name, _entryPoint, XSharpString.Comparison))
                {
                    sig.Type       = new XP.DatatypeContext(func, 0);
                    sig.Type.Start = new XSharpToken(XP.AS, "AS");
                    sig.Type.Stop  = new XSharpToken(XP.VOID, "VOID");
                    sig.Type.Put(_voidType);
                    sig.AddChild(sig.Type);
                }
                func.Attributes = new XP.AttributesContext(func, 0);
                func.Attributes.PutList(MakeCompilerGeneratedAttribute());
                func.StmtBlk           = context.StmtBlk;
                context.StmtBlk.parent = func;
                func.Start             = func.StmtBlk.Start;
                func.Stop = func.StmtBlk.Stop;
                func.AddChild(func.Sig);
                func.AddChild(func.StmtBlk);
                Entities.Push(func);
                ExitFuncproc(func);     // Generate function
                Entities.Pop();
                entity.Start = func.Start;
                entity.Stop  = func.Stop;
                entity.AddChild(func);
                ExitEntity(entity);
                context._Entities.Insert(0, entity);
            }

            _exitSource(context);
        }
Пример #3
0
 private static void processType(XP.EntityContext xnode,
                                 Dictionary <string, List <PartialPropertyElement> > partialClasses,
                                 IEnumerable <Syntax.UsingDirectiveSyntax> usings
                                 )
 {
     if (xnode != null && xnode.ChildCount == 1)
     {
         var cls = xnode.GetChild(0) as XP.IPartialPropertyContext;
         if (cls != null && (cls.Data.Partial || cls.Data.PartialProps))
         {
             var name = cls.Name;
             if (!partialClasses.ContainsKey(name))
             {
                 partialClasses.Add(name, new List <PartialPropertyElement>());
             }
             partialClasses[name].Add(new PartialPropertyElement(cls, usings));
         }
     }
 }