//----------------------------------------------------------------------------------------------------------------------------------------------------- public StatementScope(StatementBlock statementBlock, RewriteMode rewriteMode) { m_Previous = s_Current; m_Root = (m_Previous != null ? m_Previous.Root : this); m_StatementBlock = statementBlock; m_Writer = statementBlock.OwnerMethod.TransparentWriter; m_OwnerMethod = statementBlock.OwnerMethod; m_OwnerClass = statementBlock.OwnerMethod.OwnerClass; m_Depth = 1; m_ThisExceptionBlockType = ExceptionBlockType.None; m_ThisExceptionStatement = null; if (m_Previous != null) { m_InheritedLoopStatement = m_Previous.InheritedLoopStatement; m_InheritedExceptionStatement = m_Previous.InheritedExceptionStatement; m_InheritedExceptionBlockType = m_Previous.InheritedExceptionBlockType; } m_StatementBlock = statementBlock; m_IsRewriteMode = true; m_RewriteInsertionIndex = 0; s_Current = this; }
//----------------------------------------------------------------------------------------------------------------------------------------------------- private StatementScope(StatementBlock statementBlock, bool attachStatementBlock) { m_Previous = s_Current; m_Root = m_Previous.Root; if (m_Previous == null) { throw new InvalidOperationException("Parent scope is not present."); } m_StatementBlock = statementBlock; m_Writer = m_Previous.m_Writer; m_OwnerMethod = m_Previous.m_OwnerMethod; m_OwnerClass = m_Previous.m_OwnerClass; m_Depth = m_Previous.Depth + 1; m_InheritedLoopStatement = m_Previous.InheritedLoopStatement; m_ThisExceptionBlockType = ExceptionBlockType.None; m_ThisExceptionStatement = null; m_InheritedExceptionStatement = m_Previous.InheritedExceptionStatement; m_InheritedExceptionBlockType = m_Previous.InheritedExceptionBlockType; m_StatementBlock = (attachStatementBlock ? AttachStatementBlock(statementBlock) : null); s_Current = this; }
//----------------------------------------------------------------------------------------------------------------------------------------------------- public void Attach(StatementScope scope) { m_OwnerMethod = scope.OwnerMethod; m_ParentBlock = (scope.Previous != null ? scope.Previous.StatementBlock : null); m_Depth = (m_ParentBlock != null ? m_ParentBlock.Depth + 1 : 0); m_EnclosingTryStatement = scope.InheritedExceptionStatement; m_EnclosingLoopStatement = scope.InheritedLoopStatement; }
//----------------------------------------------------------------------------------------------------------------------------------------------------- public StatementScope(ClassType ownerClass, MethodWriterBase writer, StatementBlock statementBlock) { if (s_Current != null) { throw new InvalidOperationException("Root scope already exists."); } m_Writer = writer; m_OwnerMethod = (writer != null ? writer.OwnerMethod : null); m_OwnerClass = ownerClass; m_Depth = 0; m_InheritedLoopStatement = null; m_ThisExceptionBlockType = ExceptionBlockType.None; m_ThisExceptionStatement = null; m_InheritedExceptionStatement = null; m_InheritedExceptionBlockType = ExceptionBlockType.None; m_Previous = null; m_Root = this; s_Current = this; m_StatementBlock = AttachStatementBlock(statementBlock); }
//------------------------------------------------------------------------------------------------------------------------------------------------- public ContinueStatement(LoopStatementBase ownerLoop) { m_OwnerLoop = ownerLoop; }
//------------------------------------------------------------------------------------------------------------------------------------------------- public BreakStatement(LoopStatementBase ownerLoop) { m_OwnerLoop = ownerLoop; }
//----------------------------------------------------------------------------------------------------------------------------------------------------- public StatementScope(StatementBlock statementBlock, LoopStatementBase loopStatement) : this(statementBlock, attachStatementBlock : false) { m_InheritedLoopStatement = loopStatement; m_StatementBlock = AttachStatementBlock(statementBlock); }