public Scope( Scope parent = null, bool global = false ) { Parent = parent; if ( parent != null ) myBase = parent.myBase ?? parent; myVariables = new Dictionary<string, TLObject>(); }
public Thread( Block startBlock, Scope startScope = null, bool keepScope = false ) { myStack = new Stack<BlockEntry>(); myPastScopes = new Stack<Scope>(); if( !keepScope ) Scope = startScope ?? stGlobalScope; EnterBlock( startBlock ); if( keepScope ) Scope = startScope ?? stGlobalScope; }
public void ExitInnerBlock( Thread thread, Scope scope ) { CommandType.ExitInnerBlock( this, thread, scope ); }
public void Execute( Thread thread, Scope scope ) { CommandType.Execute( this, thread, scope ); }
public void ExitBlock() { BlockEntry top = myStack.Pop(); Scope = Scope.Parent; if ( Scope == null && myPastScopes.Count > 0 ) Scope = myPastScopes.Pop(); if ( myStack.Count > 0 ) { myCurrentCommandNum = top.EntryPoint; CurrentCommand.ExitInnerBlock( this, Scope ); } }
public void EnterBlock( Block block, bool newScope = false, Scope scope = null ) { if ( myStack.Count >= MaximumStackSize ) throw new Exception( "Stack overflow when attempting to enter block." ); myStack.Push( new BlockEntry( myCurrentCommandNum, block ) ); myCurrentCommandNum = 0; if ( !newScope ) Scope = new Scope( Scope ); else { myPastScopes.Push( Scope ); Scope = scope ?? stGlobalScope; } if ( myCurrentCommandNum >= CurrentBlock.Commands.Length ) ExitBlock(); }
public virtual TLObject Evaluate( Scope scope ) { return null; }
public override TLObject Evaluate( Scope scope ) { if ( Not ) return scope[ Identifier ].Not(); if ( Minus ) return scope[ Identifier ].Minus(); return scope[ Identifier ]; }
public override TLObject Evaluate( Scope scope ) { if ( Not ) return Value.Not(); if ( Minus ) return Value.Minus(); return Value; }
public override TLObject Evaluate( Scope scope ) { TLObject left = Left.Evaluate( scope ); TLObject result; switch ( Operator ) { case Operator.Add: result = left.Add( Right.Evaluate( scope ) ); break; case Operator.Subtract: result = left.Subtract( Right.Evaluate( scope ) ); break; case Operator.Multiply: result = left.Multiply( Right.Evaluate( scope ) ); break; case Operator.Divide: result = left.Divide( Right.Evaluate( scope ) ); break; case Operator.And: result = left.And( Right.Evaluate( scope ) ); break; case Operator.Or: result = left.Or( Right.Evaluate( scope ) ); break; case Operator.Xor: result = left.Xor( Right.Evaluate( scope ) ); break; case Operator.Equal: result = left.Equal( Right.Evaluate( scope ) ); break; case Operator.NotEqual: result = left.NotEqual( Right.Evaluate( scope ) ); break; case Operator.Greater: result = left.Greater( Right.Evaluate( scope ) ); break; case Operator.Less: result = left.Less( Right.Evaluate( scope ) ); break; case Operator.GreaterOrEqual: result = left.GreaterOrEqual( Right.Evaluate( scope ) ); break; case Operator.LessOrEqual: result = left.LessOrEqual( Right.Evaluate( scope ) ); break; default: return null; } if ( Not ) return result.Not(); if ( Minus ) return result.Minus(); return result; }
public virtual void ExitInnerBlock( Command command, Thread thread, Scope scope ) { }
public virtual void Execute( Command command, Thread thread, Scope scope ) { }