示例#1
0
 void ASTVisitor.Accept(NodeWhen value)
 {
     Accept(value);
 }
示例#2
0
        internal void Accept(NodeWhen when)
        {
            var condition = when.condition;

            when.pass.isResultRequired = when.isResultRequired;
            when.pass.inTailPosition = when.inTailPosition;
            when.fail.isResultRequired = when.isResultRequired;
            when.fail.inTailPosition = when.inTailPosition;

            // Disable scopes, we'll do them ourselves
            if (when.pass is NodeBlock)
                (when.pass as NodeBlock).createScope = false;
            if (when.fail is NodeBlock)
                (when.fail as NodeBlock).createScope = false;

            builder.StartScope();

            uint failLoc;
            /*
            if (condition is NodeInfix && (condition as NodeInfix).op == "==")
            {

            }
            else if (condition is NodeInfix && (condition as NodeInfix).op == "!=")
            {

            }
            else // */
            {
                condition.Visit(this);
                failLoc = builder.OpJumpF(0);
            }

            when.pass.Visit(this);

            uint passLoc = builder.OpJump(0);
            builder.SetOpC(failLoc, builder.InsnCount);
            when.fail.Visit(this);
            builder.SetOpC(passLoc, builder.InsnCount);

            builder.EndScope();
        }
示例#3
0
文件: Parser.cs 项目: LayeLang/Laye
        private Node ParseWhen(Node pass)
        {
            var when = new NodeWhen(Location);
            when.pass = pass;

            Advance(); // 'when'

            if (!TokensRemain)
            {
                log.Error(when.location, "Expected expression for 'when' condition, but the end of the file was reached.");
                return when;
            }
            when.condition = Expression();
            Expect(EL, "Expected 'el' to complete when expression.");
            if (!TokensRemain)
            {
                log.Error(when.location, "Expected expression for 'when' fail expression, but the end of the file was reached.");
                return when;
            }
            when.fail = Expression();

            return when;
        }