Inheritance: GameAction
Ejemplo n.º 1
0
            public void Actor_to_actor()
            {
                var one = system.FreshActorOf<TestInsideActor>();
                var another = system.FreshActorOf<TestActor>();

                Assert.Throws<ApplicationException>(async () =>
                {
                    var message = new Throw {Exception = new ApplicationException("a-a")};
                    await one.Tell(new DoTell {Target = another, Message = message});
                });
            }
Ejemplo n.º 2
0
 public virtual Statement MarkAsInstrumentationCode(Block block){
   Throw rethrow = new Throw();
   rethrow.NodeType = NodeType.Rethrow;
   Catch catchClause = new Catch(new Block(new StatementList(rethrow)), new Local(SystemTypes.ContractMarkerException), SystemTypes.ContractMarkerException);
   CatchList catchers = new CatchList(1);
   catchers.Add(catchClause);
   return new Try(block, catchers, null, null, null);
 }
			public override object Visit (Throw throwStatement)
			{
				var result = new ThrowStatement ();
				var location = LocationsBag.GetLocations (throwStatement);
				
				result.AddChild (new CSharpTokenNode (Convert (throwStatement.loc), ThrowStatement.ThrowKeywordRole), ThrowStatement.ThrowKeywordRole);
				if (throwStatement.Expr != null)
					result.AddChild ((Expression)throwStatement.Expr.Accept (this), Roles.Expression);
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location [0]), Roles.Semicolon), Roles.Semicolon);
				return result;
			}
 // TODO: in addition to the treatment done by base.VisitThrow, transform rethrown -> throw stack_0.
 public override Statement VisitThrow(Throw thrw)
 {
   Statement stat = base.VisitThrow(thrw);
   thrw = stat as Throw;
   if (thrw == null) return stat;
   /* TODO: see if the following lines are correct
   if (thrw.Expression == null)
     thrw.Expression = get_stack_var(0);
     */
   return thrw;
 }
Ejemplo n.º 5
0
 public virtual void Throw(VariableBase Exception)
 {
     Throw TempCommand = new Throw(Exception);
     TempCommand.Setup();
     Commands.Add(TempCommand);
 }
Ejemplo n.º 6
0
void case_981()
#line 6528 "cs-parser.jay"
{
		Error_SyntaxError (yyToken);
		yyVal = new Throw (null, GetLocation (yyVals[-1+yyTop]));
	  }
Ejemplo n.º 7
0
void case_979()
#line 6518 "cs-parser.jay"
{
		yyVal = new Throw ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop]));
		lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop]));
	  }
Ejemplo n.º 8
0
 public override Statement VisitThrow(Throw Throw) {
   this.lastBranchWasUnconditional = true;
   return Throw;
 }
Ejemplo n.º 9
0
 public void Add(Throw newThrow)
 {
     throwQueue.Add(newThrow);
 }
Ejemplo n.º 10
0
    void ThrowDice(Throw dieThrow, Vector3 startPosition, Vector3 endPosition)
    {
        if(null == dieThrow)
            if(null == lastThrow) return;
            else dieThrow = lastThrow;
        else lastThrow = dieThrow;

        foreach(string dieType in dieThrow.dice)
        {
            GameObject die = CreateDie(dieType);

        //			rigidbody.angularVelocity = Random.insideUnitSphere * randomSpin;
        //			rigidbody.velocity = Random.insideUnitSphere * randomVelocity;
            transform.rotation = Quaternion.LookRotation(Random.onUnitSphere);
            die.transform.position = startPosition;
            die.transform.LookAt(endPosition);
            die.rigidbody.velocity = Camera.main.transform.forward * -10 + Camera.main.transform.right * 5;
            die.rigidbody.angularVelocity = Vector3.right * 10;

            startPosition = startPosition + new Vector3(die.transform.localScale.x + 1, 0, 0);

            //Camera.main.GetComponent<CamControl>().LookAtDice(die.transform);
        }
    }
Ejemplo n.º 11
0
 void QueueDieThrow(string diceType, int quantity, string description)
 {
     Debug.Log(string.Format("Queueing a dice throw"));
     Throw newThrow = new Throw();
     newThrow.description = description;
     for(int i=0; i<quantity; i++)
     {
         newThrow.Add(diceType);
     }
     throws.Add(newThrow);
 }
