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); }
public override void EnterFoxsource([NotNull] XP.FoxsourceContext context) { base._enterSource(context); }