public override void VisitPreProcessorDirective(PreProcessorDirective preProcessorDirective)
 {
     if (preProcessorDirective.Type == PreProcessorDirectiveType.Define) {
         _definedSymbols.Add(preProcessorDirective.Argument);
     }
     else if (preProcessorDirective.Type == PreProcessorDirectiveType.Undef) {
         _definedSymbols.Remove(preProcessorDirective.Argument);
     }
     else {
         base.VisitPreProcessorDirective(preProcessorDirective);
     }
 }
			public override void VisitPreProcessorDirective (PreProcessorDirective preProcessorDirective)
			{
				if (searchDirectives) {
					if (preProcessorDirective.Type == PreProcessorDirectiveType.Region) {
						depth++;
					} else if (preProcessorDirective.Type == PreProcessorDirectiveType.Endregion) {
						depth--;
						if (depth == 0) {
							endregion = preProcessorDirective;
							searchDirectives = false;
						}
					}
				} else if (preProcessorDirective == regionDirective) {
					searchDirectives = true;
					depth = 1;
				}
				
				base.VisitPreProcessorDirective (preProcessorDirective);
			}
		static PreProcessorDirective GetStartDirective(PreProcessorDirective directive)
		{
			var nextNode = directive.GetPrevNode();
			int d = 0;
			while (nextNode != null) {
				var pp = nextNode as PreProcessorDirective;
				if (pp != null) {
					if (pp.Type == PreProcessorDirectiveType.Endregion) {
						d++;
					} else if (pp.Type == PreProcessorDirectiveType.Region) {
						if (d == 0) {
							return pp;
						}
						d--;
					}
				}
				nextNode = nextNode.GetPrevNode();
			}
			return null;
		}
Exemple #4
0
 public void VisitPreProcessorDirective(PreProcessorDirective node)
 {
     NotSupported(node);
 }
 public static PreProcessorDirective GetEndRegion(AstNode rootNode, PreProcessorDirective regionDirective)
 {
     var visitor = new DirectiveSearcher (regionDirective);
     rootNode.AcceptVisitor (visitor);
     return visitor.endregion;
 }
 DirectiveSearcher(PreProcessorDirective regionDirective)
 {
     if (regionDirective == null)
         throw new ArgumentNullException ("regionDirective");
     this.regionDirective = regionDirective;
 }
Exemple #7
0
 public virtual void VisitPreProcessorDirective(PreProcessorDirective preProcessorDirective)
 {
     //throw this.CreateException(preProcessorDirective);
 }
		public void VisitPreProcessorDirective(PreProcessorDirective preProcessorDirective)
		{
			formatter.StartNode(preProcessorDirective);
			formatter.WritePreProcessorDirective(preProcessorDirective.Type, preProcessorDirective.Argument);
			formatter.EndNode(preProcessorDirective);
			lastWritten = LastWritten.Whitespace;
		}
