private void CheckSymbolLink(SymbolLink link) { if (link.pool_id == UnkID) throw new ArgumentException("the symbol link is not binded"); if (link.pool_id != _id) throw new ArgumentException("the symbol link is binded to other memory pool"); }
public override bool Get(object atom, out SymbolLink result) { bool res = base.Get(atom, out result); if (res && result.Type == typeof(Resultset)) Resultsets.Add(atom); return res; }
public void Init(MemoryPool pool) { SymbolLink self = new SymbolLink(typeof(IContextProvider)); pool.Bind(self); pool.SetData(self, this); SetValue(ID.Context, self); }
public XQueryPathExpr(XQueryContext context, XQueryExprBase[] path, bool isOrdered) : base(context) { _path = path; _isOrderedSet = IsOrderedSet(); _isOrdered = isOrdered; _cache = new SymbolLink(); EnableCaching = true; }
public bool Get(object atom, out SymbolLink result) { SymbolLink link; if (m_values.TryGetValue(atom, out link) && link != null) { result = link; return true; } result = null; return false; }
public virtual bool Get(object atom, out SymbolLink result) { ColumnBinding b = GetBinding(atom); if (b == null) { result = null; return false; } result = b.data; return true; }
public void Bind(SymbolLink link) { if (link == null) throw new ArgumentNullException("link"); if (_protected) throw new InvalidOperationException("the memory pool is protected for binding"); if (link.pool_id != UnkID) throw new ArgumentException("the symbol link is already binded to the memory pool"); link.pool_id = _id; link.index = _count++; EnsureCapacity(); }
public static Inline Render(this ISymbol symbol, string alias, bool bold, WpfBrush brush) { var run = new SymbolLink(symbol, alias, Config.Instance.QuickInfoOptions.MatchFlags(QuickInfoOptions.ClickAndGo)); if (bold || brush == null) { run.FontWeight = FontWeights.Bold; } if (brush != null) { run.Foreground = brush; } return(run); }
public Token ProcessSymbolUsage(SyntaxToken token, ISymbol symbol, bool isDeclaration) { string fullName = GetSymbolName(symbol); string value = token.ToString(); string type = String.Empty; int lineNumber = token.GetLocation().GetLineSpan().StartLinePosition.Line + 1; bool isSearchable = isDeclaration; if (symbol is INamedTypeSymbol) { type = _walkerUtils.TypeTokenTypeName; } else { type = _walkerUtils.IdentifierTokenTypeName; } //Do not allow us to search locals if (symbol.Kind == SymbolKind.Local || symbol.Kind == SymbolKind.Parameter) { isSearchable = false; } var tokenModel = new Token(this.DocumentModel, fullName, value, type, lineNumber, isDeclaration, isSearchable); //If we can find the declaration, we'll link it ourselves if (symbol.DeclaringSyntaxReferences.Any() && !(symbol is INamespaceSymbol)) { var link = new SymbolLink(referencedSymbolName: fullName); tokenModel = tokenModel.WithLink(link); } //Otherwise, we try to link to the .Net Reference source else if (_refsourceLinkProvider.Assemblies.Contains(symbol.ContainingAssembly?.Identity?.Name) && !(symbol is INamespaceSymbol)) { var link = new UrlLink(url: _refsourceLinkProvider.GetLink(symbol)); tokenModel = tokenModel.WithLink(link); } return(tokenModel); }
public override void Bind(Executive.Parameter[] parameters, MemoryPool pool) { value = QueryContext.Engine.TryGet(name, false, true); if (value == null) { if (parameters != null) { arg_index = 0; foreach (Executive.Parameter p in parameters) { if (p.ID == name) return; arg_index++; } } value = QueryContext.Engine.TryGet(name, true, false); if (value == null) throw new ValueNotDefined(name.ToString()); } }
public override void Bind(Executive.Parameter[] parameters, MemoryPool pool) { m_context = new SymbolLink(typeof(IContextProvider)); pool.Bind(m_context); object data = QueryContext.Resolver.GetCurrentStack(); QueryContext.Resolver.SetValue(ID.Context, m_context); m_compiledBody = new FunctionLink[m_expr.Length]; for (int k = 0; k < m_expr.Length; k++) { m_compiledBody[k] = new FunctionLink(); QueryContext.Engine.Compile(parameters, m_expr[k], m_compiledBody[k]); } if (Annotation != null) { m_compiledAnnotation = new FunctionLink[Annotation.Length]; for (int k = 0; k < Annotation.Length; k++) { m_compiledAnnotation[k] = new FunctionLink(); QueryContext.Engine.Compile(parameters, Annotation[k], m_compiledAnnotation[k]); } } QueryContext.Resolver.RevertToStack(data); }
private void ProcessVarDecl(Notation notation, Notation.Record rec) { VarName name = (VarName)rec.Arg0; object var = ProcessVarName(name); if (_context.Engine.TryGet(var, true, false) != null) throw new XQueryException(Properties.Resources.XQST0049, name); XQuerySequenceType varType; if (rec.Arg1 == null) varType = XQuerySequenceType.Item; else varType = ProcessTypeDecl(notation, rec.Arg1); bool external = false; SymbolLink valueLink; if (rec.args.Length > 2) { object valueExpr = ProcessExprSingle(notation, rec.Arg2); if (varType == XQuerySequenceType.Item) { XQuerySequenceType type = EvalExprType(valueExpr); if (type.Cardinality == XmlTypeCardinality.One) varType = type; } valueLink = new SymbolLink(varType.ValueType); _context.AddVariable(var, valueExpr, varType, valueLink); } else { valueLink = new SymbolLink(varType.ValueType); _context.AddExternalVariable(var, varType); external = true; } valueLink.IsStatic = true; _context.Engine.DefaultPool.Bind(valueLink); _context.Engine.DefaultPool.SetData(valueLink, Undefined.Value); _context.Engine.Set(var, valueLink); _varTable.PushVar(var, varType, external); }
public XQueryLET(XQueryContext context, object var, XQuerySequenceType varType, object expr, XQueryExprBase bodyExpr, bool convert) : base(context, var, varType, expr, bodyExpr) { m_value = new SymbolLink(varType.ValueType); m_convert = convert; }
private void OnChangeValue(SymbolLink line, MemoryPool pool) { pool.SetData(_cache, null); }
public void Set(object atom, SymbolLink link) { SymbolLink link2; if (m_value.TryGetValue(atom, out link2)) throw new ArgumentException("Value already defined"); m_value.Add(atom, link); }
public SymbolLink Set(object atom, object value) { SymbolLink link; if (!m_value.TryGetValue(atom, out link)) { if (!Lisp.IsAtom(atom)) throw new ArgumentException(); link = new SymbolLink(); m_defaultPool.Bind(link); m_value.Add(atom, link); } m_defaultPool.SetData(link, value); return link; }
public void SetData(SymbolLink link, object value) { CheckSymbolLink(link); _values[link.index] = value; link.ChangeValue(this); }
public object GetData(SymbolLink link) { CheckSymbolLink(link); return _values[link.index]; }
public void Compile() { CheckDisposed(); if (String.IsNullOrEmpty(CommandText)) throw new XQueryException("CommandText is empty string"); TokenizerBase tok = new Tokenizer(CommandText); Notation notation = new Notation(); YYParser parser = new YYParser(notation); parser.yyparseSafe(tok); if (BaseUri != null) m_context.BaseUri = BaseUri; if (SearchPath != null) m_context.SearchPath = SearchPath; m_context.SchemaProcessing = SchemaProcessing; m_context.Engine.Prepare(); SymbolLink contextLink = new SymbolLink(typeof(IContextProvider)); m_context.Engine.DefaultPool.Bind(contextLink); m_context.Engine.DefaultPool.SetData(contextLink, this); m_context.Resolver.SetValue(ID.Context, contextLink); Translator translator = new Translator(m_context); translator.PreProcess(notation); if (OnPreProcess != null) // Chance to process custom declare option statement OnPreProcess(this, EventArgs.Empty); m_res = translator.Process(notation); if (m_res == null) throw new XQueryException("Can't run XQuery function module"); m_res.Bind(null, m_context.Engine.DefaultPool); // Compile variables and check it for XQST0054 m_vars = new FunctionLink[m_context.variables.Count]; Dictionary<SymbolLink, SymbolLink[]> dependences = new Dictionary<SymbolLink, SymbolLink[]>(); for (int k = 0; k < m_context.variables.Count; k++) { XQueryContext.VariableRecord rec = m_context.variables[k]; m_vars[k] = new FunctionLink(); HashSet<Object> hs = new HashSet<object>(); dependences.Add(rec.link, m_context.Engine.GetValueDependences(hs, null, rec.expr, m_vars[k], true)); } int i = 0; foreach (KeyValuePair<SymbolLink, SymbolLink[]> kvp in dependences) { List<SymbolLink> closure = new List<SymbolLink>(); HashSet<SymbolLink> hs = new HashSet<SymbolLink>(); hs.Add(kvp.Key); closure.AddRange(kvp.Value); bool expand; do { expand = false; for (int k = 0; k < closure.Count; k++) { SymbolLink[] values; if (dependences.TryGetValue(closure[k], out values)) { if (hs.Contains(closure[k])) throw new XQueryException(Properties.Resources.XQST0054, m_context.variables[i].id); hs.Add(closure[k]); closure.RemoveAt(k); closure.AddRange(values); expand = true; break; } } } while (expand); i++; } m_compiled = true; }
public XQueryFLWOR(XQueryContext context, object var, XQuerySequenceType varType, object pos, object expr, XQueryExprBase bodyExpr, bool convert) : base(context, var, varType, expr, bodyExpr) { m_var = var; m_varType = varType; m_pos = pos; m_value = new SymbolLink(varType.ValueType); m_itemType = varType.ItemType; if (m_pos != null) m_posValue = new SymbolLink(typeof(Integer)); m_convert = convert; }
public void SetValue(object atom, SymbolLink link) { m_values[atom] = link; }
public SymbolLink[] List() { SymbolLink[] res = new SymbolLink[m_values.Values.Count]; m_values.Values.CopyTo(res, 0); return res; }