예제 #1
0
        protected override bool Visit(ASTPositive node)
        {
            if (!Visit(node.Child))
            {
                return(false);
            }

            var childType = node.Child.TypeInfo;

            if (childType is FloatType f)
            {
                node.TypeInfo = f;
                return(true);
            }

            if (childType is IntegerType i)
            {
                node.TypeInfo = i;
                return(true);
            }

            Error(node.Position, $"Cannot do unary positive on {childType}");
            return(false);
        }
예제 #2
0
 protected override bool Visit(ASTPositive node) => EmitUnary <CPositive>(node);
예제 #3
0
 protected abstract bool Visit(ASTPositive node);