コード例 #1
0
ファイル: context.cs プロジェクト: ikvm/mono
		public bool MustCaptureVariable (LocalInfo local)
		{
			if (CurrentAnonymousMethod == null)
				return false;

			// FIXME: IsIterator is too aggressive, we should capture only if child
			// block contains yield
			if (CurrentAnonymousMethod.IsIterator)
				return true;

			return local.Block.Toplevel != CurrentBlock.Toplevel;
		}
コード例 #2
0
ファイル: statement.cs プロジェクト: tgiphil/mono
		public LocalInfo Clone (CloneContext clonectx)
		{
			//
			// Variables in anonymous block are not resolved yet
			//
			if (VariableType == null)
				return new LocalInfo ((FullNamedExpression) Type.Clone (clonectx), Name, clonectx.LookupBlock (Block), Location);

			//
			// Variables in method block are resolved
			//
			LocalInfo li = new LocalInfo (null, Name, clonectx.LookupBlock (Block), Location);
			li.VariableType = VariableType;
			return li;			
		}
コード例 #3
0
ファイル: anonymous.cs プロジェクト: pgoron/monodevelop
		protected virtual string GetVariableMangledName (LocalInfo local_info)
		{
			//
			// No need to mangle anonymous method hoisted variables cause they
			// are hoisted in their own scopes
			//
			return local_info.Name;
		}
コード例 #4
0
ファイル: iterators.cs プロジェクト: speier/shake
 protected override string GetVariableMangledName(LocalInfo local_info)
 {
     return "<" + local_info.Name + ">__" + local_name_idx++.ToString ();
 }
コード例 #5
0
ファイル: statement.cs プロジェクト: tgiphil/mono
			protected Emitter (Expression expr, LocalInfo li)
			{
				converted = expr;
				vi = li;
			}
コード例 #6
0
ファイル: statement.cs プロジェクト: tgiphil/mono
			public StringEmitter (Expression expr, LocalInfo li, Location loc):
				base (expr, li)
			{
				pinned_string = new LocalInfo (new TypeExpression (TypeManager.string_type, loc), null, null, loc);
				pinned_string.Pinned = true;
			}
コード例 #7
0
ファイル: statement.cs プロジェクト: lewurm/benchmarker
			public StringEmitter (Expression expr, LocalInfo li, Location loc):
				base (expr, li)
			{
				this.loc = loc;
			}
コード例 #8
0
ファイル: statement.cs プロジェクト: tgiphil/mono
		public LocalInfo AddTemporaryVariable (TypeExpr te, Location loc)
		{
			Report.Debug (64, "ADD TEMPORARY", this, Toplevel, loc);

			if (temporary_variables == null)
				temporary_variables = new List<LocalInfo> ();

			int id = ++next_temp_id;
			string name = "$s_" + id.ToString ();

			LocalInfo li = new LocalInfo (te, name, this, loc);
			li.CompilerGenerated = true;
			temporary_variables.Add (li);
			return li;
		}
コード例 #9
0
ファイル: statement.cs プロジェクト: lewurm/benchmarker
		public LocalInfo LookupVariable (LocalInfo from)
		{
			LocalInfo result = (LocalInfo) variable_map [from];

			if (result == null)
				throw new Exception ("LookupVariable: looking up a variable that has not been registered yet");

			return result;
		}
コード例 #10
0
ファイル: statement.cs プロジェクト: lewurm/benchmarker
		public LocalInfo AddVariable (Expression type, string name, Location l)
		{
			if (!CheckParentConflictName (Toplevel, name, l))
				return null;

			if (Toplevel.GenericMethod != null) {
				foreach (TypeParameter tp in Toplevel.GenericMethod.CurrentTypeParameters) {
					if (tp.Name == name) {
						Report.SymbolRelatedToPreviousError (tp);
						Error_AlreadyDeclaredTypeParameter (loc, name, "local variable");
						return null;
					}
				}
			}			

			IKnownVariable kvi = Explicit.GetKnownVariable (name);
			if (kvi != null) {
				Report.SymbolRelatedToPreviousError (kvi.Location, name);
				Error_AlreadyDeclared (l, name, "child");
				return null;
			}

			LocalInfo vi = new LocalInfo (type, name, this, l);
			AddVariable (vi);

			if ((flags & Flags.VariablesInitialized) != 0)
				throw new InternalErrorException ("block has already been resolved");

			return vi;
		}
