Beispiel #1
0
            public DisposeMethod(IteratorStorey host)
                : base(host, TypeManager.system_void_expr, Modifiers.PUBLIC, new MemberName("Dispose", host.Location))
            {
                host.AddMethod(this);

                Block = new ToplevelBlock(host.Iterator.Container, Parameters.EmptyReadOnlyParameters, Location);
                Block.AddStatement(new DisposeMethodStatement(host.Iterator));
            }
Beispiel #2
0
            public static GetEnumeratorMethod Create(IteratorStorey host, FullNamedExpression returnType, MemberName name, Statement statement)
            {
                var m    = new GetEnumeratorMethod(host, returnType, name);
                var stmt = statement ?? new GetEnumeratorStatement(host, m);

                m.block.AddStatement(stmt);
                return(m);
            }
Beispiel #3
0
            public DisposeMethod(IteratorStorey host)
                : base(host, null, new TypeExpression(host.Compiler.BuiltinTypes.Void, host.Location), Modifiers.PUBLIC | Modifiers.DEBUGGER_HIDDEN,
                       new MemberName("Dispose", host.Location), ToplevelBlock.Flags.CompilerGenerated | ToplevelBlock.Flags.NoFlowAnalysis)
            {
                host.Members.Add(this);

                Block.AddStatement(new DisposeMethodStatement(host.Iterator));
            }
Beispiel #4
0
            public DisposeMethod(IteratorStorey host)
                : base(host, new TypeExpression(host.Compiler.BuiltinTypes.Void, host.Location), Modifiers.PUBLIC | Modifiers.DEBUGGER_HIDDEN,
                       new MemberName("Dispose", host.Location))
            {
                host.AddMethod(this);

                Block.AddStatement(new DisposeMethodStatement(host.Iterator));
            }
Beispiel #5
0
        public IteratorMethod(IteratorStorey host, FullNamedExpression returnType, Modifiers mod, MemberName name)
            : base(host, null, returnType, mod | Modifiers.COMPILER_GENERATED,
                   name, ParametersCompiled.EmptyReadOnlyParameters, null)
        {
            this.host = host;

            Block = new ToplevelBlock(host.Compiler, ParametersCompiled.EmptyReadOnlyParameters, Location);
        }
Beispiel #6
0
            public IteratorMethod(IteratorStorey host, FullNamedExpression returnType, int mod, MemberName name)
                : base(host, null, returnType, mod | Modifiers.DEBUGGER_HIDDEN | Modifiers.COMPILER_GENERATED,
                       name, Parameters.EmptyReadOnlyParameters, null)
            {
                this.host = host;

                Block = new ToplevelBlock(host.Iterator.Container.Toplevel, Parameters.EmptyReadOnlyParameters, Location);
            }
Beispiel #7
0
        //
        // Our constructor
        //
        private Iterator(CompilerContext ctx, IMethodData method, TypeContainer host, TypeSpec iterator_type, bool is_enumerable)
            : base(new ToplevelBlock (ctx, method.Block, ParametersCompiled.EmptyReadOnlyParameters, method.Block.StartLocation),
				TypeManager.bool_type,
				method.Location)
        {
            this.OriginalMethod = method;
            this.OriginalIteratorType = iterator_type;
            this.IsEnumerable = is_enumerable;
            this.Host = host;
            this.type = method.ReturnType;

            IteratorHost = Block.ChangeToIterator (this, method.Block);
        }
Beispiel #8
0
        //
        // Our constructor
        //
        private Iterator(IMethodData method, TypeContainer host, Type iterator_type, bool is_enumerable)
            : base(
                new ToplevelBlock(method.Block, Parameters.EmptyReadOnlyParameters, method.Block.StartLocation),
                TypeManager.bool_type,
                method.Location)
        {
            this.OriginalMethod       = method;
            this.OriginalIteratorType = iterator_type;
            this.IsEnumerable         = is_enumerable;
            this.Host = host;

            IteratorHost = Block.ChangeToIterator(this, method.Block);
        }
Beispiel #9
0
        protected override Expression DoResolve(ResolveContext ec)
        {
            IteratorHost = (IteratorStorey)block.TopBlock.AnonymousMethodStorey;

            BlockContext ctx = new BlockContext(ec, block, ReturnType);

            ctx.CurrentAnonymousMethod = this;

            ctx.StartFlowBranching(this, ec.CurrentBranching);
            Block.Resolve(ctx);
            ctx.EndFlowBranching();

            var move_next = new IteratorMethod(IteratorHost, new TypeExpression(ec.BuiltinTypes.Bool, loc),
                                               Modifiers.PUBLIC, new MemberName("MoveNext", Location));

            move_next.Block.AddStatement(new MoveNextMethodStatement(this));
            IteratorHost.AddMethod(move_next);

            eclass = ExprClass.Value;
            return(this);
        }
Beispiel #10
0
		public void WrapIntoIterator (IMethodData method, TypeContainer host, TypeSpec iterator_type, bool is_enumerable)
		{
			ParametersBlock pb = new ParametersBlock (this, ParametersCompiled.EmptyReadOnlyParameters, StartLocation);
			pb.EndLocation = EndLocation;
			pb.statements = statements;

			var iterator = new Iterator (pb, method, host, iterator_type, is_enumerable);
			am_storey = new IteratorStorey (iterator);

			statements = new List<Statement> (1);
			AddStatement (new Return (iterator, iterator.Location));
		}