Ejemplo n.º 12
0
 public void Handle(Throw cmd)
 {
     throw cmd.Exception;
 }
Ejemplo n.º 13
0
    // Instead of overriding VisitRequiresPlain or VisitRequiresOtherwise, just process the list.
    // Almost all of the code is the same for both plain and otherwise requires.
    // This could be done by overriding VisitRequires -- but would depend upon introducing
    // a VisitRequires method in StandardVisitor.
    public override RequiresList VisitRequiresList(RequiresList Requires){
      // add a default precondition here and not earlier in the pipeline so it doesn't confuse
      // the contract inheritance checks.
      // REVIEW: probably better to add it earlier and have a HasCompilerGeneratedSignature on it
      // so it can be ignored in the inheritance checks.
      bool addDefaultPrecondition = 
        this.currentMethod != null
        && !this.currentMethod.IsStatic
        && !this.currentMethod.IsAbstract
        && this.currentMethod.Body != null && this.currentMethod.Body.Statements != null
        && !(this.currentMethod.HasCompilerGeneratedSignature && !this.currentMethod.Name.Name.StartsWith("get_") && !this.currentMethod.Name.Name.StartsWith("set_"))
        && this.currentMethod.NodeType != NodeType.InstanceInitializer
        && this.currentMethod.NodeType != NodeType.StaticInitializer
        && (this.currentType != null && this.currentType.Contract != null && this.currentType.Contract.FramePropertyGetter != null)
        && this.currentMethod.GetAttribute(SystemTypes.NoDefaultContractAttribute) == null
        ;
      
      RequiresList newRequires = new RequiresList();

      if (addDefaultPrecondition){
        Method frameGetter = this.currentType.Contract.FramePropertyGetter;
        Method m = null;
        // We used to use "get_CanStartWriting" for non-virtual methods. But Rustan and I decided
        // that it should be fine to use the transitive one for all methods. It is more liberal
        // but still prevents re-entrance into a method in a frame that is exposed.
        m = SystemTypes.Guard.GetMethod(Identifier.For("get_CanStartWritingTransitively"), null);

        // default precondition is (as normalized IR):
        // requires this.get_FrameGuard().get_CanStartWriting(); if it is a non-virtual method
        // requires this.get_FrameGuard().get_CanStartWritingTransitively(); if it is a virtual method
        if (frameGetter != null && m != null){
          SourceContext sc = this.currentMethod.Name.SourceContext;
          MethodCall getFrameGuard = new MethodCall(new MemberBinding(this.currentThisParameter, frameGetter), null, NodeType.MethodCall, SystemTypes.Guard, sc);
          Requires r = new RequiresOtherwise(
            new MethodCall(
            new MemberBinding(getFrameGuard,m),
            null,
            NodeType.MethodCall,
            SystemTypes.Boolean),
            new Construct(new MemberBinding(null, SystemTypes.RequiresException.GetConstructor(SystemTypes.String)), new ExpressionList(new Literal("The target object of this call must be exposable.", SystemTypes.String)), SystemTypes.RequiresException)
            );
          r.SourceContext = sc;
          newRequires.Add(r);
        }
      }

      if ((this.currentMethod.IsPublic || this.currentMethod.IsFamilyOrAssembly) &&
        !(this.currentCompilation != null && this.currentCompilation.CompilerParameters != null &&
        ((CompilerOptions)this.currentCompilation.CompilerParameters).DisableNullParameterValidation)){
        ParameterList parameters = this.currentMethod.Parameters;
        for (int i = 0, n = parameters == null ? 0 : parameters.Count; i < n; i++){
          Parameter parameter = parameters[i];
          if (parameter != null && !parameter.IsOut && this.typeSystem.IsNonNullType(parameter.Type)){
            RequiresOtherwise r;
            Reference rtype = parameter.Type as Reference;
            if (rtype == null) {
              TypeNode parameterType = TypeNode.StripModifier(parameter.Type, SystemTypes.NonNullType);
              Expression e = null;
              if (this.useGenerics && (parameterType is TypeParameter || parameterType is ClassParameter)) {
                e = new BinaryExpression(parameter, new MemberBinding(null, parameterType), NodeType.Box, SystemTypes.Object, parameter.SourceContext);
              } else {
                e = new ParameterBinding(parameter, parameter.SourceContext);
              }
              r =
                new RequiresOtherwise(
                new BinaryExpression(e, new Literal(null, TypeNode.StripModifiers(parameter.Type)), NodeType.Ne, SystemTypes.Boolean, parameter.SourceContext),
                new Construct(new MemberBinding(null, SystemTypes.ArgumentNullException.GetConstructor(SystemTypes.String)), new ExpressionList(new Literal(parameter.Name.Name, SystemTypes.String)), SystemTypes.ArgumentNullException));
            }
            else {
              // have to perform deref
              r =
                new RequiresOtherwise(
                new BinaryExpression(new AddressDereference(new ParameterBinding(parameter, parameter.SourceContext), rtype.ElementType), new Literal(null, TypeNode.StripModifiers(rtype.ElementType)), NodeType.Ne, SystemTypes.Boolean, parameter.SourceContext),
                new Construct(new MemberBinding(null, SystemTypes.ArgumentNullException.GetConstructor(SystemTypes.String)), new ExpressionList(new Literal(parameter.Name.Name, SystemTypes.String)), SystemTypes.ArgumentNullException));
            }
            r.SourceContext = parameter.SourceContext;
            newRequires.Add(r);
          }
        }
      }

      for (int i = 0, n = Requires == null ? 0 : Requires.Count; i < n; i++){
        newRequires.Add(Requires[i]);
      }

      if (newRequires.Count == 0)
          return Requires;

      Block preConditionBlock = new Block(new StatementList());
      preConditionBlock.HasLocals = true;

      for (int i = 0, n = newRequires.Count; i < n; i++)
      {
        Requires r = newRequires[i];
        if (r == null) continue;
        if (r.Condition == null) continue;

        // Code generation for preconditions needs to be such that the
        // data flow analysis will "see" the consequences. If the value
        // of the precondition is assigned to a local, then the information
        // is lost.
        //
        // try {
        //   if re goto pre_i_holds;
        // }
        // catch { throw new ErrorDuringPreConditionEvaluation(...); }
        // throw new PreConditionException(...);
        // pre_i_holds: nop

        bool noAllocationAllowed = this.currentMethod.GetAttribute(SystemTypes.BartokNoHeapAllocationAttribute) != null;
        Local exceptionDuringPreCondition = new Local(Identifier.For("SS$exceptionDuringPreCondition" + i),SystemTypes.Exception);
        Local exceptionDuringPreCondition3 = new Local(Identifier.For("SS$objectExceptionDuringPreCondition" + i),SystemTypes.Object);
        Expression cond = r.Condition;
        string condition = cond != null && cond.SourceContext.SourceText != null && cond.SourceContext.SourceText.Length > 0 ?
          cond.SourceContext.SourceText : "<unknown condition>";
        Expression ec2;
        Expression ec3;
        if (noAllocationAllowed) {
          ec2 = ec3 = new MemberBinding(null, SystemTypes.PreAllocatedExceptions.GetField(Identifier.For("InvalidContract")));
        }
        else {
          MemberBinding excBinding2 = new MemberBinding(null, SystemTypes.InvalidContractException.GetConstructor(SystemTypes.String, SystemTypes.Exception));
          MemberBinding excBinding3 = new MemberBinding(null, SystemTypes.InvalidContractException.GetConstructor(SystemTypes.String));
          string msg2 = "Exception occurred during evaluation of precondition '" + condition + "' in method '" + currentMethod.FullName + "'";
          ec2 = new Construct(excBinding2, new ExpressionList(new Literal(msg2, SystemTypes.String), exceptionDuringPreCondition));
          ec3 = new Construct(excBinding3, new ExpressionList(new Literal(msg2, SystemTypes.String)));
        }

        #region If the precondition fails, throw an exception
        Expression throwExpression = null;
        #region Create the expression to throw. Deal with different subtypes of Requires
        if (noAllocationAllowed) {
          throwExpression = new MemberBinding(null, SystemTypes.PreAllocatedExceptions.GetField(Identifier.For("Requires")));
        }
        else {
          if (r is RequiresPlain) {
            MemberBinding excBinding = new MemberBinding(null, SystemTypes.RequiresException.GetConstructor(SystemTypes.String));
            Construct ec = new Construct(excBinding, new ExpressionList());
            string msg = "Precondition '" + condition + "' violated from method '" + currentMethod.FullName + "'";
            ec.Operands.Add(new Literal(msg, SystemTypes.String));
            throwExpression = ec;
          }
          else if (r is RequiresOtherwise) {
            RequiresOtherwise otherwise = (RequiresOtherwise)r;
            if (otherwise.ThrowException is Literal) {
              // it was "requires P otherwise E" where E is a type name of an exception class
              Literal l = (Literal)otherwise.ThrowException;
              Class exceptionClass = (Class)l.Value;
              MemberBinding excBinding = new MemberBinding(null, this.GetTypeView(exceptionClass).GetConstructor());
              // what to do if there is no nullary constructor? I guess that should have been checked in the context checker
              Construct ec = new Construct(excBinding, new ExpressionList());
              throwExpression = ec;
            }
            else {
              // it was "requires P otherwise new E(...)" (or some other expression whose value is an exception)
              throwExpression = this.VisitExpression(otherwise.ThrowException);
            }
          }
          else {
            Debug.Assert(false, "Expecting only RequiresOtherwise and RequiresPlain as subtypes of Requires");
          }
        }
        #endregion
        Throw t = new Throw(throwExpression,r.SourceContext);
        #endregion

        Block pre_i_holds = new Block();

        //CatchList cl = new CatchList(2);
        //cl.Add(new Catch(new Block(new StatementList(new Throw(ec2,r.Condition.SourceContext))),exceptionDuringPreCondition,SystemTypes.Exception));
        //cl.Add(new Catch(new Block(new StatementList(new Throw(ec3,r.Condition.SourceContext))),exceptionDuringPreCondition3,SystemTypes.Object));

        //Try tryPre = new Try(new Block(new StatementList(new If(r.Condition,new Block(new StatementList(new Branch(null,pre_i_holds))),null))),cl,null,null,null);
        //preConditionBlock.Statements.Add(tryPre);
        preConditionBlock.Statements.Add(new If(r.Condition,new Block(new StatementList(new Branch(null,pre_i_holds))),null));
        preConditionBlock.Statements.Add(t);
        preConditionBlock.Statements.Add(pre_i_holds);

      }

      preConditionBlock = this.VisitBlock(preConditionBlock);
      this.currentContractPrelude.Statements.Add(preConditionBlock);
      return Requires;
    }
