public static AstExpr ExprFor(this IAstFactory factory, ISourcePosition position, QualifiedId qualifiedId, ISymbolView<Symbol> scope) { var currentScope = scope; for (var i = 0; i < qualifiedId.Count; i++) { // Lookup name part Symbol sym; if (!currentScope.TryGet(qualifiedId[i], out sym)) { return new AstUnresolved(position, qualifiedId[i]); } var expr = factory.ExprFor(position, sym); // last part of qualified ID does not need to be a namespace, so we're done here if (i == qualifiedId.Count - 1) return expr; var nsUsage = expr as AstNamespaceUsage; if (nsUsage == null) { factory.ReportMessage(Message.Error( string.Format(Resources.Parser_NamespaceExpected, qualifiedId[i], sym), position, MessageClasses.NamespaceExcepted)); return factory.IndirectCall(position, factory.Null(position)); } currentScope = nsUsage.Namespace; } throw new InvalidOperationException("Failed to resolve qualified Id (program control should never reach this point)"); }
public SymbolMExprParser([NotNull] ISymbolView<Symbol> symbols,[NotNull] IMessageSink messageSink, [NotNull]ISymbolView<Symbol> topLevelSymbols = null) { if (symbols == null) throw new ArgumentNullException("symbols"); if (messageSink == null) throw new ArgumentNullException("messageSink"); _symbols = symbols; _messageSink = messageSink; _topLevelSymbols = topLevelSymbols ?? symbols; }
public void PlaceSymbol(int positionY, Duration symbolDuration, ISymbolView view) { var offsetMultiplier = 0f; if (_lastSymbolDuration != Duration.Undefined) { offsetMultiplier = Config.GetDistanceOffsetMultiplier(_lastSymbolDuration) .Check($"[StaffView] There is no distance offset for duration '{_lastSymbolDuration}' in StaffConfig!") .ValueOr(0); } var posX = _lastSymbolPosition + Config.DistanceBetweenSymbolsHorizontal * offsetMultiplier; var posY = positionY * Config.DistanceBetweenSymbolsVertical; var rt = view.RectTransform; rt.SetParent(_contents, false); rt.anchoredPosition = new Vector2(posX, posY); _symbolsOnTheStaff.Add(view); _lastSymbolPosition = posX; _lastSymbolDuration = symbolDuration; }
public void Push(ISymbolView view) { view.RectTransform.SetParent(_heap); _freeSymbols.Push(view); }