Example #1
0
 public override bool Replace(Node oldValue, Node newValue)
 {
   return
     Replace(Initialization, oldValue, newValue, n => Initialization = n)
     ||
     base.Replace(oldValue, newValue);
 }
Example #2
0
    /// <summary>
    /// By default, and expression can have upto only one user. For multiple users, we will need to introduce temporary WriteIndentifier expressions.
    /// We might have statements (e.g. if) that use the result, so type should be Node and not Expression
    /// </summary>
    public override void AddUser(Node newUser)
    {
      if (User == null)
        base.AddUser(newUser);
      else
      {
        var currUser = User;

        var writeTemp = currUser as WriteTemporaryExpression;
        if (writeTemp == null)
        {
          base.RemoveUser(currUser); //next line will call this.AddUser again, so should null it beforehand
          writeTemp = new WriteTemporaryExpression(this);
          Debug.Assert(User == writeTemp, "Invalid situation!");

          currUser.Replace(this, writeTemp);
          writeTemp.AddUser(currUser);
        }
        else
        {
          //already a temporary is assigned
        }

        newUser.Replace(this, writeTemp);
        writeTemp.AddUser(newUser);
      }
    }
Example #3
0
 public override bool Replace(Node oldValue, Node newValue)
 {
   return
     Replace(ThisArg, oldValue, newValue, n => ThisArg = n)
     ||
     base.Replace(oldValue, newValue);
 }
Example #4
0
 public override bool Replace(Node oldValue, Node newValue)
 {
   return
     Replace(Expression, oldValue, newValue, n => Expression = n)
     ||
     base.Replace(oldValue, newValue);
 }
Example #5
0
 public override bool Replace(Node oldValue, Node newValue)
 {
   return
     Replace(Target, oldValue, newValue, n => Target= n)
     ||
     base.Replace(oldValue, newValue);
 }
Example #6
0
    //public BlockStatement()
    //  : this(new List<Statement>())
    //{ }

    public override bool Replace(Node oldValue, Node newValue)
    {
      return
        Replace(Statements, oldValue, newValue)
        ||
        base.Replace(oldValue, newValue);
    }
 public override bool Replace(Node oldValue, Node newValue)
 {
   return
     Replace(Value, oldValue, newValue, n => Value = n)
     ||
     base.Replace(oldValue, newValue);
 }
Example #8
0
 public override bool Replace(Node oldValue, Node newValue)
 {
   return
     Replace(Identifier, oldValue, newValue, n => Identifier = n)
     ||
     Replace(Statement, oldValue, newValue, n => Statement = n)
     ||
     base.Replace(oldValue, newValue);
 }
Example #9
0
 public override bool Replace(Node oldValue, Node newValue)
 {
   return
     Replace(Arguments, oldValue, newValue)
     ||
     Replace(Function, oldValue, newValue, n => Function = n)
     ||
     base.Replace(oldValue, newValue);
 }
Example #10
0
 public override bool Replace(Node oldValue, Node newValue)
 {
   return
     Replace(Condition, oldValue, newValue, n => Condition = n)
     ||
     Replace(Body, oldValue, newValue, n => Body = n)
     ||
     base.Replace(oldValue, newValue);
 }
Example #11
0
 public override bool Replace(Node oldValue, Node newValue)
 {
   //for (var i = 0; i < CaseClauses.Count; ++i)
   //  if (CaseClauses[i].Replace(oldValue, newValue))
   //    return true;
   return
     Replace(Expression, oldValue, newValue, n => Expression = n)
     ||
     base.Replace(oldValue, newValue);
 }
 public override bool Replace(Node oldValue, Node newValue)
 {
   return
     //The followings cannot be replaces. If this case happened we need to discuss it! 
     //Replace(Expression, oldValue, newValue, n => Expression = n)
     //||
     //Replace(Implementation, oldValue, newValue, n => Implementation = n)
     //||
     base.Replace(oldValue, newValue);
 }
Example #13
0
 public override bool Replace(Node oldValue, Node newValue)
 {
   return 
     Replace(Expression, oldValue, newValue, n => Expression = n)
     ||
     Replace(Body, oldValue, newValue, n => Body = n)
     ||
     Replace(Comparison, oldValue, newValue, n => Comparison = n)
     ||
     base.Replace(oldValue, newValue);
 }
Example #14
0
 public override bool Replace(Node oldValue, Node newValue)
 {
   return
     Replace(Initialization, oldValue, newValue, n => Initialization = n)
     ||
     Replace(Expression, oldValue, newValue, n => Expression = n)
     ||
     Replace(ExtendedBody, oldValue, newValue, n => ExtendedBody= n)
     ||
     Replace(IteratorInitialization, oldValue, newValue, n => IteratorInitialization = n)
     ||
     base.Replace(oldValue, newValue);
 }
Example #15
0
 protected override void Visit(Node node) { }
Example #16
0
      protected void PushLocation(Node node)
      {
#if DEBUG || DIAGNOSE
        if (!JSRuntime.Instance.Configuration.EnableDiagLocation)
          return;
        //Errors may occur both during compilation or execution, so we push location now, and also generate code for execution time
        JSRuntime.PushLocation(_currFuncMetadata, node.SourceOffset);
        if (_ilGen != null)
        {
          Ldarg_func();
          _ilGen.Call(Types.DFunction.GetMetadata);
          _ilGen.Castclass(Types.JSFunctionMetadata.TypeOf);
          _ilGen.Ldc_I4(node.SourceOffset);
          _ilGen.Call(Types.JSRuntime.PushLocation);
        }
#endif
      }
Example #17
0
 internal void PushLocation(Node node)
 {
   //CurrLocations.Push(node);
 }
Example #18
0
 internal void PopLocation(Node node, ref mdr.DValue result)
 {
   //_currProfiler.UpdateProfile(node, result.ValueType);
   //Node n;
   //do
   //{
   //  Debug.Assert(CurrLocations.Count > 0, "invalid situation! location stack is empty, could not fine {0}", node);
   //  n = CurrLocations.Pop();
   //} while (n != node);
   ////Debug.Assert(node == n, "invalid situation! node {0} is different from node {1} on top of stack", node, n);
 }
 ILGen.BaseILGenerator BeginICMethod(Node node, bool updateIlGen = true) { return BeginICMethod(node.GetType().Name, updateIlGen); }
Example #20
0
 public override void RemoveUser(Node currUser)
 {
   var inTheList = Users.Remove(currUser);
   Debug.Assert(inTheList, "Invalid situation!");
 }
Example #21
0
 public override void AddUser(Node newUser) { Users.Add(newUser); }
Example #22
0
 public override bool IsUsedBy(Node node) { return Users.Contains(node); }