Ejemplo n.º 14
0
    public override Node VisitQueryTransact(QueryTransact qt) {
      if (qt == null || qt.Source == null || qt.Source.Type == null) return null;
      Block block = new Block(new StatementList(10));
      qt.Transaction = this.NewClosureLocal(SystemTypes.IDbTransaction, this.currentMethod.Body.Scope);
      Expression locCommit = this.NewClosureLocal(SystemTypes.Boolean, this.currentMethod.Body.Scope);
      TypeNode txType = null;
      if (this.GetTypeView(qt.Source.Type).IsAssignableTo(SystemTypes.IDbConnection)) {
        txType = SystemTypes.IDbConnection;
      }
      else if (this.GetTypeView(qt.Source.Type).IsAssignableTo(SystemTypes.IDbTransactable)) {
        txType = SystemTypes.IDbTransactable;
      }
      Expression source = this.typeSystem.ExplicitCoercion(qt.Source, txType, this.TypeViewer);
      if (qt.Isolation != null) {
        Method mBegin = this.GetTypeView(txType).GetMethod(idBeginTransaction, SystemTypes.IsolationLevel);
        MethodCall mcBegin = new MethodCall(new MemberBinding(source, mBegin), new ExpressionList(qt.Isolation));
        mcBegin.Type = mBegin.ReturnType;
        mcBegin.NodeType = NodeType.Callvirt;
        block.Statements.Add(new AssignmentStatement(qt.Transaction, mcBegin));
      }
      else {
        Method mBegin = this.GetTypeView(txType).GetMethod(idBeginTransaction);
        MethodCall mcBegin = new MethodCall(new MemberBinding(source, mBegin), null);
        mcBegin.Type = mBegin.ReturnType;
        mcBegin.NodeType = NodeType.Callvirt;
        block.Statements.Add(new AssignmentStatement(qt.Transaction, mcBegin));
      }
      block.Statements.Add(new AssignmentStatement(locCommit, Literal.True));

      // prepare finally block
      Block finBlock = new Block(new StatementList(10));
      Method mRollback = SystemTypes.IDbTransaction.GetMethod(idRollback);
      MethodCall mcRollback = new MethodCall(new MemberBinding(qt.Transaction, mRollback), null);
      mcRollback.Type = mRollback.ReturnType;
      mcRollback.NodeType = NodeType.Callvirt;
      Method mCommit = SystemTypes.IDbTransaction.GetMethod(idCommit);
      MethodCall mcCommit = new MethodCall(new MemberBinding(qt.Transaction, mCommit), null);
      mcCommit.Type = mCommit.ReturnType;
      mcCommit.NodeType = NodeType.Callvirt;
      Method mDispose = SystemTypes.IDisposable.GetMethod(StandardIds.Dispose);
      MethodCall mcDispose = new MethodCall(new MemberBinding(qt.Transaction, mDispose), null);
      mcDispose.Type = mDispose.ReturnType;
      mcDispose.NodeType = NodeType.Callvirt;
      Block bCommitStart = new Block();
      Block bCommitBody = new Block(qt.CommitBody.Statements);
      Block bRollbackBody = new Block(qt.RollbackBody.Statements);
      Block finExit = new Block();
      finBlock.Statements.Add(new Branch(locCommit, bCommitStart));
      finBlock.Statements.Add(new ExpressionStatement(mcRollback));
      finBlock.Statements.Add(bRollbackBody);
      finBlock.Statements.Add(new Branch(null, finExit));
      finBlock.Statements.Add(bCommitStart);
      finBlock.Statements.Add(new ExpressionStatement(mcCommit));
      finBlock.Statements.Add(bCommitBody);
      finBlock.Statements.Add(finExit);
      finBlock.Statements.Add(new ExpressionStatement(mcDispose));
      finBlock.Statements.Add(new AssignmentStatement(qt.Transaction, Literal.Null));

      // prepare catcher
      Local locEx = new Local(SystemTypes.Object);
      Block catchBlock = new Block(new StatementList(2));
      catchBlock.Statements.Add(new AssignmentStatement(locCommit, Literal.False));
      Throw _throw = new Throw(locEx);
      _throw.NodeType = NodeType.Rethrow;
      catchBlock.Statements.Add(_throw);
      CatchList catchers = new CatchList(1);
      catchers.Add(new Catch(catchBlock, locEx, SystemTypes.Object));

      // prepare try block
      Block tryBlock = new Block(new StatementList(4));
      qt.CommitBody.Statements = null;;
      qt.RollbackBody.Statements = null;
      tryBlock.Statements.Add(qt.Body);
      tryBlock.Statements.Add(new Branch(null, qt.CommitBody));
      tryBlock.Statements.Add(qt.RollbackBody);
      tryBlock.Statements.Add(new AssignmentStatement(locCommit, Literal.False));
      tryBlock.Statements.Add(qt.CommitBody);
      this.exceptionBlockFor[qt.CommitBody.UniqueKey] = tryBlock;
      this.exceptionBlockFor[qt.RollbackBody.UniqueKey] = tryBlock;

      // add try-finally to block      
      block.Statements.Add(new Try(tryBlock, catchers, null, null, new Finally(finBlock)));
      this.currentTransaction = qt;
      Node result = this.VisitBlock(block);
      this.currentTransaction = null;
      return result;
    }