Exemple #9
0
		void InsertComments(CompilerCompilationUnit top, ConversionVisitor conversionVisitor)
		{
			AstNode insertionPoint = conversionVisitor.Unit.FirstChild;
			foreach (var special in top.SpecialsBag.Specials) {
				AstNode newLeaf = null;
				Role role = null;
				bool isDocumentationComment = false;
				var comment = special as SpecialsBag.Comment;
				if (comment != null) {
					// HACK: multiline documentation comment detection; better move this logic into the mcs tokenizer
					bool isMultilineDocumentationComment = (comment.CommentType == SpecialsBag.CommentType.Multi && comment.Content.StartsWith("*", StringComparison.Ordinal) && !comment.Content.StartsWith("**", StringComparison.Ordinal));
					isDocumentationComment = comment.CommentType == SpecialsBag.CommentType.Documentation || isMultilineDocumentationComment;
					if (conversionVisitor.convertTypeSystemMode && !isDocumentationComment)
						continue;
					var type = isMultilineDocumentationComment ? CommentType.MultiLineDocumentation : (CommentType)comment.CommentType;
					var start = new TextLocation(comment.Line, comment.Col);
					var end = new TextLocation(comment.EndLine, comment.EndCol);
					newLeaf = new Comment(type, start, end) {
						StartsLine = comment.StartsLine,
						Content = isMultilineDocumentationComment ? comment.Content.Substring(1) : comment.Content
					};
					role = Roles.Comment;
				} else if (!GenerateTypeSystemMode) {
					var pragmaDirective = special as SpecialsBag.PragmaPreProcessorDirective;
					if (pragmaDirective != null) {
						var pragma = new PragmaWarningPreprocessorDirective(new TextLocation(pragmaDirective.Line, pragmaDirective.Col), new TextLocation(pragmaDirective.EndLine, pragmaDirective.EndCol));
						pragma.AddChild(new CSharpTokenNode(new TextLocation(pragmaDirective.Line, pragmaDirective.Col), PragmaWarningPreprocessorDirective.PragmaKeywordRole), PragmaWarningPreprocessorDirective.PragmaKeywordRole);
						pragma.AddChild(new CSharpTokenNode(new TextLocation(pragmaDirective.Line, pragmaDirective.WarningColumn), PragmaWarningPreprocessorDirective.WarningKeywordRole), PragmaWarningPreprocessorDirective.WarningKeywordRole);
						var pragmaRole = pragmaDirective.Disalbe ? PragmaWarningPreprocessorDirective.DisableKeywordRole : PragmaWarningPreprocessorDirective.RestoreKeywordRole;
						pragma.AddChild(new CSharpTokenNode(new TextLocation(pragmaDirective.Line, pragmaDirective.DisableRestoreColumn), pragmaRole), pragmaRole);
						foreach (var code in pragmaDirective.Codes) {
							pragma.AddChild((PrimitiveExpression)conversionVisitor.Visit(code), PragmaWarningPreprocessorDirective.WarningRole);
						}
						newLeaf = pragma;
						role = Roles.PreProcessorDirective;
						goto end;
					}
					var lineDirective = special as SpecialsBag.LineProcessorDirective;
					if (lineDirective != null) {
						var pragma = new LinePreprocessorDirective(new TextLocation(lineDirective.Line, lineDirective.Col), new TextLocation(lineDirective.EndLine, lineDirective.EndCol));
						pragma.LineNumber = lineDirective.LineNumber;
						pragma.FileName = lineDirective.FileName;
						newLeaf = pragma;
						role = Roles.PreProcessorDirective;
						goto end;
					}
					var directive = special as SpecialsBag.PreProcessorDirective;
					if (directive != null) {
						newLeaf = new PreProcessorDirective((PreProcessorDirectiveType)((int)directive.Cmd & 0xF), new TextLocation(directive.Line, directive.Col), new TextLocation(directive.EndLine, directive.EndCol)) {
							Argument = directive.Arg,
							Take = directive.Take
						};
						role = Roles.PreProcessorDirective;
					}
					end:
					;
				}
				if (newLeaf != null) {
					InsertComment(ref insertionPoint, newLeaf, role, isDocumentationComment, conversionVisitor.Unit);
				}
			}
			if (!GenerateTypeSystemMode) {
				// We cannot insert newlines in the same loop as comments/preprocessor directives
				// because they are not correctly ordered in the specials bag
				insertionPoint = conversionVisitor.Unit.FirstChild;
				for (int i = 0; i < top.SpecialsBag.Specials.Count; i++) {
					var newLine = top.SpecialsBag.Specials [i] as SpecialsBag.NewLineToken;
					if (newLine != null) {
						var newLeaf = new NewLineNode(new TextLocation(newLine.Line, newLine.Col + 1));
						newLeaf.NewLineType = newLine.NewLine == SpecialsBag.NewLine.Unix ? UnicodeNewline.LF : UnicodeNewline.CRLF;
						InsertComment(ref insertionPoint, newLeaf, Roles.NewLine, false, conversionVisitor.Unit);
					}
				}
			}
		}
		public override void VisitPreProcessorDirective(PreProcessorDirective preProcessorDirective)
		{
			switch (preProcessorDirective.Type) {
				case PreProcessorDirectiveType.Region:
					NewFolding folding = new NewFolding();
					folding.DefaultClosed = true;
					folding.Name = preProcessorDirective.Argument;
					folding.StartOffset = GetOffset(preProcessorDirective.StartLocation);
					regions.Push(folding);
					break;
				case PreProcessorDirectiveType.Endregion:
					if (regions.Count > 0) {
						folding = regions.Pop();
						folding.EndOffset = GetOffset(preProcessorDirective.EndLocation);
						foldings.Add(folding);
					}
					break;
			}
		}