コード例 #11
0
ファイル: statement.cs プロジェクト: lewurm/benchmarker
		public void AddVariableMap (LocalInfo from, LocalInfo to)
		{
			if (variable_map == null)
				variable_map = new Hashtable ();
			
			if (variable_map.Contains (from))
				return;
			variable_map [from] = to;
		}
コード例 #12
0
ファイル: context.cs プロジェクト: ikvm/mono
		public LocalInfo LookupVariable (LocalInfo from)
		{
			try {
				return variable_map[from];
			} catch (KeyNotFoundException) {
				throw new Exception ("LookupVariable: looking up a variable that has not been registered yet");
			}
		}
コード例 #13
0
ファイル: context.cs プロジェクト: ikvm/mono
		public void AddVariableMap (LocalInfo from, LocalInfo to)
		{
			if (variable_map == null)
				variable_map = new Dictionary<LocalInfo, LocalInfo> ();
			else if (variable_map.ContainsKey (from))
				return;

			variable_map[from] = to;
		}
コード例 #14
0
ファイル: statement.cs プロジェクト: tgiphil/mono
		public LocalInfo AddVariable (Expression type, string name, Location l)
		{
			if (!CheckParentConflictName (Toplevel, name, l))
				return null;

			IKnownVariable kvi = Explicit.GetKnownVariable (name);
			if (kvi != null) {
				Toplevel.Report.SymbolRelatedToPreviousError (kvi.Location, name);
				Error_AlreadyDeclared (l, name, "child");
				return null;
			}

			LocalInfo vi = new LocalInfo ((FullNamedExpression) type, name, this, l);
			AddVariable (vi);

			if ((flags & Flags.VariablesInitialized) != 0)
				throw new InternalErrorException ("block has already been resolved");

			return vi;
		}
コード例 #15
0
ファイル: flowanalysis.cs プロジェクト: lewurm/benchmarker
		protected VariableInfo (VariableInfo parent, TypeInfo type)
		{
			this.Name = parent.Name;
			this.TypeInfo = type;
			this.Offset = parent.Offset + type.Offset;
			this.Parent = parent;
			this.Length = type.TotalLength;

			this.IsParameter = parent.IsParameter;
			this.LocalInfo = parent.LocalInfo;

			Initialize ();
		}
コード例 #16
0
ファイル: statement.cs プロジェクト: tgiphil/mono
		protected virtual void AddVariable (LocalInfo li)
		{
			Variables.Add (li.Name, li);
			Explicit.AddKnownVariable (li.Name, li);
		}
コード例 #17
0
ファイル: flowanalysis.cs プロジェクト: lewurm/benchmarker
		public VariableInfo (LocalInfo local_info, int offset)
			: this (local_info.Name, local_info.VariableType, offset)
		{
			this.LocalInfo = local_info;
			this.IsParameter = false;
		}
コード例 #18
0
ファイル: statement.cs プロジェクト: tgiphil/mono
		// <summary>
		//   This is used by non-static `struct' constructors which do not have an
		//   initializer - in this case, the constructor must initialize all of the
		//   struct's fields.  To do this, we add a "this" variable and use the flow
		//   analysis code to ensure that it's been fully initialized before control
		//   leaves the constructor.
		// </summary>
		public LocalInfo AddThisVariable (TypeContainer ds, Location l)
		{
			if (this_variable == null) {
				this_variable = new LocalInfo (ds, this, l);
				this_variable.Used = true;
				this_variable.IsThis = true;

				Variables.Add ("this", this_variable);
			}

			return this_variable;
		}
コード例 #19
0
		//
		// Setting `is_readonly' to false will allow you to create a writable
		// reference to a read-only variable.  This is used by foreach and using.
		//
		public LocalVariableReference (Block block, string name, Location l,
					       LocalInfo local_info, bool is_readonly)
			: this (block, name, l)
		{
			this.local_info = local_info;
			this.is_readonly = is_readonly;
		}
