Пример #1
0
		public ValueAssignEx(Position position, Operations operation, VariableUse/*!*/ lvalue, Expression/*!*/ rvalue)
			: base(position)
		{
			this.lvalue = lvalue;
			this.rvalue = rvalue;
			this.operation = operation;
		}
Пример #2
0
		internal override Evaluation Analyze(Analyzer/*!*/ analyzer, ExInfoFromParent info)
		{
			access = info.Access;

			Evaluation cond_eval = condExpr.Analyze(analyzer, ExInfoFromParent.DefaultExInfo);

			if (cond_eval.HasValue)
			{
                if (Convert.ObjectToBoolean(cond_eval.Value))
                {
                    if (trueExpr != null)
                        return trueExpr.Analyze(analyzer, ExInfoFromParent.DefaultExInfo);
                    else
                        return cond_eval;   // condExpr ?: falseExpr    // ternary shortcut
                }
                else
                    return falseExpr.Analyze(analyzer, ExInfoFromParent.DefaultExInfo);
			}
			else
			{
                if (trueExpr != null)
                {
                    analyzer.EnterConditionalCode();
                    trueExpr = trueExpr.Analyze(analyzer, ExInfoFromParent.DefaultExInfo).Literalize();
                    analyzer.LeaveConditionalCode();
                }

				analyzer.EnterConditionalCode();
				falseExpr = falseExpr.Analyze(analyzer, ExInfoFromParent.DefaultExInfo).Literalize();
				analyzer.LeaveConditionalCode();

				return new Evaluation(this);
			}
		}
Пример #3
0
		public RefAssignEx(Text.Span span, VariableUse/*!*/ lvalue, Expression/*!*/ rvalue)
			: base(span)
		{
			Debug.Assert(rvalue is VarLikeConstructUse || rvalue is NewEx);
			this.lvalue = lvalue;
			this.rvalue = rvalue;
		}
Пример #4
0
		public UnaryEx(Position position, Operations operation, Expression/*!*/ expr)
			: base(position)
		{
			Debug.Assert(expr != null);
			this.operation = operation;
			this.expr = expr;
		}
Пример #5
0
		public ActualParam(Position p, Expression param, bool ampersand)
			: base(p)
		{
			Debug.Assert(param != null);
			this.expression = param;
			this.ampersand = ampersand;
		}
Пример #6
0
        public ActualParam(Text.Span p, Expression param, Flags flags)
			: base(p)
		{
			Debug.Assert(param != null);
			_expression = param;
            _flags = flags;
		}
Пример #7
0
		public ValueAssignEx(Text.Span span, Operations operation, VariableUse/*!*/ lvalue, Expression/*!*/ rvalue)
			: base(span)
		{
			this.lvalue = lvalue;
			this.rvalue = rvalue;
			this.operation = operation;
		}
Пример #8
0
		public InstanceOfEx(Text.Span span, Expression/*!*/ expression, TypeRef/*!*/ classNameRef)
            : base(span)
		{
			Debug.Assert(expression != null && classNameRef != null);

			this.expression = expression;
			this.classNameRef = classNameRef;
		}
Пример #9
0
		public SwitchStmt(Text.Span span, Expression/*!*/ switchValue, List<SwitchItem>/*!*/ switchItems)
			: base(span)
		{
			Debug.Assert(switchValue != null && switchItems != null);

			this.switchValue = switchValue;
			this.switchItems = switchItems;
		}
Пример #10
0
		public BinaryEx(Position position, Operations operation, Expression/*!*/ leftExpr, Expression/*!*/ rightExpr)
			: base(position)
		{
			Debug.Assert(leftExpr != null && rightExpr != null);
			this.operation = operation;
			this.leftExpr = leftExpr;
			this.rightExpr = rightExpr;
		}
Пример #11
0
		public InstanceOfEx(Position position, Expression/*!*/ expression, TypeRef/*!*/ classNameRef)
			: base(position)
		{
			Debug.Assert(expression != null && classNameRef != null);

			this.expression = expression;
			this.classNameRef = classNameRef;
		}
Пример #12
0
        /// <summary>
        /// Initializes new instance of <see cref="YieldEx"/>.
        /// </summary>
        public YieldEx(Position position, Expression keyEx, Expression valueEx)
            : base(position)
        {
            if (keyEx != null && valueEx == null) throw new ArgumentException();

            _keyEx = keyEx;
            _valueEx = valueEx;
        }
Пример #13
0
		public ItemUse(Position p, VariableUse/*!*/ array, Expression index)
			: base(p)
		{
			Debug.Assert(array != null);

			this.array = array;
			this.index = index;
		}
Пример #14
0
		public SwitchStmt(Position position, Expression/*!*/ switchValue, List<SwitchItem>/*!*/ switchItems)
			: base(position)
		{
			Debug.Assert(switchValue != null && switchItems != null);

			this.switchValue = switchValue;
			this.switchItems = switchItems;
		}