Exemple #11
0
		static void InsertComments (CompilerCompilationUnit top, ConversionVisitor conversionVisitor)
		{
			var leaf = GetOuterLeft (conversionVisitor.Unit);
			for (int i = 0; i < top.SpecialsBag.Specials.Count; i++) {
				var special = top.SpecialsBag.Specials [i];
				AstNode newLeaf = null;
				var comment = special as SpecialsBag.Comment;
				if (comment != null) {
					if (conversionVisitor.convertTypeSystemMode && (comment.CommentType != SpecialsBag.CommentType.Documentation))
						continue;
					var type = (CommentType)comment.CommentType;
					var start = new TextLocation (comment.Line, comment.Col);
					var end = new TextLocation (comment.EndLine, comment.EndCol);
					newLeaf = new Comment (type, start, end) {
							StartsLine = comment.StartsLine,
							Content = comment.Content
					};
				} else {
					var directive = special as SpecialsBag.PreProcessorDirective;
					if (directive != null) {
						newLeaf = new PreProcessorDirective ((ICSharpCode.NRefactory.CSharp.PreProcessorDirectiveType)((int)directive.Cmd & 0xF), new TextLocation (directive.Line, directive.Col), new TextLocation (directive.EndLine, directive.EndCol)) {
							Argument = directive.Arg,
							Take = directive.Take
						};
					}
				}
				if (newLeaf == null)
					continue;
				
				while (true) {
					var nextLeaf = NextLeaf (leaf);
					// insert comment at begin
					if (newLeaf.StartLocation < leaf.StartLocation) {
						var node = leaf.Parent ?? conversionVisitor.Unit;
						while (node.Parent != null && node.FirstChild == leaf) {
							leaf = node;
							node = node.Parent;
						}
						if (newLeaf is Comment) {
							node.InsertChildBefore (leaf, (Comment)newLeaf, AstNode.Roles.Comment);
						} else {
							node.InsertChildBefore (leaf, (PreProcessorDirective)newLeaf, AstNode.Roles.PreProcessorDirective);
						}
						leaf = newLeaf;
						break;
					}
					
					// insert comment at the end
					if (nextLeaf == null) {
						var node = leaf.Parent ?? conversionVisitor.Unit;
						if (newLeaf is Comment) {
							node.AddChild ((Comment)newLeaf, AstNode.Roles.Comment);
						} else {
							node.AddChild ((PreProcessorDirective)newLeaf, AstNode.Roles.PreProcessorDirective);
						}
						leaf = newLeaf;
						break;
					}
					
					// comment is between 2 nodes
					if (leaf.EndLocation <= newLeaf.StartLocation && newLeaf.StartLocation <= nextLeaf.StartLocation) {
						var node = leaf.Parent ?? conversionVisitor.Unit;
						if (newLeaf is Comment) {
							node.InsertChildAfter (leaf, (Comment)newLeaf, AstNode.Roles.Comment);
						} else {
							node.InsertChildAfter (leaf, (PreProcessorDirective)newLeaf, AstNode.Roles.PreProcessorDirective);
						}
						leaf = newLeaf;
						break;
					}
					leaf = nextLeaf;
				}
			}
		}
        /// <summary>
        /// 更新viewModelScript
        /// </summary>
        /// <param name="viewModel"></param>
        /// <param name="components"></param>
        public static void UpdateViewModelScript(Binding.ViewModel viewModel, List <ComponentItem> components)
        {
            var     monoScript   = MonoScript.FromScriptableObject(viewModel);
            var     classType    = monoScript.GetClass();
            var     baseType     = classType.BaseType;
            var     className    = classType.Name;
            UICoder oldViewModel = new UICoder(className);

            oldViewModel.Load(monoScript.text);
            var tree      = oldViewModel.tree;
            var classNode = tree.Descendants.OfType <TypeDeclaration>().Where(x => x.Name == className).First();

            PreProcessorDirective startRegion = classNode.Descendants.OfType <PreProcessorDirective>().Where(x => x.Type == PreProcessorDirectiveType.Region && x.Argument == "属性列表").FirstOrDefault();

            if (startRegion == null)
            {
                startRegion = new PreProcessorDirective(PreProcessorDirectiveType.Region, "属性列表");
                AstNode firstMember = classNode.GetChildByRole(Roles.TypeMemberRole);
                if (firstMember == null)
                {
                    firstMember = classNode.LastChild;
                }
                classNode.InsertChildBefore <PreProcessorDirective>(firstMember, startRegion, Roles.PreProcessorDirective);
            }

            PreProcessorDirective endRegion = classNode.Descendants.OfType <PreProcessorDirective>().Where(x => x.Type == PreProcessorDirectiveType.Endregion && x.Argument == "属性列表").FirstOrDefault();

            if (endRegion == null)
            {
                endRegion = new PreProcessorDirective(PreProcessorDirectiveType.Endregion, "属性列表");
                classNode.InsertChildAfter <PreProcessorDirective>(startRegion, endRegion, Roles.PreProcessorDirective);
            }

            #region 处理属性列表
            foreach (var component in components)
            {
                foreach (var viewItem in component.viewItems)
                {
                    //忽略已经存在于父级的属性
                    if (baseType.GetProperty(viewItem.bindingSource, BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty | BindingFlags.FlattenHierarchy) != null)
                    {
                        continue;
                    }

                    if (viewItem.bindingTargetType.type != null)
                    {
                        InsertPropertyToClassNode(viewItem.bindingTargetType.type, viewItem.bindingSource, endRegion, classNode);
                    }
                    else
                    {
                        Debug.LogError(viewItem.bindingSource + ":type NULL");
                    }
                }

                foreach (var eventItem in component.eventItems)
                {
                    //忽略已经存在于父级的属性
                    if (baseType.GetProperty(eventItem.bindingSource, BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty | BindingFlags.FlattenHierarchy) != null)
                    {
                        continue;
                    }

                    if (eventItem.type == BindingType.NoBinding)
                    {
                        continue;
                    }
                    var type = eventItem.bindingTargetType.type;

                    if (type != null)
                    {
                        Type typevalue = null;

                        if (eventItem.type == BindingType.WithTarget)
                        {
                            typevalue = typeof(Binding.PanelAction <>).MakeGenericType(component.componentType);
                        }
                        else
                        {
                            if (type.BaseType.IsGenericType)
                            {
                                var argument = type.BaseType.GetGenericArguments();
                                if (argument.Length == 1)
                                {
                                    typevalue = typeof(Binding.PanelAction <>).MakeGenericType(argument);
                                }
                                else if (argument.Length == 2)
                                {
                                    typevalue = typeof(Binding.PanelAction <,>).MakeGenericType(argument);
                                }
                                else if (argument.Length == 3)
                                {
                                    typevalue = typeof(Binding.PanelAction <, ,>).MakeGenericType(argument);
                                }
                                else if (argument.Length == 4)
                                {
                                    typevalue = typeof(Binding.PanelAction <, , ,>).MakeGenericType(argument);
                                }
                            }
                            else
                            {
                                typevalue = typeof(Binding.PanelAction);
                            }
                        }


                        InsertPropertyToClassNode(typevalue, eventItem.bindingSource, endRegion, classNode);
                    }
                    else
                    {
                        Debug.LogError(eventItem.bindingSource + ":type NULL");
                    }
                }
            }
            #endregion
            var scriptValue = oldViewModel.Compile();
            var scriptPath  = AssetDatabase.GetAssetPath(monoScript);
            System.IO.File.WriteAllText(scriptPath, scriptValue);
        }
