Пример #1
0
        protected override IEnumerator ExecuteStep()
        {
            InternalBounds = new List <BoundingBox>();

            foreach (var metaSelectionSet in
                     TargetExpression.ResolveExpression(ChainView.Instance.Chain.RootBoundingBoxes))
            {
                var foundSelectable = metaSelectionSet.GetComponent <MetaSelectionSet>();

                if (foundSelectable == null)
                {
                    continue;
                }

                var selection = new MetaSelectionMode();
                selection.Selectable         = foundSelectable;
                selection.OperationToPerform = MetaSelectionOperation;

                var iterator = selection.ApplyMode(
                    MetaSelectionSet.GetLocalSelectables(BoundsToSelect.Bounds, foundSelectable)
                    );

                while (iterator.MoveNext())
                {
                    yield return(null);
                }
            }

            Router.FireEvent(EndEventName);
            yield return(null);
        }
 public override IEnumerable <BindingParserNode> EnumerateNodes()
 {
     return
         (base.EnumerateNodes()
          .Concat(TargetExpression.EnumerateNodes())
          .Concat(ArgumentExpressions.SelectMany(a => a.EnumerateNodes())));
 }
 public override IEnumerable <BindingParserNode> EnumerateNodes()
 {
     return
         (base.EnumerateNodes()
          .Concat(TargetExpression.EnumerateNodes())
          .Concat(MemberNameExpression.EnumerateNodes()));
 }
Пример #4
0
        public TargetExpression ReadTarget()
        {
            TargetExpression exp = null;
            var token            = Reader.DiscardToken(TokenType.Target);

            exp = new TargetExpression(token.Value.Replace("target ", ""));
            return(exp);
        }
        public override void CodeGen(CodeBuilder builder)
        {
            TargetExpression.CodeGen(builder);

            builder.AppendToken("=");

            Expression.CodeGen(builder);

            builder.EndOfStatement();
        }
        /// <summary>
        /// Serializes into the given writer.
        /// </summary>
        protected override void DoSerialize(BuildXLWriter writer)
        {
            TargetExpression.Serialize(writer);

            writer.Write(TargetQualifierSpaceId);
            writer.Write(ShouldUseDefaultsOnCoercion);

            // Force computation of line and column. When deserializing,
            // the wrong file map will be available.
            ReferencedLocation.DoSerialize(writer, forceLineAndColumn: true);
        }
Пример #7
0
        public override void RewriteChildren(TargetExpression targetExpression)
        {
            BoundField /*?*/ boundField;

            if (this.fieldForCapturedLocalOrParameter.TryGetValue(targetExpression.Definition, out boundField))
            {
                targetExpression.Instance   = new ThisReference();
                targetExpression.Definition = iteratorClosure.GetReferenceOfFieldUsedByPeers(boundField.Field);
                targetExpression.Type       = boundField.Type;
                return;
            }
            base.RewriteChildren(targetExpression);
        }
        /// <inheritdoc />
        protected override EvaluationResult DoEval(Context context, ModuleLiteral env, EvaluationStackFrame frame)
        {
            var moduleCandidate = TargetExpression.Eval(context, env, frame);

            if (moduleCandidate.IsErrorValue || moduleCandidate.IsUndefined)
            {
                return(moduleCandidate);
            }

            // Qualifier type coercion could happen on both namespaces and files when importFrom is used.
            var module = moduleCandidate.Value as ModuleLiteral;

            // Moving Assert into the if block to avoid relatively expensive message computation for non-error case.
            if (module == null)
            {
                Contract.Assert(
                    false,
                    I($"TargetExpression '{TargetExpression.ToDisplayString(context)}' should produce 'ModuleLiteral' but produced '{moduleCandidate.Value.GetType()}'"));
            }

            var pathTable = context.FrontEndContext.PathTable;

            // TODO: Consider if it is possible to use QualifierUtilities.CoerceQualifierValue instead.
            QualifierValue oldQualifierValue = module.Qualifier;

            if (
                !oldQualifierValue.TryCoerce(
                    TargetQualifierSpaceId,
                    context.FrontEndContext.QualifierTable,
                    context.QualifierValueCache,
                    pathTable,
                    context.FrontEndContext.StringTable,
                    context.FrontEndContext.LoggingContext,
                    out QualifierValue coercedQualifier,
                    Location,
                    ShouldUseDefaultsOnCoercion,
                    context.LastActiveUsedPath))
            {
                context.Errors.ReportQualifierCannotBeCoarcedToQualifierSpaceWithProvenance(
                    oldQualifierValue.QualifierId,
                    TargetQualifierSpaceId,
                    ReferencedLocation.AsLoggingLocation(),
                    Location.AsLoggingLocation(env, context));

                return(EvaluationResult.Error);
            }

            return(EvaluationResult.Create(module.Instantiate(context.ModuleRegistry, coercedQualifier)));
        }
 /// <inheritdoc />
 public override string ToDebugString()
 {
     return(I($"coerceQualifier({TargetExpression.ToDebugString()}, {TargetQualifierSpaceId})"));
 }
