/// <inheritdoc /> public override Expression VisitLockStatement(ILockStatement operation, LocalBinder argument) { return(Expressive.Lock( operation.LockedObject.Accept(this, argument), operation.Body.Accept(this, argument) )); }
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); } }
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); }
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(); } }
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; }
void IStatementVisitor.Visit(ILockStatement statement) { this.Translate(statement); }
public override void TraverseChildren(ILockStatement lockStatement) { MethodEnter(lockStatement); base.TraverseChildren(lockStatement); MethodExit(); }
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"); }
public virtual void VisitLockStatement(ILockStatement operation) { DefaultVisit(operation); }
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)); }
public override void TranslateStatement(ILockStatement lockStatement) { throw new NotImplementedException(); }
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; }
public void visit(ILockStatement value) { string s = value.GetType().Name + "."; //prepare_node(value.Body, "ILockStatement.Body"); //prepare_node(value.LockObject, "ILockStatement.LockObject"); }
public virtual void visit(ILockStatement value) { }
/// <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; }
public override void VisitLockStatement(ILockStatement operation) { Visit(operation.LockedObject); Visit(operation.Body); }
/// <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); }
//^ 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) { }
/// <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); }
TransformationImpact IStatementVisitor <TransformationImpact> .Visit(ILockStatement statement) { return(CalculateRefactorImpact(statement)); }
public void Visit(ILockStatement lockStatement) { this.traverser.Traverse(lockStatement); }
public void Visit(ILockStatement lockStatement) { Contract.Requires(lockStatement != null); throw new NotImplementedException(); }
public override void VisitLockStatement([NotNull] ILockStatement operation) { IncrementStatementCount(operation); base.VisitLockStatement(operation); }
public abstract IStatement Transform(ILockStatement statement);
public virtual void VisitLockStatement(ILockStatement value) { VisitExpression(value.Expression); VisitStatement(value.Body); }
/// <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; }
/// <summary> /// Performs some computation with the given lock statement. /// </summary> /// <param name="lockStatement"></param> public virtual void Visit(ILockStatement lockStatement) { }
/// <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); }
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(); }
/// <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()); }
public void Visit(ILockStatement lockStatement) { throw new NotImplementedException(); }
/// <inheritdoc /> public override IOperation VisitLockStatement(ILockStatement operation, object argument) { return(base.VisitLockStatement(operation, argument)); }
public static ILockStatement Update(this ILockStatement self, IOperation @argument, IOperation @body) => self;
/// <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); }
/// <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; }
/// <summary> /// Returns a shallow copy of the given lock statement. /// </summary> /// <param name="lockStatement"></param> public LockStatement Copy(ILockStatement lockStatement) { return new LockStatement(lockStatement); }
/// <summary> /// /// </summary> /// <param name="lockStatement"></param> public LockStatement(ILockStatement lockStatement) : base(lockStatement) { this.body = lockStatement.Body; this.guard = lockStatement.Guard; }
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); }
public abstract void TranslateStatement(ILockStatement lockStatement);
public virtual void VisitLockStatement(ILockStatement value) { this.VisitExpression(value.Expression); this.VisitStatement(value.Body); }