Exemple #1
0
        private void AddNewCells()
        {
            int centerAliveCellId = Size / 2;

            for (int cellId = 0; cellId < Size; cellId++)
            {
                CurrentState.Add(new CellModel(cellId, centerAliveCellId == cellId));
            }
        }
Exemple #2
0
        protected override void OnBaseStateGenerated()
        {
            var lastStatement = CurrentState.Statements.LastOrDefault();

            if (lastStatement is JsContinueStatement || lastStatement is JsBreakStatement || lastStatement is JsReturnStatement)
            {
                return;
            }
            CurrentState.Add(Js.Return(Js.Primitive(false)));
        }
        private void CreateNewGrainCellsForCurrentState()
        {
            for (int row = 0, cellId = 0; row < RowCount; row++)
            {
                CurrentState.Add(new List <ICell>());

                for (int column = 0; column < ColumnCount; column++, cellId++)
                {
                    CurrentState[row].Add(new GrainCellModel(cellId, column, row, (GrainModel)ZeroState));
                }
            }
        }
Exemple #4
0
        public void SetResult(ExpressionSyntax result = null)
        {
            var setResult = Js.Reference(builder).Member("SetResult");

            if (result != null)
            {
                var statement = setResult.Invoke((JsExpression)result.Accept(Transformer)).Express();
                CurrentState.Add(statement);
            }
            else
            {
                CurrentState.Add(setResult.Invoke().Express());
            }
            CurrentState.Add(Js.Return());
        }
        public override void VisitYieldStatement(YieldStatementSyntax node)
        {
            var nextState = GetNextState();

            if (node.ReturnOrBreakKeyword.IsKind(SyntaxKind.BreakKeyword))
            {
                CurrentState.Add(ChangeState(nextState));
                CurrentState.Add(Js.Primitive(false).Return());
            }
            else
            {
                CurrentState.Add(ChangeState(nextState));
                CurrentState.Add(Js.Reference(stateMachine).Member("set_Current").Invoke((JsExpression)node.Expression.Accept(Transformer)).Express());
                CurrentState.Add(Js.Primitive(true).Return());
            }
            CurrentState = nextState;
        }
Exemple #6
0
        public override void VisitYieldStatement(YieldStatementSyntax node)
        {
            var nextState = GetNextState();

            if (node.ReturnOrBreakKeyword.IsKind(SyntaxKind.BreakKeyword))
            {
                CurrentState.Add(ChangeState(nextState));
                CurrentState.Add(Js.Primitive(false).Return());
            }
            else
            {
                CurrentState.Add(ChangeState(nextState));
//                if (Transformer.Model.Compilation.Assembly.AreAutoPropertiesMinimized())
//                    CurrentState.Add(Js.Reference(stateMachine).Member("Current").Assign((JsExpression)node.Expression.Accept(Transformer)).Express());
//                else
                CurrentState.Add(Js.Reference(stateMachine).Member("set_Current").Invoke((JsExpression)node.Expression.Accept(Transformer)).Express());
                CurrentState.Add(Js.Primitive(true).Return());
            }
            CurrentState = nextState;
        }