text:
using System;
using System.Collections.Generic;
using Mono.CompilerServices.SymbolWriter;

#if STATIC
using IKVM.Reflection.Emit;
#else
using System.Reflection.Emit;
#endif

namespace Mono.CSharp
{
	public abstract class YieldStatement<T> : ResumableStatement where T : StateMachineInitializer
	{
		protected Expression expr;
		protected bool unwind_protect;
		protected T machine_initializer;
		int resume_pc;

		protected YieldStatement (Expression expr, Location l)
		{
			this.expr = expr;
			loc = l;
		}

		public Expression Expr {
			get { return this.expr; }
		}

		protected override void CloneTo (CloneContext clonectx, Statement t)
		{
			var target = (YieldStatement<T>) t;
			target.expr = expr.Clone (clonectx);
		}

		protected override void DoEmit (EmitContext ec)
		{
			machine_initializer.InjectYield (ec, expr, resume_pc, unwind_protect, resume_point);
		}

		public override bool Resolve (BlockContext bc)
		{
			expr = expr.Resolve (bc);
			if (expr == null)
				return false;

			machine_initializer = bc.CurrentAnonymousMethod as T;

			if (!bc.CurrentBranching.CurrentUsageVector.IsUnreachable)
				unwind_protect = bc.CurrentBranching.AddResumePoint (this, out resume_pc);

			return true;
		}
	}

	public class Yield : YieldStatement<Iterator>
	{
		public Yield (Expression expr, Location loc)
			: base (expr, loc)
		{
		}

		public static bool CheckContext (ResolveContext ec, Location loc)
		{
			if (!ec.CurrentAnonymousMethod.IsIterator) {
				ec.Report.Error (1621, loc,
					"The yield statement cannot be used inside anonymous method blocks");
				return false;
			}

			return true;
		}

		public override bool Resolve (BlockContext bc)
		{
			if (!CheckContext (bc, loc))
				return false;

			if (!base.Resolve (bc))
				return false;

			var otype = bc.CurrentIterator.OriginalIteratorType;
			if (expr.Type != otype) {
				expr = Convert.ImplicitConversionRequired (bc, expr, otype, loc);
				if (expr == null)
					return false;
			}

			return true;
		}

		public override object Accept (StructuralVisitor visitor)
		{
			return visitor.Visit (this);
		}
	}

	public class YieldBreak : ExitStatement
	{
		Iterator iterator;

		public YieldBreak (Location l)
		{
			loc = l;
		}

		public override void Error_FinallyClause (Report Report)
		{
			Report.Error (1625, loc, "Cannot yield in the body of a finally clause");
		}

		protected override void CloneTo (CloneContext clonectx, Statement target)
		{
			throw new NotSupportedException ();
		}

		protected override bool DoResolve (BlockContext ec)
		{
			iterator = ec.CurrentIterator;
			return Yield.CheckContext (ec, loc);
		}

		protected override void DoEmit (EmitContext ec)
		{
			iterator.EmitYieldBreak (ec, unwind_protect);
		}

		public override object Accept (StructuralVisitor visitor)
		{
			return visitor.Visit (this);
		}
	}

	public abstract class StateMachine : AnonymousMethodStorey
	{
		public enum State
		{
			Running = -3, // Used only in CurrentPC, never stored into $PC
			Uninitialized = -2,
			After = -1,
			Start = 0
		}

		Field pc_field;
		StateMachineMethod method;
		int local_name_idx;

		protected StateMachine (ParametersBlock block, TypeDefinition parent, MemberBase host, TypeParameters tparams, string name, MemberKind kind)
			: base (block, parent, host, tparams, name, kind)
		{
		}

		#region Properties

		public StateMachineMethod StateMachineMethod {
			get {
				return method;
			}
		}

		public Field PC {
			get {
				return pc_field;
			}
		}

		#endregion

		public void AddEntryMethod (StateMachineMethod method)
		{
			if (this.method != null)
				throw new InternalErrorException ();

			this.method = method;
			Members.Add (method);
		}

		protected override bool DoDefineMembers ()
		{
			pc_field = AddCompilerGeneratedField ("$PC", new TypeExpression (Compiler.BuiltinTypes.Int, Location));

			return base.DoDefineMembers ();
		}

		protected override string GetVariableMangledName (LocalVariable local_info)
		{
			if (local_info.IsCompilerGenerated)
				return base.GetVariableMangledName (local_info);

			return "<" + local_info.Name + ">__" + local_name_idx++.ToString ("X");
		}
	}

	class IteratorStorey : StateMachine
	{
		class GetEnumeratorMethod : StateMachineMethod
		{
			sealed class GetEnumeratorStatement : Statement
			{
				readonly IteratorStorey host;
				readonly StateMachineMethod host_method;

				Expression new_storey;

				public GetEnumeratorStatement (IteratorStorey host, StateMachineMethod host_method)
				{
					this.host = host;
					this.host_method = host_method;
					loc = host_method.Location;
				}

				protected override void CloneTo (CloneContext clonectx, Statement target)
				{
					throw new NotSupportedException ();
				}

				public override bool Resolve (BlockContext ec)
				{
					TypeExpression storey_type_expr = new TypeExpression (host.Definition, loc);
					List<Expression> init = null;
					if (host.hoisted_this != null) {
						init = new List<Expression> (host.hoisted_params == null ? 1 : host.HoistedParameters.Count + 1);
						HoistedThis ht = host.hoisted_this;
						FieldExpr from = new FieldExpr (ht.Field, loc);
						from.InstanceExpression = new CompilerGeneratedThis (ec.CurrentType, loc);
						init.Add (new ElementInitializer (ht.Field.Name, from, loc));
					}

					if (host.hoisted_params != null) {
						if (init == null)
							init = new List<Expression> (host.HoistedParameters.Count);

						for (int i = 0; i < host.hoisted_params.Count; ++i) {
							HoistedParameter hp = host.hoisted_params [i];
							HoistedParameter hp_cp = host.hoisted_params_copy [i];

							FieldExpr from = new FieldExpr (hp_cp.Field, loc);
							from.InstanceExpression = new CompilerGeneratedThis (ec.CurrentType, loc);

							init.Add (new ElementInitializer (hp.Field.Name, from, loc));
						}
					}

					if (init != null) {
						new_storey = new NewInitialize (storey_type_expr, null,
							new CollectionOrObjectInitializers (init, loc), loc);
					} else {
						new_storey = new New (storey_type_expr, null, loc);
					}

					new_storey = new_storey.Resolve (ec);
					if (new_storey != null)
						new_storey = Convert.ImplicitConversionRequired (ec, new_storey, host_method.MemberType, loc);

					ec.CurrentBranching.CurrentUsageVector.Goto ();
					return true;
				}

				protected override void DoEmit (EmitContext ec)
				{
					Label label_init = ec.DefineLabel ();

					ec.EmitThis ();
					ec.Emit (OpCodes.Ldflda, host.PC.Spec);
					ec.EmitInt ((int) State.Start);
					ec.EmitInt ((int) State.Uninitialized);

					var m = ec.Module.PredefinedMembers.InterlockedCompareExchange.Resolve (loc);
					if (m != null)
						ec.Emit (OpCodes.Call, m);

					ec.EmitInt ((int) State.Uninitialized);
					ec.Emit (OpCodes.Bne_Un_S, label_init);

					ec.EmitThis ();
					ec.Emit (OpCodes.Ret);

					ec.MarkLabel (label_init);

					new_storey.Emit (ec);
					ec.Emit (OpCodes.Ret);
				}
			}

			GetEnumeratorMethod (IteratorStorey host, FullNamedExpression returnType, MemberName name)
				: base (host, null, returnType, Modifiers.DEBUGGER_HIDDEN, name)
			{
			}

