Exemplo n.º 1
0
 public override object Visit(MemberReference that, object value)
 {
     var result = (System.Text.StringBuilder) value;
     result.Append('!');
     result.Append(that.Symbol);
     return null;
 }
Exemplo n.º 2
0
 public override object Visit(MemberReference that, object value)
 {
     _writer.Write('.');
     _writer.Write(that.Symbol);
     return null;
 }
        public override object Visit(MemberReference that, object value = null)
        {
            PrintPrologue(that);
            PrintReference(that);
            PrintEpilogue(that);

            return null;
        }
Exemplo n.º 4
0
        public override object Visit(MemberReference that, object value)
        {
            Storage index = new TemporaryStorage(CreateTemporary());

            _writer.Write(index.ToString() + " = getelementptr ");
            #if DONE && CORRECT
            /** \todo Look up the containing class, output its name, and so on. */
            that.First.Type.Visit(this);

            _writer.Write("* %");
            that.First.Visit(this);

            _writer.Write(", i32 0, i32 ");
            that.Other.Visit(this);

            /** \todo Map member name to LLVM index. */
            that.First.Visit(this);

            _writer.WriteLine();
            #endif
            return (object) index;
        }
Exemplo n.º 5
0
        public override object Visit(MemberReference that, object value = null)
        {
            /** \todo Check that the element actually is a member of the current class. */
            /** \todo Return the final type of the member expression. */

            Folder<Symbol> folder = (Folder<Symbol>) _symbols.Inner.FindUpwards("this");
            Object<Symbol> result = folder.Resolve(that.Symbol);
            if (result == null)
                throw new Toolbox.Error(Toolbox.ErrorKind.Fatal, that.Cursor, 0, "Unknown symbol: " + that.Symbol);

            that.Definition = result.Data.Definition;

            return (object) result.Data;
        }
Exemplo n.º 6
0
        /** Parses a single reference to an absolute, an instance, or a relative symbol that already exists. */
        private Reference ParseReference()
        {
            PathKind kind;
            switch (_matcher.This.Kind)
            {
                case TokenKind.Name:
                    kind = PathKind.Relative;
                    break;

                case TokenKind.Dot:
                    _matcher.Match(TokenKind.Dot);
                    kind = PathKind.Instance;
                    break;

                case TokenKind.Exclamation:
                    _matcher.Match(TokenKind.Exclamation);
                    kind = PathKind.Absolute;
                    break;

                default:
                    throw new ParserError(_matcher.This.Cursor, "Expected absolute, instance-relative, or relative symbol reference");
            }

            Token first = _matcher.Match(TokenKind.Name);
            Reference result = new SymbolReference(first.Cursor, kind, first.Text);

            while (_matcher.This.Kind == TokenKind.Dot)
            {
                _matcher.Match(TokenKind.Dot);
                Token name = _matcher.Match(TokenKind.Name);
                result = new MemberReference(
                    first.Cursor,
                    result,
                    new SymbolReference(name.Cursor, PathKind.Member, name.Text)
                );
                first = name;
            }

            return result;
        }