Ejemplo n.º 15
0
 public override Statement VisitThrow(Throw Throw)
 {
   throw new ApplicationException("unimplemented");
 }
 protected internal override Node TransformThrow(Throw @throw)
 {
     return Dispatch(@throw);
 }
Ejemplo n.º 17
0
 protected internal override void TraverseThrow(Throw @throw)
 {
     Dispatch(@throw);
 }
Ejemplo n.º 18
0
 protected virtual void VisitThrow(Throw Throw){
   if (Throw == null) return;
   if (Throw.NodeType == NodeType.Rethrow)
     this.ILGenerator.Emit(OpCodes.Rethrow);
   else{
     this.Visit(Throw.Expression);
     this.ILGenerator.Emit(OpCodes.Throw);
   }
 }
Ejemplo n.º 19
0
 public override Statement VisitThrow(Throw Throw) {
   if (Throw == null) return null;
   TypeNode thrownType = null;
   if (Throw.Expression == null) {
     if (!this.insideCatchClause) {
       this.HandleError(Throw, Error.BadEmptyThrow);
       return null;
     }
     Throw.NodeType = NodeType.Rethrow;
     thrownType = this.currentCatchClause.Type != null ? this.currentCatchClause.Type : SystemTypes.Object;
   } else {
     Expression e = Throw.Expression = this.VisitExpression(Throw.Expression);
     if (e == null || e.Type == null) return null;
     thrownType = e.Type;
     if (thrownType != null)
       thrownType = this.typeSystem.Unwrap(thrownType);
     if (!this.GetTypeView(thrownType).IsAssignableTo(SystemTypes.Exception)) {
       this.HandleError(e, Error.BadExceptionType);
       return null;
     }
     e = Throw.Expression = this.typeSystem.ImplicitCoercion(e, thrownType, this.TypeViewer);
   }
   #region Dealing with checked/unchecked exceptions
   if (this.GetTypeView(thrownType).IsAssignableTo(SystemTypes.ICheckedException)) {
     int i = 0;
     int n = this.allowedExceptions.Count;
     while (i < n) {
       TypeNode t = this.allowedExceptions[i];
       if (this.GetTypeView(thrownType).IsAssignableTo(t))
         break;
       i++;
     }
     if (i == n) // no allowed exception covers this one
       this.HandleError(Throw, Error.CheckedExceptionNotInThrowsClause, this.GetTypeName(thrownType), this.GetMethodSignature(this.currentMethod));
   } else if (
     (this.currentPreprocessorDefinedSymbols == null || !this.currentPreprocessorDefinedSymbols.ContainsKey("compatibility"))
     &&
     !this.currentOptions.DisableDefensiveChecks
     ) {
     // if we can't be sure the thrown exception's *dynamic* type is an unchecked exception, then need to
     // insert a runtime check. Just because its static type is not a subtype of ICheckedException
     // doesn't mean its runtime type isn't, since CheckedException is a subtype of Exception.
     //
     // BUT: do this only if compiler options say to! This is to preserve C# backwards compatibility.
     if (Throw.Expression == null) {
       // if Throw.Expression == null ==> this was "throw;" in a catch block, definitely need the check
       // need to know if there is a variable because it could have been "catch {}" or "catch (Exception){}"
       Block b = new Block(new StatementList(2));
       b.HasLocals = true;
       // now the really bad case: need to transform "catch" or "catch (Exception){}" into "catch (Exception e)"
       if (this.currentCatchClause.Type == null)
         this.currentCatchClause.Type = SystemTypes.Exception;
       if (this.currentCatchClause.Variable == null) {
         Local e = new Local(Identifier.For("SS$exception local"), this.currentCatchClause.Type, b);
         this.currentCatchClause.Variable = e;
       }
       b.Statements.Add(new Assertion(
         new UnaryExpression(
         new BinaryExpression(this.currentCatchClause.Variable, new MemberBinding(null, SystemTypes.ICheckedException), NodeType.Is, SystemTypes.Boolean),
         NodeType.LogicalNot)));
       b.Statements.Add(Throw);
       return b;
     } else if (Throw.Expression.NodeType != NodeType.Construct) {
       // if it is "throw new T" where T is not a checked exception, then we don't need the assert
       Block b = new Block(new StatementList(3));
       b.HasLocals = true;
       // Exception e = Throw.Expression;
       // Assert(!(e is ICheckedException) );
       // throw e;
       Local e = new Local(Identifier.For("SS$exception local"), SystemTypes.Exception, b);
       b.Statements.Add(new AssignmentStatement(e, Throw.Expression));
       b.Statements.Add(new Assertion(
         new UnaryExpression(
         new BinaryExpression(e, new MemberBinding(null, SystemTypes.ICheckedException), NodeType.Is, SystemTypes.Boolean),
         NodeType.LogicalNot)));
       Throw.Expression = e;
       b.Statements.Add(Throw);
       return b;
     }
   }
   #endregion Dealing with checked/unchecked exceptions
   return Throw;
 }