			public static GetEnumeratorMethod Create (IteratorStorey host, FullNamedExpression returnType, MemberName name)
			{
				return Create (host, returnType, name, null);
			}

			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);
				m.block.IsCompilerGenerated = true;
				return m;
			}
		}

		class DisposeMethod : StateMachineMethod
		{
			sealed class DisposeMethodStatement : Statement
			{
				Iterator iterator;

				public DisposeMethodStatement (Iterator iterator)
				{
					this.iterator = iterator;
					this.loc = iterator.Location;
				}

				protected override void CloneTo (CloneContext clonectx, Statement target)
				{
					throw new NotSupportedException ();
				}

				public override bool Resolve (BlockContext ec)
				{
					return true;
				}

				protected override void DoEmit (EmitContext ec)
				{
					ec.CurrentAnonymousMethod = iterator;
					iterator.EmitDispose (ec);
				}
			}

			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))
			{
				host.Members.Add (this);

				Block.AddStatement (new DisposeMethodStatement (host.Iterator));
				Block.IsCompilerGenerated = true;
			}
		}

		//
		// Uses Method as method info
		//
		class DynamicMethodGroupExpr : MethodGroupExpr
		{
			readonly Method method;

			public DynamicMethodGroupExpr (Method method, Location loc)
				: base ((IList<MemberSpec>) null, null, loc)
			{
				this.method = method;
				eclass = ExprClass.Unresolved;
			}

			protected override Expression DoResolve (ResolveContext ec)
			{
				Methods = new List<MemberSpec> (1) { method.Spec };
				type = method.Parent.Definition;
				InstanceExpression = new CompilerGeneratedThis (type, Location);
				return base.DoResolve (ec);
			}
		}

		class DynamicFieldExpr : FieldExpr
		{
			readonly Field field;

			public DynamicFieldExpr (Field field, Location loc)
				: base (loc)
			{
				this.field = field;
			}

			protected override Expression DoResolve (ResolveContext ec)
			{
				spec = field.Spec;
				type = spec.MemberType;
				InstanceExpression = new CompilerGeneratedThis (type, Location);
				return base.DoResolve (ec);
			}
		}

		public readonly Iterator Iterator;

		List<HoistedParameter> hoisted_params_copy;

		TypeExpr iterator_type_expr;
		Field current_field;
		Field disposing_field;

		TypeSpec generic_enumerator_type;
		TypeSpec generic_enumerable_type;

		public IteratorStorey (Iterator iterator)
			: base (iterator.Container.ParametersBlock, iterator.Host,
			  iterator.OriginalMethod as MemberBase, iterator.OriginalMethod.CurrentTypeParameters, "Iterator", MemberKind.Class)
		{
			this.Iterator = iterator;
		}

		public Field CurrentField {
			get {
				return current_field;
			}
		}

		public Field DisposingField {
			get {
				return disposing_field;
			}
		}

		public IList<HoistedParameter> HoistedParameters {
			get { return hoisted_params; }
		}

		protected override TypeSpec[] ResolveBaseTypes (out FullNamedExpression base_class)
		{
			var mtype = Iterator.OriginalIteratorType;
			if (Mutator != null)
				mtype = Mutator.Mutate (mtype);

			iterator_type_expr = new TypeExpression (mtype, Location);

			var ifaces = new List<TypeSpec> (5);
			if (Iterator.IsEnumerable) {
				ifaces.Add (Compiler.BuiltinTypes.IEnumerable);

				if (Module.PredefinedTypes.IEnumerableGeneric.Define ()) {
					generic_enumerable_type = Module.PredefinedTypes.IEnumerableGeneric.TypeSpec.MakeGenericType (Module, new[] { mtype });
					ifaces.Add (generic_enumerable_type);
				}
			}

			ifaces.Add (Compiler.BuiltinTypes.IEnumerator);
			ifaces.Add (Compiler.BuiltinTypes.IDisposable);

			var ienumerator_generic = Module.PredefinedTypes.IEnumeratorGeneric;
			if (ienumerator_generic.Define ()) {
				generic_enumerator_type = ienumerator_generic.TypeSpec.MakeGenericType (Module, new [] { mtype });
				ifaces.Add (generic_enumerator_type);
			}

			base_class = null;

			base_type = Compiler.BuiltinTypes.Object;
			return ifaces.ToArray ();
		}

		protected override bool DoDefineMembers ()
		{
			current_field = AddCompilerGeneratedField ("$current", iterator_type_expr);
			disposing_field = AddCompilerGeneratedField ("$disposing", new TypeExpression (Compiler.BuiltinTypes.Bool, Location));

			if (hoisted_params != null) {
				//
				// Iterators are independent, each GetEnumerator call has to
				// create same enumerator therefore we have to keep original values
				// around for re-initialization
				//
				// TODO: Do it for assigned/modified parameters only
				//
				hoisted_params_copy = new List<HoistedParameter> (hoisted_params.Count);
				foreach (HoistedParameter hp in hoisted_params) {
					hoisted_params_copy.Add (new HoistedParameter (hp, "<$>" + hp.Field.Name));
				}
			}

			if (generic_enumerator_type != null)
				Define_Current (true);

			Define_Current (false);
			new DisposeMethod (this);
			Define_Reset ();

			if (Iterator.IsEnumerable) {
				FullNamedExpression explicit_iface = new TypeExpression (Compiler.BuiltinTypes.IEnumerable, Location);
				var name = new MemberName ("GetEnumerator", null, explicit_iface, Location.Null);

				if (generic_enumerator_type != null) {
					explicit_iface = new TypeExpression (generic_enumerable_type, Location);
					var gname = new MemberName ("GetEnumerator", null, explicit_iface, Location.Null);
					Method gget_enumerator = GetEnumeratorMethod.Create (this, new TypeExpression (generic_enumerator_type, Location), gname);

					//
					// Just call generic GetEnumerator implementation
					//
					var stmt = new Return (new Invocation (new DynamicMethodGroupExpr (gget_enumerator, Location), null), Location);
					Method get_enumerator = GetEnumeratorMethod.Create (this, new TypeExpression (Compiler.BuiltinTypes.IEnumerator, Location), name, stmt);

					Members.Add (get_enumerator);
					Members.Add (gget_enumerator);
				} else {
					Members.Add (GetEnumeratorMethod.Create (this, new TypeExpression (Compiler.BuiltinTypes.IEnumerator, Location), name));
				}
			}

			return base.DoDefineMembers ();
		}

		void Define_Current (bool is_generic)
		{
			TypeExpr type;
			FullNamedExpression explicit_iface;

			if (is_generic) {
				explicit_iface = new TypeExpression (generic_enumerator_type, Location);
				type = iterator_type_expr;
			} else {
				explicit_iface = new TypeExpression (Module.Compiler.BuiltinTypes.IEnumerator, Location);
				type = new TypeExpression (Compiler.BuiltinTypes.Object, Location);
			}

			var name = new MemberName ("Current", null, explicit_iface, Location);

			ToplevelBlock get_block = new ToplevelBlock (Compiler, Location) {
				IsCompilerGenerated = true
			};
			get_block.AddStatement (new Return (new DynamicFieldExpr (CurrentField, Location), Location));

			Property current = new Property (this, type, Modifiers.DEBUGGER_HIDDEN | Modifiers.COMPILER_GENERATED, name, null);
			current.Get = new Property.GetMethod (current, Modifiers.COMPILER_GENERATED, null, Location);
			current.Get.Block = get_block;

			Members.Add (current);
		}

		void Define_Reset ()
		{
			Method reset = new Method (
				this, new TypeExpression (Compiler.BuiltinTypes.Void, Location),
				Modifiers.PUBLIC | Modifiers.DEBUGGER_HIDDEN | Modifiers.COMPILER_GENERATED,
				new MemberName ("Reset", Location),
				ParametersCompiled.EmptyReadOnlyParameters, null);
			Members.Add (reset);

			reset.Block = new ToplevelBlock (Compiler, Location) {
				IsCompilerGenerated = true
			};

			TypeSpec ex_type = Module.PredefinedTypes.NotSupportedException.Resolve ();
			if (ex_type == null)
				return;

			reset.Block.AddStatement (new Throw (new New (new TypeExpression (ex_type, Location), null, Location), Location));
		}

		protected override void EmitHoistedParameters (EmitContext ec, List<HoistedParameter> hoisted)
		{
			base.EmitHoistedParameters (ec, hoisted);
			base.EmitHoistedParameters (ec, hoisted_params_copy);
		}
	}

	public class StateMachineMethod : Method
	{
		readonly StateMachineInitializer expr;

		public StateMachineMethod (StateMachine host, StateMachineInitializer expr, FullNamedExpression returnType, Modifiers mod, MemberName name)
			: base (host, returnType, mod | Modifiers.COMPILER_GENERATED,
			  name, ParametersCompiled.EmptyReadOnlyParameters, null)
		{
			this.expr = expr;
			Block = new ToplevelBlock (host.Compiler, ParametersCompiled.EmptyReadOnlyParameters, Location.Null);
		}

		public override EmitContext CreateEmitContext (ILGenerator ig, SourceMethodBuilder sourceMethod)
		{
			EmitContext ec = new EmitContext (this, ig, MemberType, sourceMethod);
			ec.CurrentAnonymousMethod = expr;

			if (expr is AsyncInitializer)
				ec.With (BuilderContext.Options.AsyncBody, true);

			return ec;
		}
	}

	public abstract class StateMachineInitializer : AnonymousExpression
	{
		sealed class MoveNextBodyStatement : Statement
		{
			readonly StateMachineInitializer state_machine;

			public MoveNextBodyStatement (StateMachineInitializer stateMachine)
			{
				this.state_machine = stateMachine;
				this.loc = stateMachine.Location;
			}

			protected override void CloneTo (CloneContext clonectx, Statement target)
			{
				throw new NotSupportedException ();
			}

			public override bool Resolve (BlockContext ec)
			{
				return true;
			}

			protected override void DoEmit (EmitContext ec)
			{
				state_machine.EmitMoveNext (ec);
			}

			public override void Emit (EmitContext ec)
			{
				// Don't create sequence point
				DoEmit (ec);
			}
		}

		public readonly TypeDefinition Host;
		protected StateMachine storey;

		//
		// The state as we generate the machine
		//
		Label move_next_ok;
		Label iterator_body_end;
		protected Label move_next_error;
		LocalBuilder skip_finally;
		protected LocalBuilder current_pc;
		protected List<ResumableStatement> resume_points;

		protected StateMachineInitializer (ParametersBlock block, TypeDefinition host, TypeSpec returnType)
			: base (block, returnType, block.StartLocation)
		{
			this.Host = host;
		}

		#region Properties

		public Label BodyEnd {
			get {
				return iterator_body_end;
			}
		}

		public LocalBuilder CurrentPC
		{
			get {
				return current_pc;
			}
		}

		public LocalBuilder SkipFinally {
			get {
				return skip_finally;
			}
		}

		public override AnonymousMethodStorey Storey {
			get {
				return storey;
			}
		}

		#endregion

		public int AddResumePoint (ResumableStatement stmt)
		{
			if (resume_points == null)
				resume_points = new List<ResumableStatement> ();

			resume_points.Add (stmt);
			return resume_points.Count;
		}

		public override Expression CreateExpressionTree (ResolveContext ec)
		{
			throw new NotSupportedException ("ET");
		}

		protected virtual BlockContext CreateBlockContext (ResolveContext rc)
		{
			var ctx = new BlockContext (rc, block, ((BlockContext) rc).ReturnType);
			ctx.CurrentAnonymousMethod = this;
			return ctx;
		}

		protected override Expression DoResolve (ResolveContext ec)
		{
			var ctx = CreateBlockContext (ec);

			Block.Resolve (ctx);

			//
			// Explicit return is required for Task<T> state machine
			//
			var task_storey = storey as AsyncTaskStorey;
			if (task_storey == null || (task_storey.ReturnType != null && !task_storey.ReturnType.IsGenericTask))
				ctx.CurrentBranching.CurrentUsageVector.Goto ();

			ctx.EndFlowBranching ();

			if (!ec.IsInProbingMode) {
				var move_next = new StateMachineMethod (storey, this, new TypeExpression (ReturnType, loc), Modifiers.PUBLIC, new MemberName ("MoveNext", loc));
				move_next.Block.AddStatement (new MoveNextBodyStatement (this));
				storey.AddEntryMethod (move_next);
			}

			eclass = ExprClass.Value;
			return this;
		}

		public override void Emit (EmitContext ec)
		{
			//
			// Load state machine instance
			//
			storey.Instance.Emit (ec);
		}

		void EmitMoveNext_NoResumePoints (EmitContext ec)
		{
			ec.EmitThis ();
			ec.Emit (OpCodes.Ldfld, storey.PC.Spec);

			ec.EmitThis ();
			ec.EmitInt ((int) IteratorStorey.State.After);
			ec.Emit (OpCodes.Stfld, storey.PC.Spec);

			// We only care if the PC is zero (start executing) or non-zero (don't do anything)
			ec.Emit (OpCodes.Brtrue, move_next_error);

			iterator_body_end = ec.DefineLabel ();

			block.EmitEmbedded (ec);

			ec.MarkLabel (iterator_body_end);

			EmitMoveNextEpilogue (ec);

			ec.MarkLabel (move_next_error);

			if (ReturnType.Kind != MemberKind.Void) {
				ec.EmitInt (0);
				ec.Emit (OpCodes.Ret);
			}
		}

		void EmitMoveNext (EmitContext ec)
		{
			move_next_ok = ec.DefineLabel ();
			move_next_error = ec.DefineLabel ();

			if (resume_points == null) {
				EmitMoveNext_NoResumePoints (ec);
				return;
			}

			current_pc = ec.GetTemporaryLocal (ec.BuiltinTypes.UInt);
			ec.EmitThis ();
			ec.Emit (OpCodes.Ldfld, storey.PC.Spec);
			ec.Emit (OpCodes.Stloc, current_pc);

			// We're actually in state 'running', but this is as good a PC value as any if there's an abnormal exit
			ec.EmitThis ();
			ec.EmitInt ((int) IteratorStorey.State.After);
			ec.Emit (OpCodes.Stfld, storey.PC.Spec);

			Label[] labels = new Label[1 + resume_points.Count];
			labels[0] = ec.DefineLabel ();

			bool need_skip_finally = false;
			for (int i = 0; i < resume_points.Count; ++i) {
				ResumableStatement s = resume_points[i];
				need_skip_finally |= s is ExceptionStatement;
				labels[i + 1] = s.PrepareForEmit (ec);
			}

			if (need_skip_finally) {
				skip_finally = ec.GetTemporaryLocal (ec.BuiltinTypes.Bool);
				ec.EmitInt (0);
				ec.Emit (OpCodes.Stloc, skip_finally);
			}

			var async_init = this as AsyncInitializer;
			if (async_init != null)
				ec.BeginExceptionBlock ();

			ec.Emit (OpCodes.Ldloc, current_pc);
			ec.Emit (OpCodes.Switch, labels);

			ec.Emit (async_init != null ? OpCodes.Leave : OpCodes.Br, move_next_error);

			ec.MarkLabel (labels[0]);

			iterator_body_end = ec.DefineLabel ();

			block.EmitEmbedded (ec);

			ec.MarkLabel (iterator_body_end);

			if (async_init != null) {
				var catch_value = LocalVariable.CreateCompilerGenerated (ec.Module.Compiler.BuiltinTypes.Exception, block, Location);

				ec.BeginCatchBlock (catch_value.Type);
				catch_value.EmitAssign (ec);

				ec.EmitThis ();
				ec.EmitInt ((int) IteratorStorey.State.After);
				ec.Emit (OpCodes.Stfld, storey.PC.Spec);

				((AsyncTaskStorey) async_init.Storey).EmitSetException (ec, new LocalVariableReference (catch_value, Location));

				ec.Emit (OpCodes.Leave, move_next_ok);
				ec.EndExceptionBlock ();
			}

			ec.Mark (Block.Original.EndLocation);
			ec.EmitThis ();
			ec.EmitInt ((int) IteratorStorey.State.After);
			ec.Emit (OpCodes.Stfld, storey.PC.Spec);

			EmitMoveNextEpilogue (ec);

			ec.MarkLabel (move_next_error);

			if (ReturnType.Kind != MemberKind.Void) {
				ec.EmitInt (0);
				ec.Emit (OpCodes.Ret);
			}

			ec.MarkLabel (move_next_ok);

			if (ReturnType.Kind != MemberKind.Void) {
				ec.EmitInt (1);
				ec.Emit (OpCodes.Ret);
			}
		}

		protected virtual void EmitMoveNextEpilogue (EmitContext ec)
		{
		}

		public void EmitLeave (EmitContext ec, bool unwind_protect)
		{
			// Return ok
			ec.Emit (unwind_protect ? OpCodes.Leave : OpCodes.Br, move_next_ok);
		}

		//
		// Called back from YieldStatement
		//
		public virtual void InjectYield (EmitContext ec, Expression expr, int resume_pc, bool unwind_protect, Label resume_point)
		{
			//
			// Guard against being disposed meantime
			//
			Label disposed = ec.DefineLabel ();
			var iterator = storey as IteratorStorey;
			if (iterator != null) {
				ec.EmitThis ();
				ec.Emit (OpCodes.Ldfld, iterator.DisposingField.Spec);
				ec.Emit (OpCodes.Brtrue_S, disposed);
			}

			//
			// store resume program-counter
			//
			ec.EmitThis ();
			ec.EmitInt (resume_pc);
			ec.Emit (OpCodes.Stfld, storey.PC.Spec);

			if (iterator != null) {
				ec.MarkLabel (disposed);
			}

			// mark finally blocks as disabled
			if (unwind_protect && skip_finally != null) {
				ec.EmitInt (1);
				ec.Emit (OpCodes.Stloc, skip_finally);
			}
		}

		public void SetStateMachine (StateMachine stateMachine)
		{
			this.storey = stateMachine;
		}
	}

	//
	// Iterators are implemented as state machine blocks
	//
	public class Iterator : StateMachineInitializer
	{
		sealed class TryFinallyBlockProxyStatement : Statement
		{
			TryFinallyBlock block;
			Iterator iterator;

			public TryFinallyBlockProxyStatement (Iterator iterator, TryFinallyBlock block)
			{
				this.iterator = iterator;
				this.block = block;
			}

			protected override void CloneTo (CloneContext clonectx, Statement target)
			{
				throw new NotSupportedException ();
			}

			protected override void DoEmit (EmitContext ec)
			{
				//
				// Restore redirection for any captured variables
				//
				ec.CurrentAnonymousMethod = iterator;

				using (ec.With (BuilderContext.Options.OmitDebugInfo, !ec.HasMethodSymbolBuilder)) {
					block.EmitFinallyBody (ec);
				}
			}
		}

		public readonly IMethodData OriginalMethod;
		public readonly bool IsEnumerable;
		public readonly TypeSpec OriginalIteratorType;
		int finally_hosts_counter;

		public Iterator (ParametersBlock block, IMethodData method, TypeDefinition host, TypeSpec iterator_type, bool is_enumerable)
			: base (block, host, host.Compiler.BuiltinTypes.Bool)
		{
			this.OriginalMethod = method;
			this.OriginalIteratorType = iterator_type;
			this.IsEnumerable = is_enumerable;
			this.type = method.ReturnType;
		}

		#region Properties

		public ToplevelBlock Container {
			get { return OriginalMethod.Block; }
		}

		public override string ContainerType {
			get { return "iterator"; }
		}

		public override bool IsIterator {
			get { return true; }
		}

		#endregion

		public Method CreateFinallyHost (TryFinallyBlock block)
		{
			var method = new Method (storey, new TypeExpression (storey.Compiler.BuiltinTypes.Void, loc),
				Modifiers.COMPILER_GENERATED, new MemberName (CompilerGeneratedContainer.MakeName (null, null, "Finally", finally_hosts_counter++), loc),
				ParametersCompiled.EmptyReadOnlyParameters, null);

			method.Block = new ToplevelBlock (method.Compiler, method.ParameterInfo, loc);
			method.Block.IsCompilerGenerated = true;
			method.Block.AddStatement (new TryFinallyBlockProxyStatement (this, block));

			// Cannot it add to storey because it'd be emitted before nested
			// anonoymous methods which could capture shared variable

			return method;
		}

		public void EmitYieldBreak (EmitContext ec, bool unwind_protect)
		{
			ec.Emit (unwind_protect ? OpCodes.Leave : OpCodes.Br, move_next_error);
		}

		public override string GetSignatureForError ()
		{
			return OriginalMethod.GetSignatureForError ();
		}

		public override void Emit (EmitContext ec)
		{
			//
			// Load Iterator storey instance
			//
			storey.Instance.Emit (ec);

			//
			// Initialize iterator PC when it's unitialized
			//
			if (IsEnumerable) {
				ec.Emit (OpCodes.Dup);
				ec.EmitInt ((int)IteratorStorey.State.Uninitialized);

				var field = storey.PC.Spec;
				if (storey.MemberName.IsGeneric) {
					field = MemberCache.GetMember (Storey.Instance.Type, field);
				}

				ec.Emit (OpCodes.Stfld, field);
			}
		}

		public void EmitDispose (EmitContext ec)
		{
			if (resume_points == null)
				return;

			Label end = ec.DefineLabel ();

			Label[] labels = null;
			for (int i = 0; i < resume_points.Count; ++i) {
				ResumableStatement s = resume_points[i];
				Label ret = s.PrepareForDispose (ec, end);
				if (ret.Equals (end) && labels == null)
					continue;
				if (labels == null) {
					labels = new Label[resume_points.Count + 1];
					for (int j = 0; j <= i; ++j)
						labels[j] = end;
				}

				labels[i + 1] = ret;
			}

			if (labels != null) {
				current_pc = ec.GetTemporaryLocal (ec.BuiltinTypes.UInt);
				ec.EmitThis ();
				ec.Emit (OpCodes.Ldfld, storey.PC.Spec);
				ec.Emit (OpCodes.Stloc, current_pc);
			}

			ec.EmitThis ();
			ec.EmitInt (1);
			ec.Emit (OpCodes.Stfld, ((IteratorStorey) storey).DisposingField.Spec);

			ec.EmitThis ();
			ec.EmitInt ((int) IteratorStorey.State.After);
			ec.Emit (OpCodes.Stfld, storey.PC.Spec);

			if (labels != null) {
				//SymbolWriter.StartIteratorDispatcher (ec.ig);
				ec.Emit (OpCodes.Ldloc, current_pc);
				ec.Emit (OpCodes.Switch, labels);
				//SymbolWriter.EndIteratorDispatcher (ec.ig);

				foreach (ResumableStatement s in resume_points)
					s.EmitForDispose (ec, current_pc, end, true);
			}

			ec.MarkLabel (end);
		}

		public override void EmitStatement (EmitContext ec)
		{
			throw new NotImplementedException ();
		}

		public override void InjectYield (EmitContext ec, Expression expr, int resume_pc, bool unwind_protect, Label resume_point)
		{
			// Store the new value into current
			var fe = new FieldExpr (((IteratorStorey) storey).CurrentField, loc);
			fe.InstanceExpression = new CompilerGeneratedThis (storey.CurrentType, loc);
			fe.EmitAssign (ec, expr, false, false);

			base.InjectYield (ec, expr, resume_pc, unwind_protect, resume_point);

			EmitLeave (ec, unwind_protect);

			ec.MarkLabel (resume_point);
		}

		protected override BlockContext CreateBlockContext (ResolveContext rc)
		{
			var bc = base.CreateBlockContext (rc);
			bc.StartFlowBranching (this, rc.CurrentBranching);
			return bc;
		}

		public static void CreateIterator (IMethodData method, TypeDefinition parent, Modifiers modifiers)
		{
			bool is_enumerable;
			TypeSpec iterator_type;

			TypeSpec ret = method.ReturnType;
			if (ret == null)
				return;

			if (!CheckType (ret, parent, out iterator_type, out is_enumerable)) {
				parent.Compiler.Report.Error (1624, method.Location,
					      "The body of `{0}' cannot be an iterator block " +
					      "because `{1}' is not an iterator interface type",
					      method.GetSignatureForError (),
					      TypeManager.CSharpName (ret));
				return;
			}

			ParametersCompiled parameters = method.ParameterInfo;
			for (int i = 0; i < parameters.Count; i++) {
				Parameter p = parameters [i];
				Parameter.Modifier mod = p.ModFlags;
				if ((mod & Parameter.Modifier.RefOutMask) != 0) {
					parent.Compiler.Report.Error (1623, p.Location,
						"Iterators cannot have ref or out parameters");
					return;
				}

				if (p is ArglistParameter) {
					parent.Compiler.Report.Error (1636, method.Location,
						"__arglist is not allowed in parameter list of iterators");
					return;
				}

				if (parameters.Types [i].IsPointer) {
					parent.Compiler.Report.Error (1637, p.Location,
						"Iterators cannot have unsafe parameters or yield types");
					return;
				}
			}

			if ((modifiers & Modifiers.UNSAFE) != 0) {
				parent.Compiler.Report.Error (1629, method.Location, "Unsafe code may not appear in iterators");
			}

			method.Block = method.Block.ConvertToIterator (method, parent, iterator_type, is_enumerable);
		}

		static bool CheckType (TypeSpec ret, TypeContainer parent, out TypeSpec original_iterator_type, out bool is_enumerable)
		{
			original_iterator_type = null;
			is_enumerable = false;

			if (ret.BuiltinType == BuiltinTypeSpec.Type.IEnumerable) {
				original_iterator_type = parent.Compiler.BuiltinTypes.Object;
				is_enumerable = true;
				return true;
			}
			if (ret.BuiltinType == BuiltinTypeSpec.Type.IEnumerator) {
				original_iterator_type = parent.Compiler.BuiltinTypes.Object;
				is_enumerable = false;
				return true;
			}

			InflatedTypeSpec inflated = ret as InflatedTypeSpec;
			if (inflated == null)
				return false;

			var member_definition = inflated.MemberDefinition;
			PredefinedType ptype = parent.Module.PredefinedTypes.IEnumerableGeneric;

			if (ptype.Define () && ptype.TypeSpec.MemberDefinition == member_definition) {
				original_iterator_type = inflated.TypeArguments[0];
				is_enumerable = true;
				return true;
			}

			ptype = parent.Module.PredefinedTypes.IEnumeratorGeneric;
			if (ptype.Define () && ptype.TypeSpec.MemberDefinition == member_definition) {
				original_iterator_type = inflated.TypeArguments[0];
				is_enumerable = false;
				return true;
			}

			return false;
		}
	}
}


