Example #1
0
 /// <inheritdoc />
 public override Expression VisitLockStatement(ILockStatement operation, LocalBinder argument)
 {
     return(Expressive.Lock(
                operation.LockedObject.Accept(this, argument),
                operation.Body.Accept(this, argument)
                ));
 }
Example #2
0
        public override void VisitLockStatement(ILockStatement stmt, IList <IStatement> body)
        {
            if (IsTargetMatch(stmt, CompletionCase.EmptyCompletionBefore))
            {
                body.Add(EmptyCompletionExpression);
            }
            var block = new LockBlock
            {
                Reference = _exprVisitor.ToVariableRef(stmt.Monitor, body)
            };

            body.Add(block);

            if (IsTargetMatch(stmt, CompletionCase.InBody))
            {
                block.Body.Add(EmptyCompletionExpression);
            }

            stmt.Body.Accept(this, block.Body);


            if (IsTargetMatch(stmt, CompletionCase.EmptyCompletionAfter))
            {
                body.Add(EmptyCompletionExpression);
            }
        }
Example #3
0
 public override void TraverseChildren(ILockStatement lockStatement)
 {
     this.sourceEmitterOutput.Write("lock(", true);
     this.Traverse(lockStatement.Guard);
     this.sourceEmitterOutput.WriteLine(")");
     this.Traverse(lockStatement.Body);
 }
        public override void VisitLockStatement(ILockStatement operation)
        {
            LogString(nameof(ILockStatement));
            LogCommonPropertiesAndNewLine(operation);

            base.VisitLockStatement(operation);
        }
Example #5
0
        private static void WriteLock(LanguageWriter w, ILockStatement statement)
        {
            w.Write("{");
            w.WriteIndent();
            w.WriteLine();

            Scope.VariableData data = new Scope.VariableData("<lock_statement>" + WriteLock_counter++.ToString(), true);
            data.disp_name     = "lock";
            w.scope[data.name] = data;

            // msclr::lock を初期化
            w.WriteReference("msclr", "", null);
            w.Write("::");
            w.WriteReference("lock", "#include <msclr/lock.h> で使用して下さい", null);
            w.Write(" ");
            w.WriteDeclaration(data.disp_name);
            w.Write("(");
            ExpressionWriter.WriteExpression(w, statement.Expression, false);
            w.Write(");");
            w.WriteLine();

            // 中身を書込
            if (statement.Body != null)
            {
                WriteBlock(w, statement.Body);
            }

            w.WriteOutdent();
            w.Write("}");
            w.WriteLine();
        }
 public override void VisitLockStatement <TExpression, TStatement>(ILockStatement <TExpression, TStatement> lockStatement)
 {
     Value = new Statement()
     {
         LockStatement = new LockStatementFactory(lockStatement).Value
     };
 }
 public static void VisitLockStatementChildren <TExpression, TStatement>(
     ILockStatement <TExpression, TStatement> lockStatement,
     IGenericStatementVisitor visitor)
     where TExpression : IExpression
     where TStatement : IStatement
 {
     VisitIfNotNull(lockStatement.Statement, visitor);
 }
 public override void Visit(ILockStatement lockStatement)
 {
     if (Process(lockStatement))
     {
         visitor.Visit(lockStatement);
     }
     base.Visit(lockStatement);
 }
        public override void VisitLockStatement(ILockStatement operation)
        {
            LogString(nameof(ILockStatement));
            LogCommonPropertiesAndNewLine(operation);

            Visit(operation.LockedObject, "LockedObject");
            Visit(operation.Body, "Body");
        }
 public override void VisitLockStatement <TExpression, TStatement>(ILockStatement <TExpression, TStatement> lockStatement)
 {
     Steps.Add(new WriteLockKeyword());
     Steps.Add(new WriteWhitespace());
     Steps.Add(new WriteStartParenthesis());
     Steps.Add(new WriteExpression <TExpression>(lockStatement.Expression));
     Steps.Add(new WriteEndParenthesis());
     Steps.AddIndentedStatementSteps(lockStatement.Statement);
 }
 public override bool Visit(ILockStatement statement, IStatement context)
 {
     _stack.Push(statement);
     try
     {
         return(base.Visit(statement, context));
     }
     finally
     {
         _stack.Pop();
     }
 }