Пример #10
0
 public override string ToDisplayString()
 => $"{TargetExpression.ToDisplayString()}.{MemberNameExpression.ToDisplayString()}";
Пример #11
0
 public VccPrefixIncrement(TargetExpression target, ISourceLocation sourceLocation)
     : base(target, sourceLocation)
 {
 }
Пример #12
0
 public override string ToDisplayString() => $"{TargetExpression.ToDisplayString()}[{ArrayIndexExpression.ToDisplayString()}]";
Пример #13
0
 public SmallBasicAssignment(TargetExpression target, Expression source, ISourceLocation sourceLocation)
   : base(target, source, sourceLocation) {
 }
Пример #14
0
 private Expression ParseAssignmentExpression(Expression operand1, TokenSet followers) 
   //^ requires Parser.InfixOperators[this.currentToken];
   //^ requires this.currentToken != Token.Conditional;
   //^ ensures followers[this.currentToken] || this.currentToken == Token.EndOfFile;
 {
   switch (this.currentToken) {
     case Token.PlusAssign:
     case Token.Assign:
     case Token.BitwiseAndAssign:
     case Token.BitwiseOrAssign:
     case Token.BitwiseXorAssign:
     case Token.DivideAssign:
     case Token.LeftShiftAssign:
     case Token.MultiplyAssign:
     case Token.RemainderAssign:
     case Token.RightShiftAssign:
     case Token.SubtractAssign:
       SourceLocationBuilder slb = new SourceLocationBuilder(operand1.SourceLocation);
       Token operatorToken = this.currentToken;
       this.GetNextToken();
       TargetExpression target = new TargetExpression(operand1);
       Expression operand2 = this.ParseExpression(followers);
       slb.UpdateToSpan(operand2.SourceLocation);
       //^ assume followers[this.currentToken] || this.currentToken == Token.EndOfFile;
       switch (operatorToken) {
         case Token.PlusAssign: return new AdditionAssignment(target, operand2, slb);
         case Token.BitwiseAndAssign: return new BitwiseAndAssignment(target, operand2, slb);
         case Token.BitwiseOrAssign: return new BitwiseOrAssignment(target, operand2, slb);
         case Token.BitwiseXorAssign: return new ExclusiveOrAssignment(target, operand2, slb);
         case Token.DivideAssign: return new DivisionAssignment(target, operand2, slb);
         case Token.LeftShiftAssign: return new LeftShiftAssignment(target, operand2, slb);
         case Token.MultiplyAssign: return new MultiplicationAssignment(target, operand2, slb);
         case Token.RemainderAssign: return new ModulusAssignment(target, operand2, slb);
         case Token.RightShiftAssign: return new RightShiftAssignment(target, operand2, slb);
         case Token.SubtractAssign: return new SubtractionAssignment(target, operand2, slb);
         default: return new Assignment(target, operand2, slb);
       }
     default:
       operand1 = this.ParseBinaryExpression(operand1, followers|Token.Conditional);
       if (this.currentToken == Token.Conditional)
         return this.ParseConditional(operand1, followers);
       //^ assume followers[this.currentToken] || this.currentToken == Token.EndOfFile;
       return operand1;
   }
 }