text:
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="ChangeListManager">
    <list default="true" id="a097543d-2741-41ed-9d76-855f9af6937c" name="Default" comment="">
      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/app/models.py" afterPath="$PROJECT_DIR$/app/models.py" />
    </list>
    <ignored path="flasky.iws" />
    <ignored path=".idea/workspace.xml" />
    <ignored path=".idea/dataSources.local.xml" />
    <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
    <option name="TRACKING_ENABLED" value="true" />
    <option name="SHOW_DIALOG" value="false" />
    <option name="HIGHLIGHT_CONFLICTS" value="true" />
    <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
    <option name="LAST_RESOLUTION" value="IGNORE" />
  </component>
  <component name="CoverageDataManager">
    <SUITE FILE_PATH="coverage/flasky$flasky.coverage" NAME="flasky Coverage Results" MODIFIED="1485963223140" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="" />
    <SUITE FILE_PATH="coverage/flasky$Unittests_in_flasky.coverage" NAME="Unittests in flasky Coverage Results" MODIFIED="1485963235215" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
    <SUITE FILE_PATH="coverage/flasky$manage.coverage" NAME="manage Coverage Results" MODIFIED="1487748129798" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
  </component>
  <component name="CreatePatchCommitExecutor">
    <option name="PATCH_PATH" value="" />
  </component>
  <component name="DatabaseView">
    <option name="GROUP_SCHEMA" value="true" />
    <option name="GROUP_CONTENTS" value="false" />
    <option name="SORT_POSITIONED" value="false" />
    <option name="SHOW_TABLE_DETAILS" value="true" />
    <option name="SHOW_EMPTY_GROUPS" value="false" />
    <option name="AUTO_SCROLL_FROM_SOURCE" value="false" />
  </component>
  <component name="ExecutionTargetManager" SELECTED_TARGET="default_target" />
  <component name="FavoritesManager">
    <favorites_list name="flasky" />
  </component>
  <component name="FileEditorManager">
    <leaf SIDE_TABS_SIZE_LIMIT_KEY="375">
      <file leaf-file-name="config.py" pinned="false" current-in-tab="false">
        <entry file="file://$PROJECT_DIR$/config.py">
          <provider selected="true" editor-type-id="text-editor">
            <state relative-caret-position="1260">
              <caret line="42" column="25" selection-start-line="42" selection-start-column="25" selection-end-line="42" selection-end-column="25" />
              <folding />
            </state>
          </provider>
        </entry>
      </file>
      <file leaf-file-name="decorators.py" pinned="false" current-in-tab="false">
        <entry file="file://$PROJECT_DIR$/app/decorators.py">
          <provider selected="true" editor-type-id="text-editor">
            <state relative-caret-position="270">
              <caret line="12" column="37" selection-start-line="12" selection-start-column="37" selection-end-line="12" selection-end-column="37" />
              <folding>
                <element signature="e#0#27#0" expanded="true" />
              </folding>
            </state>
          </provider>
        </entry>
      </file>
      <file leaf-file-name="email.py" pinned="false" current-in-tab="false">
        <entry file="file://$PROJECT_DIR$/app/email.py">
          <provider selected="true" editor-type-id="text-editor">
            <state relative-caret-position="90">
              <caret line="6" column="31" selection-start-line="6" selection-start-column="31" selection-end-line="6" selection-end-column="31" />
              <folding />
            </state>
          </provider>
        </entry>
      </file>
      <file leaf-file-name="models.py" pinned="false" current-in-tab="false">
        <entry file="file://$PROJECT_DIR$/app/models.py">
          <provider selected="true" editor-type-id="text-editor">
            <state relative-caret-position="6780">
              <caret line="234" column="55" selection-start-line="234" selection-start-column="55" selection-end-line="234" selection-end-column="55" />
              <folding />
            </state>
          </provider>
        </entry>
      </file>
      <file leaf-file-name="manage.py" pinned="false" current-in-tab="false">
        <entry file="file://$PROJECT_DIR$/manage.py">
          <provider selected="true" editor-type-id="text-editor">
            <state relative-caret-position="480">
              <caret line="20" column="11" selection-start-line="20" selection-start-column="11" selection-end-line="20" selection-end-column="11" />
              <folding />
            </state>
          </provider>
        </entry>
      </file>
      <file leaf-file-name="__init__.py" pinned="false" current-in-tab="true">
        <entry file="file://$PROJECT_DIR$/app/__init__.py">
          <provider selected="true" editor-type-id="text-editor">
            <state relative-caret-position="120">
              <caret line="11" column="17" selection-start-line="11" selection-start-column="17" selection-end-line="11" selection-end-column="17" />
              <folding />
            </state>
          </provider>
        </entry>
      </file>
      <file leaf-file-name="index.html" pinned="false" current-in-tab="false">
        <entry file="file://$PROJECT_DIR$/app/templates/index.html">
          <provider selected="true" editor-type-id="text-editor">
            <state relative-caret-position="300">
              <caret line="10" column="5" selection-start-line="10" selection-start-column="5" selection-end-line="10" selection-end-column="5" />
              <folding />
            </state>
          </provider>
        </entry>
      </file>
      <file leaf-file-name="forms.py" pinned="false" current-in-tab="false">
        <entry file="file://$PROJECT_DIR$/app/auth/forms.py">
          <provider selected="true" editor-type-id="text-editor">
            <state relative-caret-position="2040">
              <caret line="72" column="0" selection-start-line="62" selection-start-column="0" selection-end-line="72" selection-end-column="0" />
              <folding>
                <element signature="e#0#31#0" expanded="true" />
              </folding>
            </state>
          </provider>
        </entry>
      </file>
      <file leaf-file-name="views.py" pinned="false" current-in-tab="false">
        <entry file="file://$PROJECT_DIR$/app/auth/views.py">
          <provider selected="true" editor-type-id="text-editor">
            <state relative-caret-position="2340">
              <caret line="86" column="0" selection-start-line="86" selection-start-column="0" selection-end-line="86" selection-end-column="0" />
              <folding>
                <element signature="e#0#68#0" expanded="true" />
              </folding>
            </state>
          </provider>
        </entry>
      </file>
      <file leaf-file-name="errors.py" pinned="false" current-in-tab="false">
        <entry file="file://$PROJECT_DIR$/app/main/errors.py">
          <provider selected="true" editor-type-id="text-editor">
            <state relative-caret-position="210">
              <caret line="8" column="0" selection-start-line="8" selection-start-column="0" selection-end-line="8" selection-end-column="0" />
              <folding />
            </state>
          </provider>
        </entry>
      </file>
    </leaf>
  </component>
  <component name="Git.Settings">
    <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
  </component>
  <component name="IdeDocumentHistory">
    <option name="CHANGED_PATHS">
      <list>
        <option value="$PROJECT_DIR$/app/main/forms.py" />
        <option value="$PROJECT_DIR$/app/auth/views.py" />
        <option value="$PROJECT_DIR$/config.py" />
        <option value="$PROJECT_DIR$/app/templates/index.html" />
        <option value="$PROJECT_DIR$/app/models.py" />
      </list>
    </option>
  </component>
  <component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
  <component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER" />
  <component name="JsGulpfileManager">
    <detection-done>true</detection-done>
    <sorting>DEFINITION_ORDER</sorting>
  </component>
  <component name="ProjectFrameBounds">
    <option name="x" value="952" />
    <option name="width" value="976" />
    <option name="height" value="1038" />
  </component>
  <component name="ProjectInspectionProfilesVisibleTreeState">
    <entry key="Project Default">
      <profile-state>
        <expanded-state>
          <State>
            <id />
          </State>
          <State>
            <id>DOM issuesJavaScript</id>
          </State>
          <State>
            <id>HTML</id>
          </State>
          <State>
            <id>JavaScript</id>
          </State>
          <State>
            <id>Python</id>
          </State>
        </expanded-state>
        <selected-state>
          <State>
            <id>AngularJS</id>
          </State>
        </selected-state>
      </profile-state>
    </entry>
  </component>
  <component name="ProjectLevelVcsManager" settingsEditedManually="false">
    <OptionsSetting value="true" id="Add" />
    <OptionsSetting value="true" id="Remove" />
    <OptionsSetting value="true" id="Checkout" />
    <OptionsSetting value="true" id="Update" />
    <OptionsSetting value="true" id="Status" />
    <OptionsSetting value="true" id="Edit" />
    <ConfirmationsSetting value="0" id="Add" />
    <ConfirmationsSetting value="0" id="Remove" />
  </component>
  <component name="ProjectView">
    <navigator currentView="ProjectPane" proportions="" version="1">
      <flattenPackages />
      <showMembers />
      <showModules />
      <showLibraryContents />
      <hideEmptyPackages />
      <abbreviatePackageNames />
      <autoscrollToSource />
      <autoscrollFromSource />
      <sortByType />
      <manualOrder />
      <foldersAlwaysOnTop value="true" />
    </navigator>
    <panes>
      <pane id="Scope" />
      <pane id="Scratches" />
      <pane id="ProjectPane">
        <subPane />
      </pane>
    </panes>
  </component>
  <component name="PropertiesComponent">
    <property name="settings.editor.selected.configurable" value="preferences.pluginManager" />
    <property name="settings.editor.splitter.proportion" value="0.2" />
    <property name="WebServerToolWindowFactoryState" value="false" />
    <property name="SearchEverywhereHistoryKey" value="mail	FILE	file://G:/GithubProjects/flasky/app/email.py