Exemple #13
0
 public void VisitPreProcessorDirective(PreProcessorDirective preProcessorDirective)
 {
     throw new NotImplementedException();
 }
Exemple #14
0
 public StringBuilder VisitPreProcessorDirective(PreProcessorDirective preProcessorDirective, int data)
 {
     throw new NotImplementedException();
 }
Exemple #15
0
 public RedILNode VisitPreProcessorDirective(PreProcessorDirective preProcessorDirective, State data)
 {
     throw new System.NotImplementedException();
 }
 public virtual Node VisitPreProcessorDirective(PreProcessorDirective preProcessorDirective)
 {
     throw new System.NotImplementedException();
 }
Exemple #17
0
 public virtual void VisitPreProcessorDirective(PreProcessorDirective preProcessorDirective)
 {
     //throw this.CreateException(preProcessorDirective);
 }
		public void VisitPreProcessorDirective(PreProcessorDirective preProcessorDirective)
		{
			writer.StartNode(preProcessorDirective);
			writer.WritePreProcessorDirective(preProcessorDirective.Type, preProcessorDirective.Argument);
			writer.EndNode(preProcessorDirective);
		}
 public override void VisitPreProcessorDirective(PreProcessorDirective preProcessorDirective)
 {
 }
Exemple #20
0
        static void InsertComments(CompilerCompilationUnit top, ConversionVisitor conversionVisitor)
        {
            var leaf = GetOuterLeft (conversionVisitor.Unit);
            for (int i = 0; i < top.SpecialsBag.Specials.Count; i++) {
                var special = top.SpecialsBag.Specials [i];
                AstNode newLeaf = null;
                var comment = special as SpecialsBag.Comment;
                if (comment != null) {
                    // HACK: multiline documentation comment detection; better move this logic into the mcs tokenizer
                    bool isMultilineDocumentationComment = (
                        comment.CommentType == SpecialsBag.CommentType.Multi
                        && comment.Content.StartsWith("*", StringComparison.Ordinal)
                        && !comment.Content.StartsWith("**", StringComparison.Ordinal)
                    );
                    if (conversionVisitor.convertTypeSystemMode && !(comment.CommentType == SpecialsBag.CommentType.Documentation || isMultilineDocumentationComment))
                        continue;
                    var type = isMultilineDocumentationComment ? CommentType.MultiLineDocumentation : (CommentType)comment.CommentType;
                    var start = new TextLocation (comment.Line, comment.Col);
                    var end = new TextLocation (comment.EndLine, comment.EndCol);
                    newLeaf = new Comment (type, start, end) {
                        StartsLine = comment.StartsLine,
                        Content = isMultilineDocumentationComment ? comment.Content.Substring(1) : comment.Content
                    };
                } else {
                    var directive = special as SpecialsBag.PreProcessorDirective;
                    if (directive != null) {
                        newLeaf = new PreProcessorDirective ((ICSharpCode.NRefactory.CSharp.PreProcessorDirectiveType)((int)directive.Cmd & 0xF), new TextLocation (directive.Line, directive.Col), new TextLocation (directive.EndLine, directive.EndCol)) {
                            Argument = directive.Arg,
                            Take = directive.Take
                        };
                    } else {
            /*					var newLine = special as SpecialsBag.NewLineToken;
                        if (newLine != null) {
                            if (newLine.NewLine == SpecialsBag.NewLine.Unix) {
                                newLeaf = new UnixNewLine (new TextLocation (newLine.Line, newLine.Col));
                            } else {
                                newLeaf = new WindowsNewLine (new TextLocation (newLine.Line, newLine.Col));
                            }
                        }*/
                    }
                }
                if (newLeaf == null)
                    continue;

                while (true) {
                    var nextLeaf = NextLeaf (leaf);
                    // insert comment at begin
                    if (newLeaf.StartLocation < leaf.StartLocation) {
                        var node = leaf.Parent ?? conversionVisitor.Unit;
                        while (node.Parent != null && node.FirstChild == leaf) {
                            leaf = node;
                            node = node.Parent;
                        }
                        if (newLeaf is NewLineNode) {
                            node.InsertChildBefore (leaf, (NewLineNode)newLeaf, Roles.NewLine);
                        } else if (newLeaf is Comment) {
                            node.InsertChildBefore (leaf, (Comment)newLeaf, Roles.Comment);
                        } else {
                            node.InsertChildBefore (leaf, (PreProcessorDirective)newLeaf, Roles.PreProcessorDirective);
                        }
                        leaf = newLeaf;
                        break;
                    }

                    // insert comment at the end
                    if (nextLeaf == null) {
                        var node = leaf.Parent ?? conversionVisitor.Unit;
                        if (newLeaf is NewLineNode) {
                            node.AddChild ((NewLineNode)newLeaf, Roles.NewLine);
                        } else if (newLeaf is Comment) {
                            node.AddChild ((Comment)newLeaf, Roles.Comment);
                        } else {
                            node.AddChild ((PreProcessorDirective)newLeaf, Roles.PreProcessorDirective);
                        }
                        leaf = newLeaf;
                        break;
                    }

                    // comment is between 2 nodes
                    if (leaf.EndLocation <= newLeaf.StartLocation && newLeaf.StartLocation <= nextLeaf.StartLocation) {
                        var node = leaf.Parent ?? conversionVisitor.Unit;
                        if (newLeaf is NewLineNode) {
                            node.InsertChildAfter (leaf, (NewLineNode)newLeaf, Roles.NewLine);
                        } else if (newLeaf is Comment) {
                            node.InsertChildAfter (leaf, (Comment)newLeaf, Roles.Comment);
                        } else {
                            node.InsertChildAfter (leaf, (PreProcessorDirective)newLeaf, Roles.PreProcessorDirective);
                        }
                        leaf = newLeaf;
                        break;
                    }
                    leaf = nextLeaf;
                }
            }
        }