Пример #15
0
        /// <summary>
        /// Initializes new instance of <see cref="YieldEx"/>.
        /// </summary>
        public YieldEx(Text.Span span, Expression keyEx, Expression valueEx)
            : base(span)
        {
            if (keyEx != null && valueEx == null) throw new ArgumentException();

            _keyEx = keyEx;
            _valueEx = valueEx;
        }
Пример #16
0
        public ItemUse(Position p, VarLikeConstructUse/*!*/ array, Expression index, bool functionArrayDereferencing = false)
			: base(p)
		{
			Debug.Assert(array != null);

			this.array = array;
			this.index = index;
            this.functionArrayDereferencing = functionArrayDereferencing;
		}
Пример #17
0
		public ShellEx(Position position, Expression/*!*/ command)
			: base(position)
		{
#if SILVERLIGHT
			// SILVERLIGHT: Handle this in the parser!
			throw new NotSupportedException("ShellEx not supported on Silverlight!");
#endif
            Debug.Assert(command is StringLiteral || command is ConcatEx || command is BinaryStringLiteral);
			this.command = command;
		}
Пример #18
0
		public ConditionalEx(Text.Span span, Expression/*!*/ condExpr, Expression trueExpr, Expression/*!*/ falseExpr)
			: base(span)
		{
            Debug.Assert(condExpr != null);
            // Debug.Assert(trueExpr != null); // allowed to enable ternary shortcut
            Debug.Assert(falseExpr != null);

			this.condExpr = condExpr;
			this.trueExpr = trueExpr;
			this.falseExpr = falseExpr;
		}
Пример #19
0
		public IncludingEx(SourceUnit/*!*/ sourceUnit, Scope scope, bool isConditional, Text.Span span,
			InclusionTypes inclusionType, Expression/*!*/ fileName)
            : base(span)
		{
			Debug.Assert(fileName != null);

			this.inclusionType = inclusionType;
			this.fileNameEx = fileName;
			this.scope = scope;
			this.isConditional = isConditional;
			this.sourceUnit = sourceUnit;
		}
Пример #20
0
		public FormalParam(Position position, string/*!*/ name, object typeHint, bool passedByRef,
				Expression initValue, List<CustomAttribute> attributes)
			: base(position)
		{
			this.name = new VariableName(name);
			this.typeHint = typeHint;
			this.passedByRef = passedByRef;
			this.initValue = initValue;
			this.attributes = new CustomAttributes(attributes);

			this.resolvedTypeHint = null;
		}
Пример #21
0
        public ListEx(Position p, List<Expression>/*!*/ lvalues, Expression rvalue)
            : base(p)
        {
            Debug.Assert(lvalues != null /*&& rvalue != null*/);    // rvalue can be determined during runtime in case of list in list.
            Debug.Assert(lvalues.TrueForAll(delegate(Expression lvalue)
            {
                return lvalue == null || lvalue is VarLikeConstructUse || lvalue is ListEx;
            }));

            this.LValues = lvalues;
            this.RValue = rvalue;
        }
Пример #22
0
		public IndirectVarUse(Text.Span span, int levelOfIndirection, Expression varNameEx)
            : base(span)
		{
			Debug.Assert(levelOfIndirection > 0 && varNameEx != null);

			if (levelOfIndirection == 1)
			{
				this.varNameEx = varNameEx;
			}
			else
			{
                Text.Span varspan = new Text.Span(span.Start + 1, span.Length - 1);
                this.varNameEx = new IndirectVarUse(varspan, --levelOfIndirection, varNameEx);
			}
		}
Пример #23
0
		public FormalParam(Text.Span span, string/*!*/ name, object typeHint, bool passedByRef,
				Expression initValue, List<CustomAttribute> attributes)
            : base(span)
		{
            Debug.Assert(typeHint == null || typeHint is PrimitiveTypeName || typeHint is GenericQualifiedName);

			this.name = new VariableName(name);
			this.typeHint = typeHint;
			this.passedByRef = passedByRef;
			this.initValue = initValue;
            if (attributes != null && attributes.Count != 0)
                this.Attributes = new CustomAttributes(attributes);

			this.TypeHintPosition = Text.Span.Invalid;
		}
Пример #24
0
		public IndirectVarUse(Position position, int levelOfIndirection, Expression varNameEx)
			: base(position)
		{
			Debug.Assert(levelOfIndirection > 0 && varNameEx != null);

			if (levelOfIndirection == 1)
			{
				this.varNameEx = varNameEx;
			}
			else
			{
				Position pos = position;
				pos.FirstColumn++;
				this.varNameEx = new IndirectVarUse(pos, --levelOfIndirection, varNameEx);
			}
		}