send	null	null
sendmail	null	null
image 	ACTION	Images.SetBackgroundImage
Background Image	ACTION	Images.SetBackgroundImage
image	ACTION	Images.SetBackgroundImage
background	ACTION	BackgroundTasks" />
  </component>
  <component name="PyConsoleOptionsProvider">
    <option name="myPythonConsoleState">
      <console-settings sdk-home="D:\python2.7\python.exe">
        <option name="mySdkHome" value="D:\python2.7\python.exe" />
      </console-settings>
    </option>
  </component>
  <component name="RunManager" selected="Python.manage">
    <configuration default="false" name="Unittests in flasky" type="tests" factoryName="Unittests" temporary="true" nameIsGenerated="true">
      <option name="INTERPRETER_OPTIONS" value="" />
      <option name="PARENT_ENVS" value="true" />
      <envs />
      <option name="SDK_HOME" value="" />
      <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
      <option name="IS_MODULE_SDK" value="true" />
      <option name="ADD_CONTENT_ROOTS" value="true" />
      <option name="ADD_SOURCE_ROOTS" value="true" />
      <module name="flasky" />
      <EXTENSION ID="PythonCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" runner="coverage.py" />
      <option name="SCRIPT_NAME" value="" />
      <option name="CLASS_NAME" value="" />
      <option name="METHOD_NAME" value="" />
      <option name="FOLDER_NAME" value="$PROJECT_DIR$" />
      <option name="TEST_TYPE" value="TEST_FOLDER" />
      <option name="PATTERN" value="" />
      <option name="USE_PATTERN" value="false" />
      <option name="PUREUNITTEST" value="true" />
      <option name="PARAMS" value="" />
      <option name="USE_PARAM" value="false" />
      <method />
    </configuration>
    <configuration default="false" name="manage" type="PythonConfigurationType" factoryName="Python" temporary="true">
      <option name="INTERPRETER_OPTIONS" value="" />
      <option name="PARENT_ENVS" value="true" />
      <envs>
        <env name="PYTHONUNBUFFERED" value="1" />
      </envs>
      <option name="SDK_HOME" value="" />
      <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
      <option name="IS_MODULE_SDK" value="true" />
      <option name="ADD_CONTENT_ROOTS" value="true" />
      <option name="ADD_SOURCE_ROOTS" value="true" />
      <module name="flasky" />
      <EXTENSION ID="PythonCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" runner="coverage.py" />
      <option name="SCRIPT_NAME" value="$PROJECT_DIR$/manage.py" />
      <option name="PARAMETERS" value="" />
      <option name="SHOW_COMMAND_LINE" value="false" />
      <method />
    </configuration>
    <configuration default="true" type="DjangoTestsConfigurationType" factoryName="Django tests">
      <option name="INTERPRETER_OPTIONS" value="" />
      <option name="PARENT_ENVS" value="true" />
      <envs>
        <env name="PYTHONUNBUFFERED" value="1" />
      </envs>
      <option name="SDK_HOME" value="" />
      <option name="WORKING_DIRECTORY" value="" />
      <option name="IS_MODULE_SDK" value="false" />
      <option name="ADD_CONTENT_ROOTS" value="true" />
      <option name="ADD_SOURCE_ROOTS" value="true" />
      <module name="flasky" />
      <EXTENSION ID="PythonCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" runner="coverage.py" />
      <option name="TARGET" value="" />
      <option name="SETTINGS_FILE" value="" />
      <option name="CUSTOM_SETTINGS" value="false" />
      <option name="USE_OPTIONS" value="false" />
      <option name="OPTIONS" value="" />
      <method />
    </configuration>
    <configuration default="true" type="JavascriptDebugType" factoryName="JavaScript Debug">
      <method />
    </configuration>
    <configuration default="true" type="PyBehaveRunConfigurationType" factoryName="Behave">
      <option name="INTERPRETER_OPTIONS" value="" />
      <option name="PARENT_ENVS" value="true" />
      <envs />
      <option name="SDK_HOME" value="" />
      <option name="WORKING_DIRECTORY" value="" />
      <option name="IS_MODULE_SDK" value="false" />
      <option name="ADD_CONTENT_ROOTS" value="true" />
      <option name="ADD_SOURCE_ROOTS" value="true" />
      <module name="flasky" />
      <EXTENSION ID="PythonCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" runner="coverage.py" />
      <option name="ADDITIONAL_ARGS" value="" />
      <method />
    </configuration>
    <configuration default="true" type="PyLettuceRunConfigurationType" factoryName="Lettuce">
      <option name="INTERPRETER_OPTIONS" value="" />
      <option name="PARENT_ENVS" value="true" />
      <envs />
      <option name="SDK_HOME" value="" />
      <option name="WORKING_DIRECTORY" value="" />
      <option name="IS_MODULE_SDK" value="false" />
      <option name="ADD_CONTENT_ROOTS" value="true" />
      <option name="ADD_SOURCE_ROOTS" value="true" />
      <module name="flasky" />
      <EXTENSION ID="PythonCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" runner="coverage.py" />
      <option name="ADDITIONAL_ARGS" value="" />
      <method />
    </configuration>
    <configuration default="true" type="PythonConfigurationType" factoryName="Python">
      <option name="INTERPRETER_OPTIONS" value="" />
      <option name="PARENT_ENVS" value="true" />
      <envs>
        <env name="PYTHONUNBUFFERED" value="1" />
      </envs>
      <option name="SDK_HOME" value="" />
      <option name="WORKING_DIRECTORY" value="" />
      <option name="IS_MODULE_SDK" value="false" />
      <option name="ADD_CONTENT_ROOTS" value="true" />
      <option name="ADD_SOURCE_ROOTS" value="true" />
      <module name="flasky" />
      <EXTENSION ID="PythonCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" runner="coverage.py" />
      <option name="SCRIPT_NAME" value="" />
      <option name="PARAMETERS" value="" />
      <option name="SHOW_COMMAND_LINE" value="false" />
      <method />
    </configuration>
    <configuration default="true" type="Tox" factoryName="Tox">
      <option name="INTERPRETER_OPTIONS" value="" />
      <option name="PARENT_ENVS" value="true" />
      <envs />
      <option name="SDK_HOME" value="" />
      <option name="WORKING_DIRECTORY" value="" />
      <option name="IS_MODULE_SDK" value="false" />
      <option name="ADD_CONTENT_ROOTS" value="true" />
      <option name="ADD_SOURCE_ROOTS" value="true" />
      <EXTENSION ID="PythonCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" runner="coverage.py" />
      <module name="flasky" />
      <method />
    </configuration>
    <configuration default="true" type="js.build_tools.gulp" factoryName="Gulp.js">
      <node-interpreter>project</node-interpreter>
      <node-options />
      <gulpfile />
      <tasks />
      <arguments />
      <envs />
      <method />
    </configuration>
    <configuration default="true" type="js.build_tools.npm" factoryName="npm">
      <command value="run-script" />
      <scripts />
      <node-interpreter value="project" />
      <envs />
      <method />
    </configuration>
    <configuration default="true" type="tests" factoryName="Attests">
      <option name="INTERPRETER_OPTIONS" value="" />
      <option name="PARENT_ENVS" value="true" />
      <envs />
      <option name="SDK_HOME" value="" />
      <option name="WORKING_DIRECTORY" value="" />
      <option name="IS_MODULE_SDK" value="false" />
      <option name="ADD_CONTENT_ROOTS" value="true" />
      <option name="ADD_SOURCE_ROOTS" value="true" />
      <module name="flasky" />
      <EXTENSION ID="PythonCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" runner="coverage.py" />
      <option name="SCRIPT_NAME" value="" />
      <option name="CLASS_NAME" value="" />
      <option name="METHOD_NAME" value="" />
      <option name="FOLDER_NAME" value="" />
      <option name="TEST_TYPE" value="TEST_SCRIPT" />
      <option name="PATTERN" value="" />
      <option name="USE_PATTERN" value="false" />
      <method />
    </configuration>
    <configuration default="true" type="tests" factoryName="Doctests">
      <option name="INTERPRETER_OPTIONS" value="" />
      <option name="PARENT_ENVS" value="true" />
      <envs />
      <option name="SDK_HOME" value="" />
      <option name="WORKING_DIRECTORY" value="" />
      <option name="IS_MODULE_SDK" value="false" />
      <option name="ADD_CONTENT_ROOTS" value="true" />
      <option name="ADD_SOURCE_ROOTS" value="true" />
      <module name="flasky" />
      <EXTENSION ID="PythonCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" runner="coverage.py" />
      <option name="SCRIPT_NAME" value="" />
      <option name="CLASS_NAME" value="" />
      <option name="METHOD_NAME" value="" />
      <option name="FOLDER_NAME" value="" />
      <option name="TEST_TYPE" value="TEST_SCRIPT" />
      <option name="PATTERN" value="" />
      <option name="USE_PATTERN" value="false" />
      <method />
    </configuration>
    <configuration default="true" type="tests" factoryName="Nosetests">
      <option name="INTERPRETER_OPTIONS" value="" />
      <option name="PARENT_ENVS" value="true" />
      <envs />
      <option name="SDK_HOME" value="" />
      <option name="WORKING_DIRECTORY" value="" />
      <option name="IS_MODULE_SDK" value="false" />
      <option name="ADD_CONTENT_ROOTS" value="true" />
      <option name="ADD_SOURCE_ROOTS" value="true" />
      <module name="flasky" />
      <EXTENSION ID="PythonCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" runner="coverage.py" />
      <option name="SCRIPT_NAME" value="" />
      <option name="CLASS_NAME" value="" />
      <option name="METHOD_NAME" value="" />
      <option name="FOLDER_NAME" value="" />
      <option name="TEST_TYPE" value="TEST_SCRIPT" />
      <option name="PATTERN" value="" />
      <option name="USE_PATTERN" value="false" />
      <option name="PARAMS" value="" />
      <option name="USE_PARAM" value="false" />
      <method />
    </configuration>
    <configuration default="true" type="tests" factoryName="Unittests">
      <option name="INTERPRETER_OPTIONS" value="" />
      <option name="PARENT_ENVS" value="true" />
      <envs />
      <option name="SDK_HOME" value="" />
      <option name="WORKING_DIRECTORY" value="" />
      <option name="IS_MODULE_SDK" value="false" />
      <option name="ADD_CONTENT_ROOTS" value="true" />
      <option name="ADD_SOURCE_ROOTS" value="true" />
      <module name="flasky" />
      <EXTENSION ID="PythonCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" runner="coverage.py" />
      <option name="SCRIPT_NAME" value="" />
      <option name="CLASS_NAME" value="" />
      <option name="METHOD_NAME" value="" />
      <option name="FOLDER_NAME" value="" />
      <option name="TEST_TYPE" value="TEST_SCRIPT" />
      <option name="PATTERN" value="" />
      <option name="USE_PATTERN" value="false" />
      <option name="PUREUNITTEST" value="true" />
      <option name="PARAMS" value="" />
      <option name="USE_PARAM" value="false" />
      <method />
    </configuration>
    <configuration default="true" type="tests" factoryName="py.test">
      <option name="INTERPRETER_OPTIONS" value="" />
      <option name="PARENT_ENVS" value="true" />
      <envs />
      <option name="SDK_HOME" value="" />
      <option name="WORKING_DIRECTORY" value="" />
      <option name="IS_MODULE_SDK" value="false" />
      <option name="ADD_CONTENT_ROOTS" value="true" />
      <option name="ADD_SOURCE_ROOTS" value="true" />
      <module name="flasky" />
      <EXTENSION ID="PythonCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" runner="coverage.py" />
      <option name="SCRIPT_NAME" value="" />
      <option name="CLASS_NAME" value="" />
      <option name="METHOD_NAME" value="" />
      <option name="FOLDER_NAME" value="" />
      <option name="TEST_TYPE" value="TEST_SCRIPT" />
      <option name="PATTERN" value="" />
      <option name="USE_PATTERN" value="false" />
      <option name="testToRun" value="" />
      <option name="keywords" value="" />
      <option name="params" value="" />
      <option name="USE_PARAM" value="false" />
      <option name="USE_KEYWORD" value="false" />
      <method />
    </configuration>
    <configuration default="false" name="flasky" type="PythonConfigurationType" factoryName="Python" singleton="true">
      <option name="INTERPRETER_OPTIONS" value="" />
      <option name="PARENT_ENVS" value="true" />
      <envs>
        <env name="PYTHONUNBUFFERED" value="1" />
      </envs>
      <option name="SDK_HOME" value="" />
      <option name="WORKING_DIRECTORY" value="" />
      <option name="IS_MODULE_SDK" value="false" />
      <option name="ADD_CONTENT_ROOTS" value="true" />
      <option name="ADD_SOURCE_ROOTS" value="true" />
      <module name="flasky" />
      <EXTENSION ID="PythonCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" runner="coverage.py" />
      <option name="SCRIPT_NAME" value="$PROJECT_DIR$/app/__init__.py" />
      <option name="PARAMETERS" value="" />
      <option name="SHOW_COMMAND_LINE" value="false" />
      <method />
    </configuration>
    <list size="3">
      <item index="0" class="java.lang.String" itemvalue="Python.flasky" />
      <item index="1" class="java.lang.String" itemvalue="Python tests.Unittests in flasky" />
      <item index="2" class="java.lang.String" itemvalue="Python.manage" />
    </list>
    <recent_temporary>
      <list size="2">
        <item index="0" class="java.lang.String" itemvalue="Python.manage" />
        <item index="1" class="java.lang.String" itemvalue="Python tests.Unittests in flasky" />
      </list>
    </recent_temporary>
  </component>
  <component name="ShelveChangesManager" show_recycled="false">
    <option name="remove_strategy" value="false" />
  </component>
  <component name="SvnConfiguration">
    <configuration />
  </component>
  <component name="TaskManager">
    <task active="true" id="Default" summary="Default task">
      <changelist id="a097543d-2741-41ed-9d76-855f9af6937c" name="Default" comment="" />
      <created>1485866596781</created>
      <option name="number" value="Default" />
      <option name="presentableId" value="Default" />
      <updated>1485866596781</updated>
    </task>
    <servers />
  </component>
  <component name="TestHistory">
    <history-entry file="Unittests_in_flasky - 2017.02.01 at 23h 33m 57s.xml">
      <configuration name="Unittests in flasky" configurationId="tests" />
    </history-entry>
  </component>
  <component name="ToolWindowManager">
    <frame x="952" y="0" width="976" height="1038" extended-state="0" />
    <editor active="true" />
    <layout>
      <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.37694013" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" x="680" y="209" width="560" height="611" />
      <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
      <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="true" content_ui="tabs" />
      <window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3299356" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
      <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3295583" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
      <window_info id="Python Console" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3295583" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
      <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="true" content_ui="tabs" />
      <window_info id="Mongo Explorer" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3299356" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
      <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="SLIDING" type="SLIDING" visible="false" show_stripe_button="true" weight="0.33295584" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
      <window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="true" content_ui="tabs" />
      <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3238958" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
      <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="SLIDING" type="SLIDING" visible="false" show_stripe_button="true" weight="0.3295583" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
      <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32930845" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
    </layout>
  </component>
  <component name="Vcs.Log.UiProperties">
    <option name="RECENTLY_FILTERED_USER_GROUPS">
      <collection />
    </option>
    <option name="RECENTLY_FILTERED_BRANCH_GROUPS">
      <collection />
    </option>
  </component>
  <component name="VcsContentAnnotationSettings">
    <option name="myLimit" value="2678400000" />
  </component>
  <component name="XDebuggerManager">
    <breakpoint-manager />
    <watches-manager />
  </component>
  <component name="editorHistoryManager">
    <entry file="file://D:/python2.7/Lib/site-packages/openpyxl/chartsheet/relation.py">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="0">
          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/app/main/__init__.py">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="0">
          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/manage.py">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="480">
          <caret line="20" column="29" selection-start-line="20" selection-start-column="29" selection-end-line="20" selection-end-column="29" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/app/models.py">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="0">
          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/app/main/__init__.py">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="0">
          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/manage.py">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="480">
          <caret line="20" column="29" selection-start-line="20" selection-start-column="29" selection-end-line="20" selection-end-column="29" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/app/models.py">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="0">
          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/app/main/__init__.py">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="0">
          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/manage.py">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="600">
          <caret line="20" column="29" selection-start-line="20" selection-start-column="29" selection-end-line="20" selection-end-column="29" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/app/models.py">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="0">
          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/app/main/__init__.py">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="0">
          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/manage.py">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="0">
          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/app/main/__init__.py">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="0">
          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/manage.py">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="330">
          <caret line="11" column="0" selection-start-line="11" selection-start-column="0" selection-end-line="11" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/app/__init__.py">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="0">
          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/data-test.sqlite">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="0">
          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/LICENSE">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="0">
          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/migrations/env.py">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="0">
          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/migrations/README">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="0">
          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://D:/python2.7/Lib/site-packages/openpyxl/chartsheet/relation.py">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="300">
          <caret line="18" column="0" selection-start-line="18" selection-start-column="0" selection-end-line="18" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/README.md">
      <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
        <state split_layout="SPLIT">
          <first_editor relative-caret-position="0">
            <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
          </first_editor>
          <second_editor />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/app/templates/mail/new_user.txt">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="0">
          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/app/templates/404.html">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="0">
          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/app/templates/403.html">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="0">
          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/app/templates/mail/new_user.html">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="0">
          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/app/templates/auth/email/confirm.html">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="240">
          <caret line="8" column="0" selection-start-line="8" selection-start-column="0" selection-end-line="8" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/app/templates/auth/email/confirm.txt">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="-10">
          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/app/templates/auth/email/change_email.html">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="210">
          <caret line="7" column="0" selection-start-line="7" selection-start-column="0" selection-end-line="7" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/app/main/__init__.py">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="240">
          <caret line="8" column="0" selection-start-line="8" selection-start-column="0" selection-end-line="8" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://D:/python2.7/Lib/site-packages/flask_login.py">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="-3840">
          <caret line="46" column="0" selection-start-line="46" selection-start-column="0" selection-end-line="46" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/app/auth/__init__.py">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="0">
          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://D:/python2.7/Lib/site-packages/scapy/contrib/send.py">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="0">
          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://D:/python2.7/Lib/smtplib.py">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="283">
          <caret line="653" column="8" selection-start-line="653" selection-start-column="8" selection-end-line="653" selection-end-column="8" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/app/main/views.py">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="2820">
          <caret line="104" column="55" selection-start-line="104" selection-start-column="55" selection-end-line="104" selection-end-column="55" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/app/main/forms.py">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="450">
          <caret line="21" column="32" selection-start-line="21" selection-start-column="32" selection-end-line="21" selection-end-column="32" />
        </state>
      </provider>
    </entry>
    <entry file="file://D:/python2.7/Lib/site-packages/flask/helpers.py">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="4183">
          <caret line="362" column="4" selection-start-line="362" selection-start-column="4" selection-end-line="362" selection-end-column="4" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/data-dev.sqlite">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="450">
          <caret line="15" column="1023" selection-start-line="15" selection-start-column="1023" selection-end-line="15" selection-end-column="1023" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/app/email.py">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="90">
          <caret line="6" column="31" selection-start-line="6" selection-start-column="31" selection-end-line="6" selection-end-column="31" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/app/templates/_posts.html">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="-90">
          <caret line="7" column="14" selection-start-line="7" selection-start-column="14" selection-end-line="7" selection-end-column="14" />
        </state>
      </provider>
    </entry>
    <entry file="file://D:/python2.7/Lib/site-packages/flask_migrate/__init__.py">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="-17">
          <caret line="83" column="0" selection-start-line="83" selection-start-column="0" selection-end-line="83" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://D:/python2.7/Lib/site-packages/itsdangerous.py">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="583">
          <caret line="778" column="8" selection-start-line="778" selection-start-column="8" selection-end-line="778" selection-end-column="8" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/tests/test_user_model.py">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="283">
          <caret line="85" column="52" selection-start-line="85" selection-start-column="52" selection-end-line="85" selection-end-column="52" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/app/models.py">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="6780">
          <caret line="234" column="55" selection-start-line="234" selection-start-column="55" selection-end-line="234" selection-end-column="55" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/app/decorators.py">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="270">
          <caret line="12" column="37" selection-start-line="12" selection-start-column="37" selection-end-line="12" selection-end-column="37" />
          <folding>
            <element signature="e#0#27#0" expanded="true" />
          </folding>
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/config.py">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="1260">
          <caret line="42" column="25" selection-start-line="42" selection-start-column="25" selection-end-line="42" selection-end-column="25" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/manage.py">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="480">
          <caret line="20" column="11" selection-start-line="20" selection-start-column="11" selection-end-line="20" selection-end-column="11" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/app/__init__.py">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="120">
          <caret line="11" column="17" selection-start-line="11" selection-start-column="17" selection-end-line="11" selection-end-column="17" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/app/templates/index.html">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="300">
          <caret line="10" column="5" selection-start-line="10" selection-start-column="5" selection-end-line="10" selection-end-column="5" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/app/auth/forms.py">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="2040">
          <caret line="72" column="0" selection-start-line="62" selection-start-column="0" selection-end-line="72" selection-end-column="0" />
          <folding>
            <element signature="e#0#31#0" expanded="true" />
          </folding>
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/app/auth/views.py">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="2340">
          <caret line="86" column="0" selection-start-line="86" selection-start-column="0" selection-end-line="86" selection-end-column="0" />
          <folding>
            <element signature="e#0#68#0" expanded="true" />
          </folding>
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/app/main/errors.py">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="210">
          <caret line="8" column="0" selection-start-line="8" selection-start-column="0" selection-end-line="8" selection-end-column="0" />
          <folding />
        </state>
      </provider>
    </entry>
  </component>
  <component name="masterDetails">
    <states>
      <state key="ScopeChooserConfigurable.UI">
        <settings>
          <splitter-proportions>
            <option name="proportions">
              <list>
                <option value="0.2" />
              </list>
            </option>
          </splitter-proportions>
        </settings>
      </state>
    </states>
  </component>