Пример #15
0
 /// <summary>
 /// Allocates an expression that adds or concatenates the value of the left operand with the value of the right operand.
 /// The result of the expression is assigned to the left operand, which must be a target expression.
 /// Both operands must be primitives types.
 /// </summary>
 /// <param name="leftOperand">The left operand and target of the assignment.</param>
 /// <param name="rightOperand">The right operand.</param>
 /// <param name="sourceLocation">The source location of the operation.</param>
 public VccAdditionAssignment(TargetExpression leftOperand, Expression rightOperand, ISourceLocation sourceLocation)
     : base(leftOperand, rightOperand, sourceLocation)
 {
 }
Пример #16
0
 public VccPostfixDecrement(TargetExpression target, ISourceLocation sourceLocation)
     : base(target, sourceLocation)
 {
 }
Пример #17
0
 public VccInitializerAssignment(TargetExpression leftOperand, VccInitializerWithDesignators rightOperand, ISourceLocation sourceLocation)
     : base(leftOperand, rightOperand, sourceLocation)
 {
 }
Пример #18
0
 public override string ToDisplayString() => $"{TargetExpression.ToDisplayString()}({string.Join(", ", ArgumentExpressions.Select(e => e.ToDisplayString()))})";
Пример #19
0
        internal void TransferTo(StackOfLocals targetStack, List <IStatement> list)
        {
            Contract.Requires(targetStack != null);
            Contract.Requires(list != null);
            Contract.Requires(Contract.ForAll(list, x => x != null));

            for (int i = 0; i <= this.top && i <= targetStack.top; i++)
            {
                Contract.Assert(this.top >= 0);
                Contract.Assert(this.top < this.elements.Length);
                var sourceLocal = this.elements[i];
                Contract.Assert(targetStack.top >= 0);
                Contract.Assume(targetStack.elements != null);
                Contract.Assume(targetStack.top < targetStack.elements.Length);
                var targetLocal = targetStack.elements[i];
                Contract.Assume(targetLocal != null);
                if (sourceLocal == targetLocal)
                {
                    continue;
                }
                if (targetLocal.turnIntoPopValueExpression)
                {
                    sourceLocal.turnIntoPopValueExpression = true;
                }
                else if (sourceLocal.turnIntoPopValueExpression)
                {
                    targetLocal.turnIntoPopValueExpression = true;
                }
                else
                {
                    Contract.Assume(this.body.numberOfReferences != null);
                    this.body.numberOfReferences[sourceLocal]++;
                    Contract.Assume(this.body.numberOfAssignments != null);
                    this.body.numberOfAssignments[targetLocal]++;
                    var targetType = targetLocal.Type;
                    var sourceType = sourceLocal.Type;
                    var mergedType = TypeHelper.MergedType(TypeHelper.StackType(targetType), TypeHelper.StackType(sourceType));
                    if (targetType != mergedType && !(targetType.TypeCode == PrimitiveTypeCode.Boolean && mergedType.TypeCode == PrimitiveTypeCode.Int32))
                    {
                        targetLocal.Type = mergedType;
                        targetType       = mergedType;
                        if (targetType is Dummy || sourceType is Dummy)
                        {
                            targetLocal.isPolymorphic = true;
                        }
                    }
                    var target = new TargetExpression()
                    {
                        Definition = targetLocal, Type = targetType
                    };
                    var source = new BoundExpression()
                    {
                        Definition = sourceLocal, Type = sourceType
                    };
                    var assigment = new Assignment()
                    {
                        Target = target, Source = source, Type = targetType
                    };
                    list.Add(new ExpressionStatement()
                    {
                        Expression = assigment
                    });
                }
            }
            //Contract.Assume(this.top < 0 || Contract.ForAll(0, this.top+1, i => this.elements[i] != null));
        }
Пример #20
0
 public VccOutArgument(TargetExpression expression, ISourceLocation sourceLocation)
     : base(expression, sourceLocation)
 {
 }