Example #12
0
        private void GenerateDownLevelLockStatement(ILockStatement lockStatement)
        {
            var systemThreading = new NestedUnitNamespaceReference(this.host.PlatformType.SystemObject.ContainingUnitNamespace,
            this.host.NameTable.GetNameFor("Threading"));
              var systemThreadingMonitor = new NamespaceTypeReference(this.host, systemThreading, this.host.NameTable.GetNameFor("Monitor"), 0,
            isEnum: false, isValueType: false, typeCode: PrimitiveTypeCode.NotPrimitive);
              var parameters = new IParameterTypeInformation[2];
              var monitorEnter = new MethodReference(this.host, systemThreadingMonitor, CallingConvention.Default, this.host.PlatformType.SystemVoid,
            this.host.NameTable.GetNameFor("Enter"), 0, this.host.PlatformType.SystemObject);
              var monitorExit = new MethodReference(this.host, systemThreadingMonitor, CallingConvention.Default, this.host.PlatformType.SystemVoid,
            this.host.NameTable.GetNameFor("Exit"), 0, this.host.PlatformType.SystemObject);

              this.EmitSequencePoint(lockStatement.Locations);
              var guardObject = new TemporaryVariable(lockStatement.Guard.Type, this.method);
              this.Traverse(lockStatement.Guard);
              this.generator.Emit(OperationCode.Dup); this.StackSize++;
              this.VisitAssignmentTo(guardObject);
              this.generator.Emit(OperationCode.Call, monitorEnter);
              this.StackSize--;
              //try
              var savedCurrentTryCatch = this.currentTryCatch;
              this.currentTryCatch = lockStatement;
              var savedCurrentTryCatchFinallyEnd = this.currentTryCatchFinallyEnd;
              this.currentTryCatchFinallyEnd = new ILGeneratorLabel();
              this.generator.BeginTryBody();
              this.Traverse(lockStatement.Body);
              if (!this.lastStatementWasUnconditionalTransfer)
            this.generator.Emit(OperationCode.Leave, this.currentTryCatchFinallyEnd);
              //finally
              this.generator.BeginFinallyBlock();
              //if (status)
              this.LoadLocal(guardObject);
              this.generator.Emit(OperationCode.Call, monitorExit);
              this.StackSize--;
              //monitor exit
              this.generator.Emit(OperationCode.Endfinally);
              this.generator.EndTryBody();
              this.generator.MarkLabel(this.currentTryCatchFinallyEnd);
              this.currentTryCatchFinallyEnd = savedCurrentTryCatchFinallyEnd;
              this.currentTryCatch = savedCurrentTryCatch;
              this.lastStatementWasUnconditionalTransfer = false;
        }
Example #13
0
 void IStatementVisitor.Visit(ILockStatement statement)
 {
     this.Translate(statement);
 }
        public override void TraverseChildren(ILockStatement lockStatement)
{ MethodEnter(lockStatement);
            base.TraverseChildren(lockStatement);
     MethodExit();   }
Example #15
0
 public void visit(ILockStatement value)
 {
     throw new System.NotSupportedException(value.GetType().ToString());
     //prepare_node(value.Body, "ILockStatement.Body"); ?
     //prepare_node(value.LockObject, "ILockStatement.LockObject"); ?          
 }
            private void WriteLockStatement(ILockStatement statement, IFormatter formatter)
            {
                this.WriteStatementSeparator(formatter);

                formatter.WriteKeyword("lock");
                formatter.Write(" ");
                formatter.Write("(");
                this.WriteExpression(statement.Expression, formatter);
                formatter.Write(")");
                formatter.WriteLine();

                formatter.WriteKeyword("begin");
                formatter.WriteIndent();

                if (statement.Body != null)
                {
                    this.WriteStatement(statement.Body, formatter);
                }

                formatter.WriteLine();
                formatter.WriteOutdent();
                formatter.WriteKeyword("end");
            }
Example #17
0
 public virtual void VisitLockStatement(ILockStatement operation)
 {
     DefaultVisit(operation);
 }
Example #18
0
 public override IOperation VisitLockStatement(ILockStatement operation, object argument)
 {
     return(new LockStatement(Visit(operation.Expression), Visit(operation.Body), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit));
 }
Example #19
0
 public override void TranslateStatement(ILockStatement lockStatement)
 {
     throw new NotImplementedException();
 }