</project>

redpajama_set_name: RedPajamaGithub


text:
#ifndef LIBGREETING_H_INCLUDED
#define LIBGREETING_H_INCLUDED

char * greeting(char const * suffix);

#endif /* LIBGREETING_H_INCLUDED */


text:
using System;

namespace Samurai.Graphics
{
	public enum ShaderType
	{
		Vertex,

		Fragment
	}
}


text:
Please review the [guidelines for contributing](../CONTRIBUTING.md) to this repository.

- [ ] Make sure you are requesting to **pull a feature/bugfix branch** (right side). Don't request your master!
- [ ] Make sure tests pass and coverage has not fallen `docker-compose run --rm test`.
- [ ] Update the [CHANGELOG.md](../CHANGELOG.md) to describe your changes in a bulleted list under the "Development" section at the top of the changelog. If this section does not exist, create it.
- [ ] Make sure code style follows PEP 008 using `docker-compose run --rm blacken`.
- [ ] Make sure that new functions and classes have inline docstrings and are
  included in [docs/api.rst](../docs/api.rst) for the sphinx build. Please use [numpy-style docstrings](https://www.sphinx-doc.org/en/master/usage/extensions/napoleon.html#google-vs-numpy).
  Sphinx docs can be built with the following command: `docker-compose run --rm --entrypoint="make -C docs html" shell`. Please note and fix any warnings.
- [ ] Make sure that all git commits are have the "Signed-off-by" message for
  the Developer Certificate of Origin. When you're making a commit, just add
  the `-s/--signoff` flag (e.g., `git commit -s`).

### Description

Please describe your pull request.


text:
import React, { Component } from 'react';
import AppBar from 'material-ui/AppBar';
import AppMenuIcon from './AppMenuIcon';
import Loading from './loading/Loading';
import Menu from './menu/Menu';
import Question from './question/Question';
import ErrorBar from './errorbar/ErrorBar';
import { connect } from 'react-redux';
import * as selectors from '../redux/selectors/selectors';
import * as actions from '../redux/actions/all';

const NO_ICON =

;

const pages = [
  { name: 'loading', component: Loading },
  { name: 'menu', component: Menu },
  { name: 'question', component: Question }
];

const titles = [
  { category: 'article', text: 'Artikel von...' },
  { category: 'plural', text: 'Plural von...' },
  { category: 'simple-past', text: 'Präteritum von...' },
  { category: 'perfect', text: 'Perfekt von...' }
];

const mapProps = (state) => ({
  page: selectors.getPage(state),
  currentQuestion: selectors.getCurrentQuestion(state)
});

const mapCallbacks = (dispatch) => ({
  loadAppRequest: () => dispatch(actions.APP_LOADING_REQUEST.create())
});

export default connect(mapProps, mapCallbacks)(class extends Component {

  componentDidMount() {
    this.props.loadAppRequest();
  }

  findTitlePerQuestion = (question) => {
    return titles.find(({ category }) => category === question.category).text;
  };

  getTitle = () => {
    const { page, currentQuestion } = this.props;

    return page === 'question' ? this.findTitlePerQuestion(currentQuestion) : 'Genau!';
  };

  createPageComponent = () => {
    const { component } = pages.find(({ name }) => name === this.props.page);

    return React.createElement(component);
  };

  render() {
    return (

        <AppBar title={this.getTitle()} iconElementLeft={NO_ICON} iconElementRight={<AppMenuIcon />} />
        {this.createPageComponent()}
        <ErrorBar />

    );
  }
});


text:
using System.Collections.Generic;
using System.Linq;
using CMS.DocumentEngine.Types.DancingGoatMvc;
using CMS.SiteProvider;
using DancingGoat.Infrastructure;
using DancingGoat.Repositories.Filters;

namespace DancingGoat.Repositories.Implementation
{
    /// <summary>
    /// Represents a collection of coffees.
    /// </summary>
    public class KenticoCoffeeRepository : ICoffeeRepository
    {
        private readonly string mCultureName;
        private readonly bool mLatestVersionEnabled;

        /// <summary>
        /// Initializes a new instance of the <see cref="KenticoCoffeeRepository"/> class that returns coffees in the specified language.
        /// If the requested coffees doesn't exist in specified language then its default culture version is returned.
        /// </summary>
        /// <param name="siteName">The code name of a site.</param>
        /// <param name="cultureName">The name of a culture.</param>
        /// <param name="latestVersionEnabled">Indicates whether the repository will provide the most recent version of pages.</param>
        public KenticoCoffeeRepository(string cultureName, bool latestVersionEnabled)
        {
            mCultureName = cultureName;
            mLatestVersionEnabled = latestVersionEnabled;
        }

        /// <summary>
        /// Returns an enumerable collection of coffees ordered by the date of publication.
        /// </summary>
        /// <param name="filter">Instance of a product filter.</param>
        /// <param name="count">The number of coffees to return. Use 0 as value to return all records.</param>
        /// <returns>An enumerable collection that contains the specified number of coffees.</returns>
        [PagesCacheDependency(Coffee.CLASS_NAME)]
        [CacheDependency("ecommerce.sku|all")]
        public IEnumerable<Coffee> GetCoffees(IRepositoryFilter filter, int count = 0)
        {
            return CoffeeProvider.GetCoffees()
                .LatestVersion(mLatestVersionEnabled)
                .Published(!mLatestVersionEnabled)
                .OnSite(SiteContext.CurrentSiteName)
                .Culture(mCultureName)
                .CombineWithDefaultCulture()
                .TopN(count)
                .WhereTrue("SKUEnabled")
                .Where(filter?.GetWhereCondition())
                .OrderByDescending("SKUInStoreFrom")
                .ToList();
        }
    }
}


text:
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES

    static_assert((std::is_same<
        std::scoped_allocator_adaptor<A1<int>>::propagate_on_container_move_assignment,
        std::false_type>::value), "");

    static_assert((std::is_same<
        std::scoped_allocator_adaptor<A1<int>, A2<int>>::propagate_on_container_move_assignment,
        std::true_type>::value), "");

    static_assert((std::is_same<
        std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>>::propagate_on_container_move_assignment,
        std::true_type>::value), "");

#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}