Exemple #21
0
        public void VisitPreProcessorDirective(PreProcessorDirective preProcessorDirective)
        {
            JsonObject visit = new JsonObject();
            visit.Comment = "VisitPreProcessorDirective";
            var type = preProcessorDirective.Type;
            string typeStr = "#" + type.ToString().ToLowerInvariant();
            visit.AddJsonValue("preprocessordirective-type", new JsonElement(typeStr));
            if (!string.IsNullOrEmpty(preProcessorDirective.Argument))
            {
                visit.AddJsonValue("argument", new JsonElement(preProcessorDirective.Argument));
            }
            else
            {
                visit.AddJsonNull("argument");
            }

            Push(visit);
            throw new FirstTimeUseException();
        }
            public override void VisitPreProcessorDirective(PreProcessorDirective preProcessorDirective)
            {
                Console.WriteLine("visit directiv:"+preProcessorDirective.GetText ());
                if (preProcessorDirective.Type == PreProcessorDirectiveType.If) {
                    ifStack.Push (preProcessorDirective);
                } else if (preProcessorDirective.Type == PreProcessorDirectiveType.Endif) {
                    if (ifStack.Count == 0)
                        return;
                    var ifDirective = ifStack.Pop ();
                    if (ifDirective.StartLocation < loc && loc < preProcessorDirective.EndLocation) {
                        Console.WriteLine ("if :"+ ifDirective.Argument);
                        Check (ifDirective.Argument);
                    }

                }

                base.VisitPreProcessorDirective(preProcessorDirective);
            }
 public override void VisitPreProcessorDirective
     (PreProcessorDirective preProcessorDirective) {
     Directives.Add(preProcessorDirective);
 }
		public virtual void VisitPreProcessorDirective (PreProcessorDirective preProcessorDirective)
		{
			VisitChildren (preProcessorDirective);
		}