Example #20
0
 public override void VisitLockStatement(ILockStatement operation)
 {
     base.VisitLockStatement(operation);
 }
 /// <summary>
 /// Rewrites the given lock statement.
 /// </summary>
 /// <param name="lockStatement"></param>
 public virtual IStatement Rewrite(ILockStatement lockStatement)
 {
     return lockStatement;
 }
Example #22
0
 public void visit(ILockStatement value)
 {
     string s = value.GetType().Name + ".";
     //prepare_node(value.Body, "ILockStatement.Body"); 
     //prepare_node(value.LockObject, "ILockStatement.LockObject");          
 }
Example #23
0
 public virtual void visit(ILockStatement value)
 {
 	
 }
Example #24
0
    /// <summary>
    /// Returns a deep copy of the given lock statement.
    /// </summary>
    /// <param name="lockStatement"></param>
    public LockStatement Copy(ILockStatement lockStatement) {
      Contract.Requires(lockStatement != null);
      Contract.Ensures(Contract.Result<LockStatement>() != null);

      var mutableCopy = this.shallowCopier.Copy(lockStatement);
      mutableCopy.Guard = this.Copy(mutableCopy.Guard);
      mutableCopy.Body = this.Copy(mutableCopy.Body);
      return mutableCopy;
    }
Example #25
0
 public override void VisitLockStatement(ILockStatement operation)
 {
     Visit(operation.LockedObject);
     Visit(operation.Body);
 }
Example #26
0
    /// <summary>
    /// Returns a shallow copy of the given lock statement.
    /// </summary>
    /// <param name="lockStatement"></param>
    public LockStatement Copy(ILockStatement lockStatement) {
      Contract.Requires(lockStatement != null);
      Contract.Ensures(Contract.Result<LockStatement>() != null);

      return new LockStatement(lockStatement);
    }
 public override void Visit(ILockStatement lockStatement)
 {
     if(Process(lockStatement)){visitor.Visit(lockStatement);}
     base.Visit(lockStatement);
 }
Example #28
0
 //^ ensures this.path.Count == old(this.path.Count);
 /// <summary>
 /// Traverses the given lock statement.
 /// </summary>
 /// <param name="lockStatement"></param>
 public virtual void Visit(ILockStatement lockStatement)
 {
     if (this.stopTraversal) return;
       //^ int oldCount = this.path.Count;
       this.path.Push(lockStatement);
       this.Visit(lockStatement.Guard);
       this.Visit(lockStatement.Body);
       //^ assume this.path.Count == oldCount+1; //True because all of the virtual methods of this class promise not decrease this.path.Count.
       this.path.Pop();
 }
 public virtual void onASTElement(ILockStatement lockStatement) { }
Example #30
0
 /// <summary>
 /// Traverses the lock statement.
 /// </summary>
 public void Traverse(ILockStatement lockStatement)
 {
     Contract.Requires(lockStatement != null);
       if (this.preorderVisitor != null) this.preorderVisitor.Visit(lockStatement);
       if (this.StopTraversal) return;
       this.TraverseChildren(lockStatement);
       if (this.StopTraversal) return;
       if (this.postorderVisitor != null) this.postorderVisitor.Visit(lockStatement);
 }
Example #31
0
 TransformationImpact IStatementVisitor <TransformationImpact> .Visit(ILockStatement statement)
 {
     return(CalculateRefactorImpact(statement));
 }
Example #32
0
 public void Visit(ILockStatement lockStatement)
 {
     this.traverser.Traverse(lockStatement);
 }
Example #33
0
 public virtual void onASTElement(ILockStatement lockStatement)
 {
 }
Example #34
0
 public void Visit(ILockStatement lockStatement)
 {
     Contract.Requires(lockStatement != null);
       throw new NotImplementedException();
 }
 public override void VisitLockStatement([NotNull] ILockStatement operation)
 {
     IncrementStatementCount(operation);
     base.VisitLockStatement(operation);
 }
Example #36
0
 public abstract IStatement Transform(ILockStatement statement);
 public virtual void VisitLockStatement(ILockStatement value)
 {
     VisitExpression(value.Expression);
     VisitStatement(value.Body);
 }