Ejemplo n.º 20
0
 public virtual Statement VisitThrow(Throw Throw1, Throw Throw2)
 {
     if (Throw1 == null) return null;
     if (Throw2 == null)
         Throw1.Expression = this.VisitExpression(Throw1.Expression, null);
     else
         Throw1.Expression = this.VisitExpression(Throw1.Expression, Throw2.Expression);
     return Throw1;
 }
Ejemplo n.º 21
0
void case_980()
#line 6523 "cs-parser.jay"
{
		Error_SyntaxError (yyToken);
		yyVal = new Throw ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop]));
	  }
Ejemplo n.º 22
0
		public virtual object Visit (Throw throwStatement)
		{
			return null;
		}
Ejemplo n.º 23
0
 protected internal virtual void TraverseThrow(Throw @throw) { @throw.Unsupported(); }
Ejemplo n.º 24
0
 private static string ThrowToString(Throw thrw) {
   return
     (thrw.Expression != null) ? ("throw " + expression2str(thrw.Expression)) : "rethrow";
 }
 public override Statement VisitThrow(Throw thrw) 
 {
   base.VisitThrow(thrw);
   // when a throw occurs, the entire evaluation stack is flushed out.
   depth = 0;
   return thrw;
 }
Ejemplo n.º 26
0
 private static string RethrowToString(Throw thrw) 
 {
   return "rethrow";
 }
