internal void SetParentSymbolTable(ISymbolTable symbolTable) { Debug.Assert(_parentSymbolTable == null); Debug.Assert(symbolTable != null); _parentSymbolTable = symbolTable; }
private void HandleFragmentConflict(ISymbolTable context, IProblemPipe problemPipe) { if (ProblemMetadata != null) problemPipe.AddProblem (_problemMetadata); context.MakeUnsafe (_symbol); }
public virtual void HandleViolation(ISymbolTable context, IProblemPipe problemPipe) { if (_problemMetadata != null) { problemPipe.AddProblem (_problemMetadata); } }
public SymbolScope(ISymbolTable parentSymbolTable) { Debug.Assert(parentSymbolTable != null); _parentSymbolTable = parentSymbolTable; _locals = new Collection<LocalSymbol>(); _localTable = new Dictionary<string, LocalSymbol>(); }
public TypeSymbol ResolveIntrinsicType(PredefinedTypeSyntax type, ISymbolTable symbolTable, Symbol contextSymbol) { switch (type.Kind) { case SyntaxKind.PredefinedScalarType: return ResolveIntrinsicScalarType((ScalarTypeSyntax) type); case SyntaxKind.PredefinedVectorType: return ResolveIntrinsicVectorType((VectorTypeSyntax)type); case SyntaxKind.PredefinedGenericVectorType: return ResolveIntrinsicGenericVectorType((GenericVectorTypeSyntax)type); case SyntaxKind.PredefinedMatrixType: return ResolveIntrinsicMatrixType((MatrixTypeSyntax)type); case SyntaxKind.PredefinedGenericMatrixType: return ResolveIntrinsicGenericMatrixType((GenericMatrixTypeSyntax)type); case SyntaxKind.PredefinedObjectType: return ResolveIntrinsicObjectType((PredefinedObjectTypeSyntax) type, symbolTable, contextSymbol); default: throw new ArgumentOutOfRangeException(nameof(type), "Unmapped intrinsic type"); } }
public ClassDecl(Cursor c, ISymbolTable table) : base(c, table) { Debug.Assert(CursorKinds.IsClassStructEtc(c.Kind)); _templateKind = Symbols.TemplateKind.NonTemplate; if (c.Kind == CursorKind.ClassTemplate) _templateKind = Symbols.TemplateKind.Template; else if (c.Kind == CursorKind.ClassTemplatePartialSpecialization) _templateKind = Symbols.TemplateKind.TemplatePartialSpecialization; else if (c.TemplateSpecialisedCursorTemplate != null) _templateKind = Symbols.TemplateKind.TemplateSpecialization; if(c.SemanticParentCurosr.Kind == CursorKind.Namespace) { _parent = table.FindNamespaceDeclaration(c.SemanticParentCurosr.Usr); Debug.Assert(_parent != null); } else if (c.SemanticParentCurosr.Kind == CursorKind.TranslationUnit || c.SemanticParentCurosr.Kind == CursorKind.UnexposedDecl) { _parent = null; } else if(CursorKinds.IsClassStructEtc(c.SemanticParentCurosr.Kind)) { _parent = table.FindClassDeclaration(c.SemanticParentCurosr.Usr); Debug.Assert(_parent != null); } else { Debug.Assert(false); } }
public Reference(Cursor c, IDeclaration decl, ISymbolTable table) { _cursor = c; _decl = decl; _table = table; _location = new CodeLocation(c.Extent.Start); //todo - replace for doc tracking }
public VariableDecl(Cursor c, ISymbolTable table) : base(c, table) { // Debug.Assert(c.Kind == CursorKind.VarDecl); if (c.SemanticParentCurosr.Kind == CursorKind.Namespace) { _parent = table.FindNamespaceDeclaration(c.SemanticParentCurosr.Usr); Debug.Assert(_parent != null); } else if (CursorKinds.IsClassStructEtc(c.SemanticParentCurosr.Kind)) { _parent = table.FindClassDeclaration(c.SemanticParentCurosr.Usr); Debug.Assert(_parent != null); } else if(CursorKinds.IsFunctionEtc(c.SemanticParentCurosr.Kind)) { _parent = table.FindFunctionDeclaration(c.SemanticParentCurosr.Usr); } else if (c.SemanticParentCurosr.Kind == CursorKind.TranslationUnit || c.SemanticParentCurosr.Kind == CursorKind.UnexposedDecl) { _parent = null; } else { Debug.Assert(false); } }
public MethodDecl(Cursor declaration, ISymbolTable table) : base(declaration, table) { Debug.Assert(CursorKinds.IsClassStructEtc(declaration.SemanticParentCurosr.Kind)); _class = table.FindClassDeclaration(declaration.SemanticParentCurosr.Usr); Debug.Assert(_class != null); }
public FieldDecl(Cursor c, ISymbolTable table) : base(c, table) { Debug.Assert(c.Kind == CursorKind.FieldDecl); _class = table.FindClassDeclaration(c.SemanticParentCurosr.Usr); Debug.Assert(_class != null); }
public void ClearTables() { this.myPrefixesSymbolTable = null; this.myUriIdentifiersSymbolTable = null; this.myPrefixes.Clear(); this.myUriIdentifiers.Clear(); }
private static void DoTest(List<Item> testData, ISymbolTable symbolTable) { Stack<Item> inserted = new Stack<Item>(testData.Count); Random r = new Random(DateTime.Now.Millisecond); DateTime start = DateTime.Now; foreach (Item item in testData) { symbolTable.Insert(item); inserted.Push(item); } foreach (Item item in inserted.Reverse()) { Item found = symbolTable.Search(item.Key); if (!found.Value.Equals(item.Value)) { throw new Exception(); } } for (int i = 0; i < testData.Count; i++) { int randomIndex = r.Next(testData.Count); Item searched = testData[randomIndex]; Item found = symbolTable.Search(searched.Key); if (!found.Value.Equals(searched.Value)) { throw new Exception(); } } DateTime finish = DateTime.Now; TimeSpan span = finish - start; Console.WriteLine("Timing for {0}: {1} ms", symbolTable.GetType(), span.TotalMilliseconds); }
public ConstructorDecl(Cursor c, ISymbolTable table) : base(c, table) { Debug.Assert(c.Kind == CursorKind.Constructor); _class = table.FindClassDeclaration(c.SemanticParentCurosr.Usr); //could be classtemplate //Debug.Assert(_class != null); }
public AnonymousMethodSymbol(CodeMemberSymbol containingMember, ISymbolTable stackContext, TypeSymbol returnType, bool isStatic) : base(SymbolType.AnonymousMethod, /* name */ String.Empty, (TypeSymbol)containingMember.Parent, returnType) { SetVisibility(isStatic ? MemberVisibility.Public | MemberVisibility.Static : MemberVisibility.Public); _containingMember = containingMember; _stackContext = stackContext; _containingMember.AddAnonymousMethod(this); }
public virtual void Build() { if (_result == null) { _result = new SymbolTable (_blacklistManager); AnalyzeParameters(); } }
private void MergeBlockAssignments(ISymbolTable context, ISymbolTable adjustedContext, BlockAssignment[] blockAssignments) { foreach (var blockAssignment in blockAssignments) { Fragment propagatedFragmentType = context.GetFragmentType (blockAssignment.SourceSymbol); adjustedContext.MakeSafe (blockAssignment.TargetSymbol, propagatedFragmentType); } }
public FunctionDeclBase(Cursor declaration, ISymbolTable table) : base(declaration, table) { _args = new List<MethodArgumentSymbol>(); foreach (Cursor arg in declaration.ArgumentCursors) { _args.Add(new MethodArgumentSymbol(arg, table)); } }
public BasicBlock( int id, IPreCondition[] preConditions, ISymbolTable postConditionSymbolTable, int[] successorKeys, BlockAssignment[] blockAssignments) { _preConditions = ArgumentUtility.CheckNotNull ("preConditions", preConditions); _postConditionSymbolTable = ArgumentUtility.CheckNotNull ("postConditionSymbolTable", postConditionSymbolTable); _successorKeys = ArgumentUtility.CheckNotNull ("successorKeys", successorKeys); _id = id; _blockAssignments = blockAssignments; }
public void Analyze(MethodCall methodCall, ISymbolTable context, List<IPreCondition> preConditions) { Method calleeMethod = IntrospectionUtility.ExtractMethod (methodCall); ICustomInference matchingRule = MatchingAnalyzeRule (calleeMethod); if (matchingRule != null) { matchingRule.Analyze (methodCall, context, preConditions); } }
public EnumConstantDecl(Cursor c, ISymbolTable table) : base(c, table) { Debug.Assert(c.Kind == CursorKind.EnumConstantDecl); Debug.Assert(c.SemanticParentCurosr != null); Debug.Assert(c.SemanticParentCurosr.Kind == CursorKind.EnumDecl); _parent = table.FindEnumDeclaration(c.SemanticParentCurosr.Usr); Debug.Assert(_parent != null); }
public Fragment InferFragmentType(MethodCall methodCall, ISymbolTable context) { Fragment returnFragment = Fragment.CreateEmpty(); Method calleeMethod = IntrospectionUtility.ExtractMethod (methodCall); if(_coveredMethods.Contains(calleeMethod.FullName)) { returnFragment = ParameterFragmentUtility.ParameterFragmentIntersection (methodCall, context); } return returnFragment; }
private void CheckPreConditions(IPreCondition[] preconditions, ISymbolTable context) { foreach (IPreCondition preCondition in preconditions) { if(preCondition.IsViolated(context)) { preCondition.HandleViolation (context, _problemPipe); } } }
private SymbolImplementation BuildImplementation(ISymbolTable symbolTable, CodeMemberSymbol symbolContext, BlockStatementNode implementationNode, bool addAllParameters) { _rootScope = new SymbolScope(symbolTable); _currentScope = _rootScope; List<Statement> statements = new List<Statement>(); StatementBuilder statementBuilder = new StatementBuilder(this, symbolContext, _errorHandler, _options); if (symbolContext.Parameters != null) { int parameterCount = symbolContext.Parameters.Count; if (addAllParameters == false) { // For property getters (including indexers), we don't add the last parameter, // which happens to be the "value" parameter, which only makes sense // for the setter. parameterCount--; } for (int paramIndex = 0; paramIndex < parameterCount; paramIndex++) { _currentScope.AddSymbol(symbolContext.Parameters[paramIndex]); } } if ((symbolContext.Type == SymbolType.Constructor) && ((((ConstructorSymbol)symbolContext).Visibility & MemberVisibility.Static) == 0)) { Debug.Assert(symbolContext.Parent is ClassSymbol); if (((ClassSymbol)symbolContext.Parent).BaseClass != null) { BaseInitializerExpression baseExpr = new BaseInitializerExpression(); ConstructorDeclarationNode ctorNode = (ConstructorDeclarationNode)symbolContext.ParseContext; if (ctorNode.BaseArguments != null) { ExpressionBuilder expressionBuilder = new ExpressionBuilder(this, symbolContext, _errorHandler, _options); Debug.Assert(ctorNode.BaseArguments is ExpressionListNode); ICollection<Expression> args = expressionBuilder.BuildExpressionList((ExpressionListNode)ctorNode.BaseArguments); foreach (Expression paramExpr in args) { baseExpr.AddParameterValue(paramExpr); } } statements.Add(new ExpressionStatement(baseExpr)); } } foreach (StatementNode statementNode in implementationNode.Statements) { Statement statement = statementBuilder.BuildStatement(statementNode); if (statement != null) { statements.Add(statement); } } return new SymbolImplementation(statements, _rootScope); }
private static void PrintSymTab(ISymbolTable stack) { foreach (ISymbolTableEntry entry in stack.SortedEntries) { StringBuilder nums = new StringBuilder(); foreach (int line in entry.LineNumbers) nums.Append(string.Format("{0:D3} ", line)); Console.WriteLine(" {0}" + Space + String.Concat(Enumerable.Repeat(" ", " Identifier".Length - entry.Name.Length)) + "{1}", entry.Name, nums.ToString()); } }
public NamespaceDecl(Cursor c, ISymbolTable table) : base(c, table) { Debug.Assert(c.Kind == CursorKind.Namespace); if(c.SemanticParentCurosr.Kind == CursorKind.Namespace) { _parent = table.FindNamespaceDeclaration(c.SemanticParentCurosr.Usr); Debug.Assert(_parent != null); } }
public static Fragment ParameterFragmentIntersection(MethodCall methodCall, ISymbolTable context) { Fragment current = context.InferFragmentType (methodCall.Operands[0]); Fragment intersection = current; for (int i = 1; i < methodCall.Operands.Count; i++) { Fragment next = context.InferFragmentType (methodCall.Operands[i]); intersection = FragmentIntersection (current, next); } return intersection; }
public Fragment InferFragmentType(MethodCall methodCall, ISymbolTable context) { Fragment fragmentType = Fragment.CreateEmpty(); Method calleeMethod = IntrospectionUtility.ExtractMethod (methodCall); ICustomInference matchingRule = MatchingInferRule (calleeMethod); if (matchingRule != null) { fragmentType = matchingRule.InferFragmentType (methodCall, context); } return fragmentType; }
// a symbol-table client that finds the number of occurrences of each string // (having at least as many characters as a given threshold length) // in a sequence of strings from standard input, // then iterates through the keys to find the one that occurs the most frequently static void FrequencyCounter(ISymbolTable <string, int> st, IEnumerable <string> strings) { foreach (string s in strings) { if (st.Contains(s)) { st.Put(s, 1 + st.Get(s)); } else { st.Put(s, 1); } } }
/// <nodoc /> public NamespaceScope(List <SymbolAtom> fullName, ISymbolTable symbolTable, ISourceFile sourceFile, PathTable pathTable, StringTable stringTable, NamespaceScope parent = null) { Contract.Requires(symbolTable != null); Contract.Requires(sourceFile != null); Contract.Requires(stringTable != null); m_sourceFile = sourceFile; m_stringTable = stringTable; m_parent = parent; m_pathTable = pathTable; FullName = fullName; PopulateFromSymbolTable(symbolTable); }
public virtual void Process(ICode code, ISymbolTable symTab) { Stopwatch.Start(); Stopwatch.Stop(); int executionCount = 0; int runtimeError = 0; OnMessageEmitted(this, MessageType.InterpreterSummary, new Dictionary<string, object>() { {"ExecutionCount", executionCount}, {"RuntimeError", runtimeError}, {"Elapsed", Stopwatch.Elapsed} }); }
// Gets a symbol table that contains all common attributes, that is, all attributes that apply to any tag. // Used in attribute code completion and resolution - if the tag is unknown, show common attributes, // rather than specific attributes // The standard HtmlDeclaredElementsProvider treats attributes as specific (tag.OwnAttributes), shared // between multiple tags (tag.InheritedAttributes - I18N, core, asp, events, etc.) and common (additional // - all groups of inherited/shared/reused attributes). The only significant difference betwen OwnAttributes // and InheritedAttributes is the sorting when showing descriptions (important attributes, important common // attributes, own attributes, inherited attributes - important comes from the XML file with the descriptions). // This method returns all common and inherited attributes public ISymbolTable GetCommonAttributesSymbolTable() { lock (lockObject) { if (commonAttributesSymbolTable == null) { var psiServices = solution.GetComponent <IPsiServices>(); var directives = cache.Directives; var attributeDeclaredElements = from ai in GetCommonAttributeInfosLocked(directives) select ai.AttributeDeclaredElement; commonAttributesSymbolTable = new DeclaredElementsSymbolTable <IHtmlAttributeDeclaredElement>(psiServices, attributeDeclaredElements); } return(commonAttributesSymbolTable); } }
public override void HandleViolation(ISymbolTable context, IProblemPipe problemPipe) { if (!IsViolated (context)) return; bool symbolIsUndefined = context.Contains (_symbol) && context.GetFragmentType (_symbol).Undefined; if (symbolIsUndefined) { SetSymbolFragmentType(context); } else { HandleFragmentConflict (context, problemPipe); } }
private void CheckAssignment(AssignmentStatement assignmentStatement, string targetName, HandleContext context) { ISymbolTable symbolTable = context.SymbolTable; Fragment targetFragmentType = symbolTable.GetFragmentType(targetName); Fragment sourceFragmentType = symbolTable.InferFragmentType(assignmentStatement.Source); if (targetFragmentType != sourceFragmentType) { symbolTable.MakeUnsafe(targetName); } else { SetPreConditionForIndexerObject(assignmentStatement, targetName, sourceFragmentType, context); } }
public PrgState Execute(PrgState p) { ISymbolTable <string, int> dict = p.Dict; int val = this.expr.Eval(dict); if (val != 0) { p.Stack.Push(thenstmt); } else { p.Stack.Push(elsestmt); } return(p); }
public void SetUp() { MockRepository mocks = new MockRepository(); IBlacklistManager blacklistManager = mocks.Stub <IBlacklistManager>(); BlockParserContext blockParserContext = new BlockParserContext( new ProblemPipeStub(), Fragment.CreateNamed("returnFragmentType"), new List <ReturnCondition>(), blacklistManager, delegate { }); _handler = new StringBuilderConstructStatementHandler(blockParserContext); _symbolTable = new SymbolTable(blacklistManager); _stringBuilderFragmentTypesDefined = new Dictionary <string, bool>(); }
public void Analyze(MethodCall methodCall, ISymbolTable symbolTable, List <IPreCondition> preConditions) { _symbolTable = symbolTable; _preConditions = preConditions; Method calleeMethod = IntrospectionUtility.ExtractMethod(methodCall); if (_customInferenceController.Analyzes(calleeMethod)) { //_customInferenceController.InferFragmentType(methodCall, symbolTable); _customInferenceController.Analyze(methodCall, symbolTable, preConditions); } else { AnalyzeOrdinaryMethodCall(methodCall); } }
public ContextFile(ContextProject projectContext, ZFileModel fileModel) { ProjectContext = projectContext; FileModel = fileModel; //CompiledContext = new CompiledContext(); UseContext = new ContextUse(); //this.ImportCollectionContext = new ImportCollectionContext(); //this.ImportCollectionContext.SetFileContext(this); this.UseContext.SetFileContext(this); //PreDimCollectionContext = new PreDimCollectionContext(); ImportContext = new ContextImport(); ClassContext = new ContextClass(this); SymbolTable = UseContext.SymbolTable; }
public override ResolveResultWithInfo ResolveWithoutCache() { ISymbolTable table = GetReferenceSymbolTable(true); IList <DeclaredElementInstance> elements = new List <DeclaredElementInstance>(); { IList <ISymbolInfo> infos = table.GetSymbolInfos(GetName()); foreach (ISymbolInfo info in infos) { var element = new DeclaredElementInstance(info.GetDeclaredElement(), EmptySubstitution.INSTANCE); elements.Add(element); } } return(new ResolveResultWithInfo(ResolveResultFactory.CreateResolveResultFinaly(elements), ResolveErrorType.OK)); }
public bool IsDefinedInParent(String name) { ISymbolTable scopeRef = parent; while (scopeRef != null) { if (scopeRef.IsDefined(name)) { return(true); } scopeRef = scopeRef.Parent; } return(false); }
public ISymbolTable CreateUriIdentifiersSymbolTable() { this.CollectUriIdentifiers(); if (this.GetSourceFile() != null) { var elements = this.myUriIdentifiers.Values.SelectMany(x => x); this.myUriIdentifiersSymbolTable = ResolveUtil.CreateSymbolTable(elements, 0); } else { this.myUriIdentifiersSymbolTable = null; } return(this.myUriIdentifiersSymbolTable); }
public PrgState execute(PrgState p) { ISymbolTable <string, int> t = p.getSymbolTable(); int resExpr = this.expr.evaluate(t); if (t.contains(var)) { t.setValue(var, resExpr); } else { t.add(var, resExpr); } return(p); }
public ISymbolTable CreatePrefixesSymbolTable() { this.CollectPrefixes(); if (this.GetSourceFile() != null) { Dictionary<string, IDeclaredElement>.ValueCollection elements = this.myPrefixes.Values; this.myPrefixesSymbolTable = ResolveUtil.CreateSymbolTable(elements, 0); } else { this.myPrefixesSymbolTable = null; } return this.myPrefixesSymbolTable; }
public Fragment InferFragmentType(MethodCall methodCall, ISymbolTable context) { Fragment returnFragment = Fragment.CreateEmpty(); Method method = IntrospectionUtility.ExtractMethod(methodCall); if (Infers(method) && methodCall.Callee is MemberBinding) { MemberBinding memberBinding = (MemberBinding)methodCall.Callee; string variableName; if (IntrospectionUtility.IsVariable(memberBinding.TargetObject, out variableName)) { returnFragment = context.GetFragmentType(variableName); } } return(returnFragment); }
public ISymbolTable CreatePrefixesSymbolTable() { this.CollectPrefixes(); if (this.GetSourceFile() != null) { Dictionary <string, IDeclaredElement> .ValueCollection elements = this.myPrefixes.Values; this.myPrefixesSymbolTable = ResolveUtil.CreateSymbolTable(elements, 0); } else { this.myPrefixesSymbolTable = null; } return(this.myPrefixesSymbolTable); }
public override ISymbolTable GetReferenceSymbolTable(bool useReferenceName) { string name = GetName(); IProject project = myOwner.GetProject(); ISymbolTable symbolTable = EmptySymbolTable.INSTANCE; foreach (JetTuple <string, string, MvcUtil.DeterminationKind, ICollection <IClass> > tuple in names) { ISymbolTable symbolTable2; if (tuple.C == MvcUtil.DeterminationKind.ImplicitByContainingMember) { symbolTable2 = (from @class in tuple.D where @class != null && @class.IsValid() select GetReferenceSymbolTable(@class, useReferenceName ? name : null, mvcKind, version, tuple.A)).Merge(); } else { symbolTable2 = GetReferenceSymbolTable(psiServices, tuple.A, tuple.B, useReferenceName ? name : null, mvcKind, project, version); } if (useReferenceName && symbolTable2.GetAllSymbolInfos().IsEmpty() && name.IndexOfAny(FileSystemDefinition.InvalidPathChars) == -1) { var symbolTable3 = new SymbolTable(psiServices); try { bool hasExtension = Path.HasExtension(name); foreach (string location in mvcCache.GetLocations(project, MvcUtil.GetViewLocationType(mvcKind, tuple.A))) { string path = string.Format(location, name, tuple.B, tuple.A); if (hasExtension) { path = Path.ChangeExtension(path, null); } symbolTable3.AddSymbol(new PathDeclaredElement(psiServices, FileSystemPath.Parse(path))); } } catch (InvalidPathException) { } symbolTable2 = symbolTable3; } symbolTable = symbolTable.Merge(symbolTable2); } return(symbolTable.Distinct()); }
protected override bool HasNext() { while (!_hasNextCalled) { base.HasNext(); if (_valueType != IonType.None && !CurrentIsNull && GetContainerType() == IonType.Datagram) { switch (_valueType) { case IonType.Struct: if (_annotations.Count > 0 && _annotations[0].Text == SystemSymbols.IonSymbolTable) { _currentSymtab = ReaderLocalTable.ImportReaderTable(this, _catalog, true); _hasNextCalled = false; } break; case IonType.Symbol: if (_annotations.Count == 0) { // $ion_1_0 is read as an IVM only if it is not annotated var version = SymbolValue().Text; if (version is null || !IvmRegex.IsMatch(version)) { break; } //new Ivm found, reset all symbol tables if (SystemSymbols.Ion10 != version) { throw new UnsupportedIonVersionException(version); } MoveNext(); _currentSymtab = _systemSymbols; _hasNextCalled = false; } break; } } } return(!_eof); }
ISymbolTable <String, Double> GetGrades(string st) { ISymbolTable <String, Double> grades = Factory <String, Double>(st); grades.Put("A", 4.00); grades.Put("B", 3.00); grades.Put("C", 2.00); grades.Put("D", 1.00); grades.Put("F", 0.00); grades.Put("A+", 4.33); grades.Put("B+", 3.33); grades.Put("C+", 2.33); grades.Put("A-", 3.67); grades.Put("B-", 2.67); return(grades); }
private static void RoundTrip_AssertBinary(IIonValue datagram, ISymbolTable readerTable) { using (var ms = new MemoryStream()) { using (var writer = IonBinaryWriterBuilder.Build(ms, readerTable.GetImportedTables())) { datagram.WriteTo(writer); writer.Finish(); var bin = ms.ToArray(); var catalog = Symbols.GetReaderCatalog(readerTable); var datagram2 = IonLoader.WithReaderOptions(new ReaderOptions { Catalog = catalog, Format = ReaderFormat.Binary }).Load(bin); AssertDatagramEquivalent(datagram, datagram2); } } }
public PrgState execute(PrgState p) { IExeStack <Statement> exe = p.ExeStack; ISymbolTable <string, int> t = p.getSymbolTable(); int resExpr = this.expr.evaluate(t); if (resExpr != 0) { exe.push(this.first); } else { exe.push(this.second); } return(p); }
/// <summary> /// Returns a catalog that contains all shared symbol tables that the reader has read so far. /// </summary> /// <param name="readerTable">The reader's local symbol table. Typically obtained by calling <see cref="IIonReader.GetSymbolTable"/>.</param> /// <remarks> /// Normally when a text or binary Ion data with shared symbol tables is read, the materialized object (such as /// a .Net POCO object or an <see cref="IonDotnet.Tree.IonDatagram"/> does not have the reference to these tables. /// As such, systems that want to reuse those shared tables should extract them after reading through all the values. /// This method provides a shortcut to do get a catalog that contains those tables. /// </remarks> public static ICatalog GetReaderCatalog(ISymbolTable readerTable) { var catalog = new SimpleCatalog(); foreach (var importedTable in readerTable.GetImportedTables()) { Debug.Assert(importedTable.IsShared); if (importedTable.IsSystem || importedTable.IsSubstitute) { continue; } catalog.PutTable(importedTable); } return(catalog); }
public override void HandleViolation(ISymbolTable context, IProblemPipe problemPipe) { if (!IsViolated(context)) { return; } bool symbolIsUndefined = context.Contains(_symbol) && context.GetFragmentType(_symbol).Undefined; if (symbolIsUndefined) { SetSymbolFragmentType(context); } else { HandleFragmentConflict(context, problemPipe); } }
internal static ISymbolTable NewSharedSymbolTable(string name, int version, ISymbolTable priorSymtab, IEnumerable <string> symbols) { if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentNullException(nameof(name), "Must not be empty"); } if (symbols == null) { throw new ArgumentNullException(nameof(symbols), "Must not be null"); } if (version < 1) { throw new ArgumentException("Must be at least 1", nameof(version)); } var(symbolList, symbolMap) = PrepSymbolListAndMap(priorSymtab, symbols); return(new SharedSymbolTable(name, version, symbolList, symbolMap)); }
protected SystemTreeReader(IIonValue value) { _systemSymbols = SharedSymbolTable.GetSystem(1); _current = null; _eof = false; _top = 0; if (value.Type() == IonType.Datagram) { _parent = value; _next = null; _iter = value.GetEnumerator(); } else { _parent = null; _next = value; } }
protected SystemTreeReader(IIonValue value) { this.systemSymbols = SharedSymbolTable.GetSystem(1); this.current = null; this.eof = false; this.top = 0; if (value.Type() == IonType.Datagram) { this.parent = value; this.next = null; this.iter = value.GetEnumerator(); } else { this.parent = null; this.next = value; } }
public MethodDefinitionStatement(ISymbolTable parentScope, AccessLevel accessLevel, String fullname) : base(NodeType.MethodDefinition) { statements = new StatementCollection(this); nameScope = new SymbolTable(ScopeType.Method, parentScope); this.fullname = fullname; this.accessLevel = accessLevel; String boundToName; ASTUtils.CollectMethodInformation(fullname, out boundToName, out name, out isStatic); if (boundToName != null) { boundTo = new TypeReference(":" + boundToName); } isConstructor = "initialize".Equals(fullname); }
// Returns a symbol table of all tags known to the provider. Only one provider should own // a particular tag, so providers other than the standard HtmlDeclaredElementProvider should // return non-standard HTML tags. // Used all over the place, e.g. resolution + code completion public ISymbolTable GetAllTagsSymbolTable() { lock (lockObject) { if (allTagsSymbolTable == null) { var psiServices = solution.GetComponent <IPsiServices>(); var tagDeclaredElements = from d in cache.Directives where d.IsElement && !IsOverridingTag(d.Name) from n in GetPrefixedNames(d.Name) select GetOrCreateTagLocked(n); allTagsSymbolTable = new DeclaredElementsSymbolTable <IHtmlTagDeclaredElement>(psiServices, tagDeclaredElements); } return(allTagsSymbolTable); } }
public void Analyze(MethodCall methodCall, ISymbolTable context, List <IPreCondition> preConditions) { Method method = IntrospectionUtility.ExtractMethod(methodCall); if (Analyzes(method) && methodCall.Callee is MemberBinding) { MemberBinding memberBinding = (MemberBinding)methodCall.Callee; if (IsFragmentParameterInferenceMethod(method)) { string variableName; if (IntrospectionUtility.IsVariable(memberBinding.TargetObject, out variableName)) { Fragment parameterFragment = ParameterFragmentUtility.ParameterFragmentIntersection(methodCall, context); Fragment targetObjectFragment = context.GetFragmentType(variableName); if (targetObjectFragment == Fragment.CreateLiteral() || targetObjectFragment.Undefined) { context.MakeSafe(variableName, parameterFragment); } else { if (targetObjectFragment == Fragment.CreateEmpty() && parameterFragment != Fragment.CreateLiteral()) // && parameterFragment != Fragment.CreateEmpty() { ProblemMetadata problemMetadata = new ProblemMetadata(methodCall.UniqueKey, methodCall.SourceContext, parameterFragment, targetObjectFragment); IPreCondition precondition = new CustomInferencePreCondition(variableName, parameterFragment, problemMetadata); preConditions.Add(precondition); } else if (!FragmentUtility.FragmentTypesAssignable(parameterFragment, targetObjectFragment)) { context.MakeUnsafe(variableName); } } } } else if (!IsSafeMethod(method)) { string variableName; if (IntrospectionUtility.IsVariable(memberBinding.TargetObject, out variableName)) { context.MakeUnsafe(variableName); } } } }
public override bool VisitAssignmentExpression(AssignmentExpression assignExp) { if (assignExp.Target.NodeType == NodeType.VariableRefExpression) { // Convert to declaration if not found on the scope VariableReferenceExpression varRef = (VariableReferenceExpression)assignExp.Target; ISymbolTable scope = varRef.SymbolTable; System.Diagnostics.Debug.Assert(scope != null); String name = varRef.Identifier.Name; if (!scope.IsDefined(name)) // TODO: The rules are slighly more complicated than that. { errorReport.Disable(); SingleVariableDeclarationStatement varDecl = new SingleVariableDeclarationStatement(varRef.Identifier); IStatement stmt = ASTUtils.GetParentStatement(varRef); System.Diagnostics.Debug.Assert(stmt != null); IStatementContainer stmts = stmt.Parent as IStatementContainer; int index = stmts.Statements.IndexOf(stmt); varDecl.InitExp = assignExp.Value; // stmts.Statements.Insert(index, varDecl); stmts.Statements.Replace(stmt, varDecl); if (!ApplyDeclarationRules(varRef.Identifier, scope, varDecl, stmt)) { stmts.Statements.Remove(varDecl); } errorReport.Enable(); } } return(base.VisitAssignmentExpression(assignExp)); }
public IonSystemLite(IonTextWriterBuilder textWriterBuilder, PrivateIonBinaryWriterBuilder binaryWriterBuilder, IonReaderBuilder readerBuilder) { _readerBuilder = readerBuilder; var catalog = textWriterBuilder.Catalog; //make sure we're on the same catalog here Debug.Assert(catalog == binaryWriterBuilder.Catalog); Debug.Assert(catalog == readerBuilder.Catalog); Context = new ContainerlessContext(this); Catalog = catalog; _systemSymbolTable = binaryWriterBuilder.InitialSymbolTable; Debug.Assert(_systemSymbolTable.IsSystem); binaryWriterBuilder.SymtabValueFactory = this; _textWriterBuilder = textWriterBuilder.Immutable(); _binaryWriterBuilder = binaryWriterBuilder.Immutable(); }
public HandleContext( Statement statement, ISymbolTable symbolTable, List <IPreCondition> preConditions, List <string> assignmentTargetVariables, List <BlockAssignment> blockAssignments, List <int> successors, Dictionary <string, bool> arrayFragmentTypeDefined, Dictionary <string, bool> stringBuilderFragmentTypeDefined) { _statement = ArgumentUtility.CheckNotNull("statement", statement); _symbolTable = ArgumentUtility.CheckNotNull("symbolTable", symbolTable); _preConditions = ArgumentUtility.CheckNotNull("preConditions", preConditions); _assignmentTargetVariables = ArgumentUtility.CheckNotNull("assignmentTargetVariables", assignmentTargetVariables); _blockAssignments = ArgumentUtility.CheckNotNull("blockAssignments", blockAssignments); _successors = ArgumentUtility.CheckNotNull("successors", successors); _arrayFragmentTypeDefined = ArgumentUtility.CheckNotNull("arrayFragmentTypeDefined", arrayFragmentTypeDefined); _stringBuilderFragmentTypeDefined = stringBuilderFragmentTypeDefined; }