static void ReadScopeAndLocals(PdbScope [] scopes, ScopeSymbol parent, MethodSymbols symbols) { foreach (PdbScope scope in scopes) { ReadScopeAndLocals(scope, parent, symbols); } }
public static void UsingPlugin(string pluginName, ScopeSymbolTable currentScope, string moduleName) { if (Plugins.ContainsKey(pluginName)) { IPlugin plugin = Plugins[pluginName]; if (ModelManager.ExtendedModelTypePool.ContainsKey(moduleName)) { throw logger.Error(new PluginException(plugin, $"Cannot using {moduleName} since the same plugin has already exists.")); } else { ModelManager.ExtendedModelTypePool.Add(moduleName, plugin.ModelTypePool); } ScopeSymbolTable pluginScope = new ScopeSymbolTable(plugin.ReferenceName, currentScope.scopeLevel + 1, currentScope); TypeSymbol scopeType = currentScope.Lookup("SCOPE") as TypeSymbol; TypeSymbol modelType = currentScope.Lookup("MODEL") as TypeSymbol; foreach (string modelName in plugin.ModelTypePool.Keys) { ScopedModelType scopedModelType = new ScopedModelType() { ModelName = modelName, ScopeName = moduleName }; pluginScope.Insert(new TypeSymbol(modelName, modelType, scopedModelType)); } ScopeSymbol scopeSymbol = new ScopeSymbol(moduleName, scopeType, pluginScope); if (!currentScope.Insert(scopeSymbol, false)) { throw logger.Error(new PluginException(plugin, $"Cannot using {moduleName} since the same symbol has already exists.")); } } else { throw logger.Error(new NotFoundException($"Plugin {pluginName}")); } }
public override void Visit(BlockStmt blockStatement) { var oldBlock = _block; _block = new ScopeSymbol(_block, blockStatement); oldBlock.Symbols.Add(_block); base.Visit(blockStatement); _block = oldBlock; }
public AggregateCoercionNode(IRContext irContext, UnaryOpKind op, ScopeSymbol scope, IntermediateNode child, IReadOnlyDictionary <DName, IntermediateNode> fieldCoercions) : base(irContext) { Contracts.AssertValue(child); Contracts.Assert(op == UnaryOpKind.RecordToRecord || op == UnaryOpKind.TableToTable); Op = op; Scope = scope; Child = child; FieldCoercions = fieldCoercions; }
private void ProcessAndRegisterMethodBody(MethodSymbol methodSymbol, BlockStmt?blockStatement) { if (blockStatement == null) { return; } var rootBlock = new ScopeSymbol(methodSymbol, blockStatement); var localVisitor = new LocalVariableDeclarationVisitor(_logger, rootBlock); localVisitor.Resolve(blockStatement); methodSymbol.Block = rootBlock; }
void WriteScope(PdbMethodSymbols symbols, ScopeSymbol scope, bool rootScope) { writer.OpenScope(scope.Start); // TODO: Store used namespace per scope? if (rootScope) { DefineUsedNamespaces(symbols); } foreach (var s in scope.Scopes) { WriteScope(symbols, s, false); } DefineVariables(symbols, scope.Variables, scope.Start, scope.End); writer.CloseScope(scope.End); }
static void ReadScopeAndLocals(PdbScope scope, ScopeSymbol parent, MethodSymbols symbols) { if (scope == null) { return; } ScopeSymbol s = new ScopeSymbol(); s.start = (int)scope.offset; s.end = (int)(scope.offset + scope.length); if (parent != null) { parent.Scopes.Add(s); } else if (symbols.scope == null) { symbols.scope = s; } else { throw new InvalidDataException(); } foreach (PdbSlot slot in scope.slots) { int index = (int)slot.slot; if (index < 0 || index >= symbols.Variables.Count) { continue; } VariableDefinition variable = symbols.Variables [index]; variable.Name = slot.name; s.Variables.Add(variable); } ReadScopeAndLocals(scope.scopes, s, symbols); }
public CallNode(IRContext irContext, TexlFunction func, ScopeSymbol scope, IList <IntermediateNode> args) : this(irContext, func, args) { Contracts.AssertValue(scope); Scope = scope; }
public LocalVariableDeclarationVisitor(ILogger logger, ScopeSymbol rootBlock) { // TODO support cancellation _logger = logger; _block = rootBlock; }
public FormulaValue GetScopeVar(ScopeSymbol scope, string name) { IScope record = ScopeValues[scope.Id]; return(record.Resolve(name)); // Binder should ensure success. }
public SymbolContext WithScope(ScopeSymbol currentScope) { return(new SymbolContext(Globals, currentScope, ScopeValues)); }
public SymbolContext(RecordValue globals, ScopeSymbol currentScope, Dictionary <int, IScope> scopeValues) { _globals = globals; _currentScope = currentScope; _scopeValues = scopeValues; }