Ejemplo n.º 27
0
    public virtual Differences VisitThrow(Throw throw1, Throw throw2){
      Differences differences = new Differences(throw1, throw2);
      if (throw1 == null || throw2 == null){
        if (throw1 != throw2) differences.NumberOfDifferences++; else differences.NumberOfSimilarities++;
        return differences;
      }
      Throw changes = (Throw)throw2.Clone();
      Throw deletions = (Throw)throw2.Clone();
      Throw insertions = (Throw)throw2.Clone();

      Differences diff = this.VisitExpression(throw1.Expression, throw2.Expression);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.Expression = diff.Changes as Expression;
      deletions.Expression = diff.Deletions as Expression;
      insertions.Expression = diff.Insertions as Expression;
      Debug.Assert(diff.Changes == changes.Expression && diff.Deletions == deletions.Expression && diff.Insertions == insertions.Expression);
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      if (differences.NumberOfDifferences == 0){
        differences.Changes = null;
        differences.Deletions = null;
        differences.Insertions = null;
      }else{
        differences.Changes = changes;
        differences.Deletions = deletions;
        differences.Insertions = insertions;
      }
      return differences;
    }
Ejemplo n.º 28
0
 public object Any(Throw request)
 {
     if (request.StatusCode.HasValue)
     {
         throw new HttpError(
             request.StatusCode.Value,
             typeof(NotImplementedException).Name,
             request.Message);
     }
     throw new NotImplementedException(request.Message + " is not implemented");
 }
Ejemplo n.º 29
0
 public virtual Statement VisitThrow(Throw Throw, Throw changes, Throw deletions, Throw insertions){
   this.UpdateSourceContext(Throw, changes);
   if (Throw == null) return changes;
   if (changes != null){
     if (deletions == null || insertions == null)
       Debug.Assert(false);
     else{
     }
   }else if (deletions != null)
     return null;
   return Throw;
 }
Ejemplo n.º 30
0
 public Block MarkAsInstrumentationCodeNormalized(Method method, Block normalizedCode) {
   Throw t = new Throw();
   t.NodeType = NodeType.Rethrow;
   return CreateTryCatchBlock(
     method,
     normalizedCode, // try body
     new Block(new StatementList(t)), // catch: just rethrow
     new Local(Identifier.For("SS$Contract Marker"), SystemTypes.ContractMarkerException)
     );
 }