Beispiel #1
0
        //
        // 'return' expression? ';'
        public void CompileReturnStatement(int depth)
        {
            // compile: 'return'
            var returnToken = Eat("return");

            // compile: expression?
            if (_tokenizer.CurrentToken.Value != ";")
            {
                CompileExpression(depth + 1, AssignmentType.NONE);
            }
            else
            {
                _vmWriter.WritePush("constant", 0);
            }

            // compile: ';'
            var semiColonToken = Eat(";");

            // write return
            _vmWriter.WriteReturn();
        }