internal void RecordWarning(Bookmark position, Bookmark order, string message, params object[] args) { // Quit warnings disabled at this point if (!position.warnings) return; // Create the warning record var warning = new Warning(); warning.Bookmark = position; warning.Order = order; warning.Message = string.Format("warning: {0}", string.Format(message, args)); warning.OriginalOrder = Warnings.Count; // Add to list Warnings.Add(warning); }
void DefineLocalSymbol(string Name, Bookmark bmk) { // This check is for parameters that are allowed to hide symbols from the outer // real scope if (currentPseudoScope.Node != null && currentPseudoScope.Node.Scope == null) { var scope = currentPseudoScope.OuterScope; while (scope != null) { var symbol = scope.FindLocalSymbol(Name); if (symbol != null) { scope.Compiler.RecordWarning(bmk, "symbol `{0}` hides previous declaration", Name); foreach (var decl in symbol.Declarations) { scope.Compiler.RecordWarning(decl, bmk, "see previous declaration of `{0}`", Name); } } // Have we reached the real scope? if (scope.Node == null || scope.Node.Scope != null) break; // Walk up scope = scope.OuterScope; } } // First check we're not hiding an outer declared symbol currentScope.Symbols.DefineSymbol(Name, bmk); currentPseudoScope.Symbols.DefineSymbol(Name, bmk); }
// Constructor internal CompileError(string message, Tokenizer t) { m_strMessage = message; m_Bookmark = t.GetBookmark(); }
internal void RecordWarning(Bookmark position, string message, params object[] args) { RecordWarning(position, position, message, args); }
// Check for cases where a semicolon is optional // - end of file // - immediately before a brace // - before a line break public bool IsAutoSemicolon() { if (p.eof || token == Token.closeBrace || m_bPreceededByLineBreak) { if (m_prevToken!=Token.closeBrace) { if (m_bWarnings) { var b = new Bookmark(p, m_prevTokenEnd, token, m_bWarnings); b.file = this.p; b.position = this.m_prevTokenEnd; b.token = this.token; Compiler.RecordWarning(b, "missing semicolon"); } } return true; } return false; }
// Rewind the tokenizer to a previously marked position public void Rewind(Bookmark bmk) { System.Diagnostics.Debug.Assert(bmk.file == this.p); p.position = bmk.position; Next(); }
public void ProcessAccessibilitySpecs(ast.ExprNodeIdentifier target, string identifier, Bookmark bmk) { // Check accessibility specs for (int i = m_AccessibilitySpecs.Count - 1; i >= 0; i--) { var spec = m_AccessibilitySpecs[i]; if (spec.IsWildcard() && spec.DoesMatch(target, identifier)) { var symbol=Members.DefineSymbol(identifier, bmk); if (symbol.Accessibility == Accessibility.Default) symbol.Accessibility = spec.GetAccessibility(); return; } } // Pass to outer scope if (OuterScope!=null) OuterScope.ProcessAccessibilitySpecs(target, identifier, bmk); }
public void AddAccessibilitySpec(Bookmark bmk, AccessibilitySpec spec) { // Just store wildcards for now if (spec.IsWildcard()) { m_AccessibilitySpecs.Add(spec); return; } Symbol s; if (spec.IsMemberSpec()) { s = Members.DefineSymbol(spec.GetExplicitName(), bmk); } else { s = Symbols.DefineSymbol(spec.GetExplicitName(), bmk); } // Mark obfuscation for this symbol s.Accessibility = spec.GetAccessibility(); }