Example #38
0
        /// <summary>
        /// Generates IL for the specified lock statement.
        /// </summary>
        /// <param name="lockStatement">The lock statement.</param>
        public override void TraverseChildren(ILockStatement lockStatement)
        {
            if (this.host.SystemCoreAssemblySymbolicIdentity.Version.Major < 4) {
            this.GenerateDownLevelLockStatement(lockStatement);
            return;
              }
              var systemThreading = new NestedUnitNamespaceReference(this.host.PlatformType.SystemObject.ContainingUnitNamespace,
            this.host.NameTable.GetNameFor("Threading"));
              var systemThreadingMonitor = new NamespaceTypeReference(this.host, systemThreading, this.host.NameTable.GetNameFor("Monitor"), 0,
            isEnum: false, isValueType: false, typeCode: PrimitiveTypeCode.NotPrimitive);
              var parameters = new IParameterTypeInformation[2];
              var monitorEnter = new MethodReference(this.host, systemThreadingMonitor, CallingConvention.Default, this.host.PlatformType.SystemVoid,
            this.host.NameTable.GetNameFor("Enter"), 0, parameters);
              parameters[0] = new SimpleParameterTypeInformation(monitorEnter, 0, this.host.PlatformType.SystemObject);
              parameters[1] = new SimpleParameterTypeInformation(monitorEnter, 1, this.host.PlatformType.SystemBoolean, isByReference: true);
              var monitorExit = new MethodReference(this.host, systemThreadingMonitor, CallingConvention.Default, this.host.PlatformType.SystemVoid,
            this.host.NameTable.GetNameFor("Exit"), 0, this.host.PlatformType.SystemObject);

              this.EmitSequencePoint(lockStatement.Locations);
              var guardObject = new TemporaryVariable(lockStatement.Guard.Type, this.method);
              var lockTaken = new TemporaryVariable(this.host.PlatformType.SystemBoolean, this.method);
              //try
              var savedCurrentTryCatch = this.currentTryCatch;
              this.currentTryCatch = lockStatement;
              var savedCurrentTryCatchFinallyEnd = this.currentTryCatchFinallyEnd;
              this.currentTryCatchFinallyEnd = new ILGeneratorLabel();
              this.generator.BeginTryBody();
              this.Traverse(lockStatement.Guard);
              this.generator.Emit(OperationCode.Dup); this.StackSize++;
              this.VisitAssignmentTo(guardObject);
              this.LoadAddressOf(lockTaken, null);
              this.generator.Emit(OperationCode.Call, monitorEnter);
              this.StackSize-=2;
              this.Traverse(lockStatement.Body);
              if (!this.lastStatementWasUnconditionalTransfer)
            this.generator.Emit(OperationCode.Leave, this.currentTryCatchFinallyEnd);
              //finally
              this.generator.BeginFinallyBlock();
              //if (status)
              var endIf = new ILGeneratorLabel();
              this.LoadLocal(lockTaken);
              this.generator.Emit(OperationCode.Brfalse_S, endIf);
              this.StackSize--;
              this.LoadLocal(guardObject);
              this.generator.Emit(OperationCode.Call, monitorExit);
              this.StackSize--;
              this.generator.MarkLabel(endIf);
              //monitor exit
              this.generator.Emit(OperationCode.Endfinally);
              this.generator.EndTryBody();
              this.generator.MarkLabel(this.currentTryCatchFinallyEnd);
              this.currentTryCatchFinallyEnd = savedCurrentTryCatchFinallyEnd;
              this.currentTryCatch = savedCurrentTryCatch;
              this.lastStatementWasUnconditionalTransfer = false;
        }
Example #39
0
 /// <summary>
 /// Performs some computation with the given lock statement.
 /// </summary>
 /// <param name="lockStatement"></param>
 public virtual void Visit(ILockStatement lockStatement)
 {
 }
 /// <summary>
 /// Performs some computation with the given lock statement.
 /// </summary>
 /// <param name="lockStatement"></param>
 public virtual void Visit(ILockStatement lockStatement)
 {
 }
Example #41
0
 /// <summary>
 /// Traverses the children of the lock statement.
 /// </summary>
 public virtual void TraverseChildren(ILockStatement lockStatement)
 {
     Contract.Requires(lockStatement != null);
       this.TraverseChildren((IStatement)lockStatement);
       if (this.StopTraversal) return;
       this.Traverse(lockStatement.Guard);
       if (this.StopTraversal) return;
       this.Traverse(lockStatement.Body);
 }