Пример #25
0
		/// <include file='Doc/Nodes.xml' path='doc/method[@name="Expression.Analyze"]/*'/>
		internal override Evaluation Analyze(Analyzer/*!*/ analyzer, ExInfoFromParent info)
		{
			access = info.Access;

			switch (operation)
			{
				case Operations.Print:
				case Operations.Clone:
				case Operations.ObjectCast:
				case Operations.ArrayCast:
					expr = expr.Analyze(analyzer, ExInfoFromParent.DefaultExInfo).Literalize();
					return new Evaluation(this);

				default:
					return expr.Analyze(analyzer, ExInfoFromParent.DefaultExInfo).Evaluate(this, out expr);
			}
		}
Пример #26
0
		/// <include file='Doc/Nodes.xml' path='doc/method[@name="Statement.Analyze"]/*'/>
		internal override Statement Analyze(Analyzer/*!*/ analyzer)
		{
			if (analyzer.IsThisCodeUnreachable())
			{
				analyzer.ReportUnreachableCode(position);
				return EmptyStmt.Unreachable;
			}

			switchValue = switchValue.Analyze(analyzer, ExInfoFromParent.DefaultExInfo).Literalize();

			analyzer.EnterSwitchBody();

			foreach (SwitchItem item in switchItems)
				item.Analyze(analyzer);

			analyzer.LeaveSwitchBody();
			return this;
		}
Пример #27
0
		internal override Evaluation Analyze(Analyzer/*!*/ analyzer, ExInfoFromParent info)
		{
			access = info.Access;
			ExInfoFromParent sinfo = new ExInfoFromParent(this);

            // r-value
            if (RValue != null)
			    RValue = RValue.Analyze(analyzer, sinfo).Literalize();

            // l-values
			sinfo.Access = AccessType.Write;

			for (int i = 0; i < LValues.Count; i++)
			{
				if (LValues[i] != null)
					LValues[i] = LValues[i].Analyze(analyzer, sinfo).Expression;
			}

			return new Evaluation(this);
		}
Пример #28
0
		/// <include file='Doc/Nodes.xml' path='doc/method[@name="Expression.Analyze"]/*'/>
		internal override Evaluation Analyze(Analyzer/*!*/ analyzer, ExInfoFromParent info)
		{
			access = info.Access;

			base.Analyze(analyzer, info);

			if (isMemberOf == null)
			{
				if (!(access == AccessType.Read
					|| access == AccessType.Write
					|| access == AccessType.ReadAndWrite
					|| access == AccessType.None))
				{
					analyzer.CurrentVarTable.SetAllRef();
				}
				analyzer.AddCurrentRoutineProperty(RoutineProperties.IndirectLocalAccess);
			}

			varNameEx = varNameEx.Analyze(analyzer, ExInfoFromParent.DefaultExInfo).Literalize();

			return new Evaluation(this);
		}
Пример #29
0
		/// <include file='Doc/Nodes.xml' path='doc/method[@name="Statement.Analyze"]/*'/>
		internal override Statement/*!*/ Analyze(Analyzer/*!*/ analyzer)
		{
			if (analyzer.IsThisCodeUnreachable())
			{
				analyzer.ReportUnreachableCode(position);
				return EmptyStmt.Unreachable;
			}

			if (expr != null)
			{
				ExInfoFromParent sinfo = ExInfoFromParent.DefaultExInfo;

				if (type == Types.Return
					&& analyzer.CurrentRoutine != null && analyzer.CurrentRoutine.Signature.AliasReturn
					&& expr is VarLikeConstructUse)
				{
					sinfo.Access = AccessType.ReadRef;
				}

				expr = expr.Analyze(analyzer, sinfo).Literalize();

				if (type != Types.Return && expr.HasValue)
				{
					int level = Convert.ObjectToInteger(expr.Value);
					if (level > analyzer.LoopNestingLevel || level < 0)
					{
						analyzer.ErrorSink.Add(Errors.InvalidBreakLevelCount, analyzer.SourceUnit, position, level);
					}
				}
			}
			else if (type != Types.Return && analyzer.LoopNestingLevel == 0)
			{
				analyzer.ErrorSink.Add(Errors.InvalidBreakLevelCount, analyzer.SourceUnit, position, 1);
			}

			// code in the same block after return, break, continue is unreachable
			analyzer.EnterUnreachableCode();
			return this;
		}
Пример #30
0
		internal virtual void Analyze(Analyzer/*!*/ analyzer)
		{
            if (!this.analyzed && Constant != null) // J: Constant can be null, if there was an error
			{
				Evaluation eval = initializer.Analyze(analyzer, ExInfoFromParent.DefaultExInfo);
				if (eval.HasValue)
				{
					Constant.SetValue(eval.Value);
				}
				else
				{
					this.initializer = eval.Expression;
					Constant.SetNode(this);
				}

				this.analyzed = true;
			}
		}