コード例 #20
0
ファイル: statement.cs プロジェクト: tgiphil/mono
			public ExpressionEmitter (Expression converted, LocalInfo li) :
				base (converted, li)
			{
			}
コード例 #21
0
		void ResolveLocalInfo ()
		{
			if (local_info == null) {
				local_info = Block.GetLocalInfo (Name);
				type = local_info.VariableType;
				is_readonly = local_info.ReadOnly;
			}
		}
コード例 #22
0
ファイル: anonymous.cs プロジェクト: pgoron/monodevelop
		public void CaptureLocalVariable (ResolveContext ec, LocalInfo local_info)
		{
			ec.CurrentBlock.Explicit.HasCapturedVariable = true;
			if (ec.CurrentBlock.Explicit != local_info.Block.Explicit)
				AddReferenceFromChildrenBlock (ec.CurrentBlock.Explicit);

			if (local_info.HoistedVariant != null)
				return;

			HoistedVariable var = new HoistedLocalVariable (this, local_info, GetVariableMangledName (local_info));
			local_info.HoistedVariant = var;

			if (hoisted_locals == null)
				hoisted_locals = new List<HoistedVariable> ();

			hoisted_locals.Add (var);
		}
コード例 #23
0
ファイル: ecore.cs プロジェクト: speier/shake
        protected override Expression DoResolve(ResolveContext ec)
        {
            eclass = ExprClass.Variable;

            TypeExpr te = new TypeExpression (type, loc);
            li = ec.CurrentBlock.AddTemporaryVariable (te, loc);
            if (!li.Resolve (ec))
                return null;

            //
            // Don't capture temporary variables except when using
            // iterator redirection
            //
            if (ec.CurrentAnonymousMethod != null && ec.CurrentAnonymousMethod.IsIterator && ec.IsVariableCapturingRequired) {
                AnonymousMethodStorey storey = li.Block.Explicit.CreateAnonymousMethodStorey (ec);
                storey.CaptureLocalVariable (ec, li);
            }

            return this;
        }
コード例 #24
0
ファイル: anonymous.cs プロジェクト: pgoron/monodevelop
		public HoistedLocalVariable (AnonymousMethodStorey scope, LocalInfo local, string name)
			: base (scope, name, local.VariableType)
		{
			this.name = local.Name;
		}
コード例 #25
0
ファイル: eval.cs プロジェクト: speier/shake
 public LocalVariableReferenceWithClassSideEffect(TypeContainer container, string name, Block current_block, string local_variable_id, LocalInfo li, Location loc)
     : base(current_block, local_variable_id, loc, li, false)
 {
     this.container = container;
     this.name = name;
 }
コード例 #26
0
ファイル: CSharpParser.cs プロジェクト: pgoron/monodevelop
			VariableDeclarationStatement CreateVariableDeclaration (LocalInfo info)
			{
				VariableDeclarationStatement result = new VariableDeclarationStatement ();
				result.AddChild ((INode)info.Type.Accept (this), CatchClause.Roles.ReturnType);
				VariableInitializer variable = new VariableInitializer ();
				variable.AddChild (new Identifier (info.Name, Convert (info.Location)), AbstractNode.Roles.Identifier);
				result.AddChild (variable, AbstractNode.Roles.Initializer);
				
				result.AddChild (new Identifier (info.Name, Convert (info.Location)), CatchClause.Roles.ReturnType);
				return result;
			}
コード例 #27
0
ファイル: anonymous.cs プロジェクト: lewurm/benchmarker
		public void CaptureLocalVariable (EmitContext ec, LocalInfo local_info)
		{
			if (local_info.HoistedVariableReference != null)
				return;

			HoistedVariable var = new HoistedLocalVariable (this, local_info, GetVariableMangledName (local_info));
			local_info.HoistedVariableReference = var;
			has_hoisted_variable = true;

			if (hoisted_locals == null)
				hoisted_locals = new ArrayList ();

			hoisted_locals.Add (var);
		}