Example #42
0
 public override void visit(ILockStatement value)
 {
     if (_monitor_enter == null)
     {
         _monitor_enter = TypeFactory.MonitorType.GetMethod("Enter", new Type[1] { TypeFactory.ObjectType });
         _monitor_exit = TypeFactory.MonitorType.GetMethod("Exit", new Type[1] { TypeFactory.ObjectType });
     }
     LocalBuilder lb = il.DeclareLocal(TypeFactory.ObjectType);
     value.LockObject.visit(this);
     il.Emit(OpCodes.Dup);
     il.Emit(OpCodes.Stloc, lb);
     il.Emit(OpCodes.Call, _monitor_enter);
     il.BeginExceptionBlock();
     ConvertStatement(value.Body);
     il.BeginFinallyBlock();
     il.Emit(OpCodes.Ldloc, lb);
     il.Emit(OpCodes.Call, _monitor_exit);
     il.EndExceptionBlock();
 }
Example #43
0
 /// <summary>
 /// Performs some computation with the given lock statement.
 /// </summary>
 /// <param name="lockStatement"></param>
 public virtual void Visit(ILockStatement lockStatement)
 {
     this.Visit((IStatement)lockStatement);
 }
            public override Location VisitLockStatement([NotNull] ILockStatement operation, [CanBeNull] object argument)
            {
                var syntax = (LockStatementSyntax)operation.Syntax;

                return(syntax.LockKeyword.GetLocation());
            }
Example #45
0
 public void Visit(ILockStatement lockStatement)
 {
     throw new NotImplementedException();
 }
 /// <inheritdoc />
 public override IOperation VisitLockStatement(ILockStatement operation, object argument)
 {
     return(base.VisitLockStatement(operation, argument));
 }
 public virtual void visit(ILockStatement value)
 {
 }
Example #48
0
 public override void TraverseChildren(ILockStatement lockStatement) {
   this.sourceEmitterOutput.Write("lock(", true);
   this.Traverse(lockStatement.Guard);
   this.sourceEmitterOutput.WriteLine(")");
   this.Traverse(lockStatement.Body);
 }
 public static ILockStatement Update(this ILockStatement self, IOperation @argument, IOperation @body) => self;
Example #50
0
 /// <summary>
 /// Visits the specified lock statement.
 /// </summary>
 /// <param name="lockStatement">The lock statement.</param>
 public override void Visit(ILockStatement lockStatement)
 {
     LockStatement mutableLockStatement = new LockStatement(lockStatement);
     this.resultStatement = this.myCodeCopier.DeepCopy(mutableLockStatement);
 }
 public override void VisitLockStatement(ILockStatement operation)
 {
     base.VisitLockStatement(operation);
 }
Example #52
0
 /// <summary>
 /// Returns a deep copy of the given lock statement.
 /// </summary>
 /// <param name="lockStatement"></param>
 public LockStatement Copy(ILockStatement lockStatement)
 {
     var mutableCopy = this.shallowCopier.Copy(lockStatement);
       mutableCopy.Guard = this.Copy(mutableCopy.Guard);
       mutableCopy.Body = this.Copy(mutableCopy.Body);
       return mutableCopy;
 }
Example #53
0
 public virtual void VisitLockStatement(ILockStatement operation)
 {
     DefaultVisit(operation);
 }
Example #54
0
 /// <summary>
 /// Returns a shallow copy of the given lock statement.
 /// </summary>
 /// <param name="lockStatement"></param>
 public LockStatement Copy(ILockStatement lockStatement)
 {
     return new LockStatement(lockStatement);
 }
Example #55
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="lockStatement"></param>
 public LockStatement(ILockStatement lockStatement)
   : base(lockStatement) {
   this.body = lockStatement.Body;
   this.guard = lockStatement.Guard;
 }
Example #56
0
 public void Visit(ILockStatement lockStatement)
 {
     this.result = this.copier.Copy(lockStatement);
 }
 public virtual void VisitLockStatement <TExpression, TStatement>(ILockStatement <TExpression, TStatement> lockStatement)
     where TExpression : IExpression
     where TStatement : IStatement
 {
     Visit(lockStatement);
 }
Example #58
0
 public abstract void TranslateStatement(ILockStatement lockStatement);
Example #59
0
 public override void TraverseChildren(ILockStatement lockStatement)
 {
     MethodEnter(lockStatement);
     base.TraverseChildren(lockStatement);
     MethodExit();
 }
 public virtual void VisitLockStatement(ILockStatement value)
 {
     this.VisitExpression(value.Expression);
     this.VisitStatement(value.Body);
 }