Exemple #25
0
 void InsertComments(CompilerCompilationUnit top, ConversionVisitor conversionVisitor)
 {
     AstNode insertionPoint = conversionVisitor.Unit.FirstChild;
     for (int i = 0; i < top.SpecialsBag.Specials.Count; i++) {
         var special = top.SpecialsBag.Specials [i];
         AstNode newLeaf = null;
         Role role = null;
         bool isDocumentationComment = false;
         var comment = special as SpecialsBag.Comment;
         if (comment != null) {
             // HACK: multiline documentation comment detection; better move this logic into the mcs tokenizer
             bool isMultilineDocumentationComment = (
                 comment.CommentType == SpecialsBag.CommentType.Multi
                 && comment.Content.StartsWith("*", StringComparison.Ordinal)
                 && !comment.Content.StartsWith("**", StringComparison.Ordinal)
             );
             isDocumentationComment = comment.CommentType == SpecialsBag.CommentType.Documentation || isMultilineDocumentationComment;
             if (conversionVisitor.convertTypeSystemMode && !isDocumentationComment)
                 continue;
             var type = isMultilineDocumentationComment ? CommentType.MultiLineDocumentation : (CommentType)comment.CommentType;
             var start = new TextLocation (comment.Line, comment.Col);
             var end = new TextLocation (comment.EndLine, comment.EndCol);
             newLeaf = new Comment (type, start, end) {
                 StartsLine = comment.StartsLine,
                 Content = isMultilineDocumentationComment ? comment.Content.Substring(1) : comment.Content
             };
             role = Roles.Comment;
         } else if (!GenerateTypeSystemMode) {
             var pragmaDirective = special as SpecialsBag.PragmaPreProcessorDirective;
             if (pragmaDirective != null) {
                 var pragma = new PragmaWarningPreprocssorDirective(new TextLocation(pragmaDirective.Line, pragmaDirective.Col), new TextLocation(pragmaDirective.EndLine, pragmaDirective.EndCol));
                 pragma.Disable = pragmaDirective.Disalbe;
                 pragma.AddWarnings(pragmaDirective.Codes);
                 newLeaf = pragma;
                 role = Roles.PreProcessorDirective;
             } else {
                 var directive = special as SpecialsBag.PreProcessorDirective;
                 if (directive != null) {
                     newLeaf = new PreProcessorDirective ((ICSharpCode.NRefactory.CSharp.PreProcessorDirectiveType)((int)directive.Cmd & 0xF), new TextLocation (directive.Line, directive.Col), new TextLocation (directive.EndLine, directive.EndCol)) {
                         Argument = directive.Arg,
                         Take = directive.Take
                     };
                     role = Roles.PreProcessorDirective;
                 }
             }
         }
         if (newLeaf != null) {
             InsertComment(ref insertionPoint, newLeaf, role, isDocumentationComment, conversionVisitor.Unit);
         }
     }
     if (!GenerateTypeSystemMode) {
         // We cannot insert newlines in the same loop as comments/preprocessor directives
         // because they are not correctly ordered in the specials bag
         insertionPoint = conversionVisitor.Unit.FirstChild;
         for (int i = 0; i < top.SpecialsBag.Specials.Count; i++) {
             var newLine = top.SpecialsBag.Specials[i] as SpecialsBag.NewLineToken;
             if (newLine != null) {
                 AstNode newLeaf;
                 if (newLine.NewLine == SpecialsBag.NewLine.Unix) {
                     newLeaf = new UnixNewLine (new TextLocation (newLine.Line, newLine.Col + 1));
                 } else {
                     newLeaf = new WindowsNewLine (new TextLocation (newLine.Line, newLine.Col + 1));
                 }
                 InsertComment(ref insertionPoint, newLeaf, Roles.NewLine, false, conversionVisitor.Unit);
             }
         }
     }
 }
			public override void VisitPreProcessorDirective(PreProcessorDirective preProcessorDirective)
			{
				if (preProcessorDirective.Type == PreProcessorDirectiveType.If) {
					ifStack.Push(preProcessorDirective);
				} else if (preProcessorDirective.Type == PreProcessorDirectiveType.Endif) {
					if (ifStack.Count == 0)
						return;
					var ifDirective = ifStack.Pop();
					if (ifDirective.StartLocation < loc && loc < preProcessorDirective.EndLocation) {
						Check(ifDirective.Argument);
					}

				}

				base.VisitPreProcessorDirective(preProcessorDirective);
			}
 public JsNode VisitPreProcessorDirective(PreProcessorDirective node)
 {
     throw new NotImplementedException();
 }