Beispiel #11
0
 public GetEnumeratorMethod(IteratorStorey host, FullNamedExpression returnType, MemberName name)
     : base(host, returnType, Modifiers.DEBUGGER_HIDDEN, name)
 {
     Block.AddStatement(new GetEnumeratorStatement(host, this));
 }
Beispiel #12
0
			public DisposeMethod (IteratorStorey host)
				: base (host, new TypeExpression (TypeManager.void_type, host.Location), Modifiers.PUBLIC | Modifiers.DEBUGGER_HIDDEN,
					new MemberName ("Dispose", host.Location))
			{
				host.AddMethod (this);

				Block.AddStatement (new DisposeMethodStatement (host.Iterator));
			}
Beispiel #13
0
 public GetEnumeratorStatement(IteratorStorey host, IteratorMethod host_method)
 {
     this.host = host;
     this.host_method = host_method;
     loc = host_method.Location;
 }
Beispiel #14
0
 public static GetEnumeratorMethod Create(IteratorStorey host, FullNamedExpression returnType, MemberName name)
 {
     return(Create(host, returnType, name, null));
 }
Beispiel #15
0
 GetEnumeratorMethod(IteratorStorey host, FullNamedExpression returnType, MemberName name)
     : base(host, null, returnType, Modifiers.DEBUGGER_HIDDEN, name, ToplevelBlock.Flags.CompilerGenerated | ToplevelBlock.Flags.NoFlowAnalysis)
 {
 }
Beispiel #16
0
		//
		// Reformats this block to be top-level iterator block
		//
		public IteratorStorey ChangeToIterator (Iterator iterator, ToplevelBlock source)
		{
			IsIterator = true;

			// Creates block with original statements
			AddStatement (new IteratorStatement (iterator, new Block (this, source)));

			source.statements = new List<Statement> (1);
			source.AddStatement (new Return (iterator, iterator.Location));
			source.IsIterator = false;

			IteratorStorey iterator_storey = new IteratorStorey (iterator);
			source.am_storey = iterator_storey;
			return iterator_storey;
		}
 GetEnumeratorMethod(IteratorStorey host, FullNamedExpression returnType, MemberName name)
     : base(host, null, returnType, Modifiers.DEBUGGER_HIDDEN, name)
 {
 }
Beispiel #18
0
		protected override Expression DoResolve (ResolveContext ec)
		{
			IteratorHost = (IteratorStorey) block.TopBlock.AnonymousMethodStorey;

			BlockContext ctx = new BlockContext (ec, block, ReturnType);
			ctx.CurrentAnonymousMethod = this;

			ctx.StartFlowBranching (this, ec.CurrentBranching);
			Block.Resolve (ctx);
			ctx.EndFlowBranching ();

			var move_next = new IteratorMethod (IteratorHost, new TypeExpression (TypeManager.bool_type, loc),
				Modifiers.PUBLIC, new MemberName ("MoveNext", Location));
			move_next.Block.AddStatement (new MoveNextMethodStatement (this));
			IteratorHost.AddMethod (move_next);

			eclass = ExprClass.Value;
			return this;
		}
Beispiel #19
0
            public DisposeMethod(IteratorStorey host)
                : base(host, TypeManager.system_void_expr, Modifiers.PUBLIC, new MemberName ("Dispose", host.Location))
            {
                host.AddMethod (this);

                Block = new ToplevelBlock (Compiler, host.Iterator.Container, ParametersCompiled.EmptyReadOnlyParameters, Location);
                Block.AddStatement (new DisposeMethodStatement (host.Iterator));
            }
Beispiel #20
0
 public GetEnumeratorMethod(IteratorStorey host, FullNamedExpression returnType, MemberName name)
     : base(host, returnType, 0, name)
 {
     Block.AddStatement (new GetEnumeratorStatement (host, this));
 }
Beispiel #21
0
 public GetEnumeratorStatement(IteratorStorey host, IteratorMethod host_method)
 {
     this.host        = host;
     this.host_method = host_method;
     loc = host_method.Location;
 }
Beispiel #22
0
            public IteratorMethod(IteratorStorey host, FullNamedExpression returnType, Modifiers mod, MemberName name)
                : base(host, null, returnType, mod | Modifiers.DEBUGGER_HIDDEN | Modifiers.COMPILER_GENERATED,
				  name, ParametersCompiled.EmptyReadOnlyParameters, null)
            {
                this.host = host;

                Block = new ToplevelBlock (Compiler, host.Iterator.Container.Toplevel, ParametersCompiled.EmptyReadOnlyParameters, Location);
            }
Beispiel #23
0
		//
		// Our constructor
		//
		private Iterator (IMethodData method, TypeContainer host, Type iterator_type, bool is_enumerable)
			: base (
				new ToplevelBlock (method.Block, Parameters.EmptyReadOnlyParameters, method.Block.StartLocation),
				TypeManager.bool_type,
				method.Location)
		{
			this.OriginalMethod = method;
			this.OriginalIteratorType = iterator_type;
			this.IsEnumerable = is_enumerable;
			this.Host = host;

			IteratorHost = Block.ChangeToIterator (this, method.Block);
		}