예제 #1
0
        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)");
        }
예제 #2
0
 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;
 }
예제 #3
0
        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;
        }
예제 #4
0
 public void Push(ISymbolView view)
 {
     view.RectTransform.SetParent(_heap);
     _freeSymbols.Push(view);
 }