예제 #1
0
        public Scope( Scope parent = null, bool global = false )
        {
            Parent = parent;

            if ( parent != null )
                myBase = parent.myBase ?? parent;

            myVariables = new Dictionary<string, TLObject>();
        }
예제 #2
0
        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;
        }
예제 #3
0
 public void ExitInnerBlock( Thread thread, Scope scope )
 {
     CommandType.ExitInnerBlock( this, thread, scope );
 }
예제 #4
0
 public void Execute( Thread thread, Scope scope )
 {
     CommandType.Execute( this, thread, scope );
 }
예제 #5
0
        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 );
            }
        }
예제 #6
0
        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();
        }
예제 #7
0
 public virtual TLObject Evaluate( Scope scope )
 {
     return null;
 }
예제 #8
0
        public override TLObject Evaluate( Scope scope )
        {
            if ( Not )
                return scope[ Identifier ].Not();

            if ( Minus )
                return scope[ Identifier ].Minus();

            return scope[ Identifier ];
        }
예제 #9
0
        public override TLObject Evaluate( Scope scope )
        {
            if ( Not )
                return Value.Not();

            if ( Minus )
                return Value.Minus();

            return Value;
        }
예제 #10
0
        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;
        }
예제 #11
0
 public virtual void ExitInnerBlock( Command command, Thread thread, Scope scope )
 {
 }
예제 #12
0
 public virtual void Execute( Command command, Thread thread, Scope scope )
 {
 }