Пример #1
0
    /// <summary>
    /// 
    /// </summary>
    /// <remarks>(mschaef) Works, but still a stub </remarks>
    /// <param name="assignment"></param>
    public override void Visit(IAssignment assignment) {

      #region Transform Right Hand Side ...
      this.Visit(assignment.Source);
      Bpl.Expr sourceexp = this.TranslatedExpressions.Pop();
      #endregion

      this.Visit(assignment.Target);

      Bpl.Expr targetexp = this.TranslatedExpressions.Pop();
      Bpl.IdentifierExpr idexp = targetexp as Bpl.IdentifierExpr;
      if (idexp != null) {
        StmtTraverser.StmtBuilder.Add(Bpl.Cmd.SimpleAssign(assignment.Token(),
          idexp, sourceexp));
        return;
      } else {
        throw new TranslationException("Trying to create a SimpleAssign with complex/illegal lefthand side");
      }

    }
    /// <summary>
    /// 
    /// </summary>
    /// <remarks>(mschaef) Works, but still a stub </remarks>
    /// <param name="assignment"></param>
    public override void TraverseChildren(IAssignment assignment) {
      Contract.Assert(TranslatedExpressions.Count == 0);
      var tok = assignment.Token();

      bool translationIntercepted= false;
      ICompileTimeConstant constant= assignment.Source as ICompileTimeConstant;
      // TODO move away phone related code from the translation, it would be better to have 2 or more translation phases
      // NAVIGATION TODO maybe this will go away if I can handle it with stubs
      if (PhoneCodeHelper.instance().PhonePlugin != null && PhoneCodeHelper.instance().PhoneNavigationToggled) {
        IFieldReference target = assignment.Target.Definition as IFieldReference;
        if (target != null && target.Name.Value == PhoneCodeHelper.IL_CURRENT_NAVIGATION_URI_VARIABLE) {
          if (constant != null && constant.Type == sink.host.PlatformType.SystemString && constant.Value != null &&
              constant.Value.Equals(PhoneCodeHelper.BOOGIE_DO_HAVOC_CURRENTURI)) {
            TranslateHavocCurrentURI();
            translationIntercepted = true;
          }
          StmtTraverser.StmtBuilder.Add(PhoneCodeHelper.instance().getAddNavigationCheck(sink));
        }
      }

      if (!translationIntercepted)
        TranslateAssignment(tok, assignment.Target.Definition, assignment.Target.Instance, assignment.Source);
    }