예제 #1
0
    def visit_BinaryExpression(self, expr, **kwargs):
        lhst = self.visit(expr.lhs, **kwargs)
        if not protocol.isa(lhst, expr.type_signature[0]):
            raise errors.EfilterTypeError(query=self.query, root=expr.lhs,
                                          expected=expr.type_signature[0],
                                          actual=lhst)

        rhst = self.visit(expr.rhs, **kwargs)
        if not protocol.isa(rhst, expr.type_signature[1]):
            raise errors.EfilterTypeError(query=self.query, root=expr.rhs,
                                          expected=expr.type_signature[1],
                                          actual=rhst)

        return expr.return_signature
예제 #2
0
파일: validate.py 프로젝트: rlugojr/dotty
def validate(expr, scope):
    lhs_type = infer_type.infer_type(expr.lhs, scope)
    if not (lhs_type is protocol.AnyType
            or protocol.isa(lhs_type, expr.type_signature[0])):
        raise errors.EfilterTypeError(root=expr.lhs,
                                      expected=expr.type_signature[0],
                                      actual=lhs_type)

    rhs_type = infer_type.infer_type(expr.rhs, scope)
    if not (lhs_type is protocol.AnyType
            or protocol.isa(rhs_type, expr.type_signature[1])):
        raise errors.EfilterTypeError(root=expr.rhs,
                                      expected=expr.type_signature[1],
                                      actual=rhs_type)

    return True
예제 #3
0
파일: validate.py 프로젝트: Onager/dotty
def validate(expr, scope):
    lhs_type = infer_type.infer_type(expr.lhs, scope)
    if not (lhs_type is protocol.AnyType
            or protocol.isa(lhs_type, expr.type_signature[0])):
        raise errors.EfilterTypeError(root=expr.lhs,
                                      expected=expr.type_signature[0],
                                      actual=lhs_type)

    rhs_type = infer_type.infer_type(expr.rhs, scope)
    if not (lhs_type is protocol.AnyType
            or protocol.isa(rhs_type, expr.type_signature[1])):
        raise errors.EfilterTypeError(root=expr.rhs,
                                      expected=expr.type_signature[1],
                                      actual=rhs_type)

    return True
예제 #4
0
    def visit_LetAny(self, expr, **kwargs):
        t = self.visit_Let(expr, **kwargs)
        if not protocol.isa(t, boolean.IBoolean):
            raise errors.EfilterTypeError(query=self.query, root=expr,
                                          actual=t,
                                          expected=associative.IBoolean)

        return boolean.IBoolean
예제 #5
0
파일: validate.py 프로젝트: rlugojr/dotty
def validate(expr, scope):
    t = infer_type.infer_type(expr.value, scope)
    if not protocol.isa(t, boolean.IBoolean):
        raise errors.EfilterTypeError(root=expr,
                                      actual=t,
                                      expected=boolean.IBoolean)

    return True
예제 #6
0
파일: validate.py 프로젝트: Onager/dotty
def validate(expr, scope):
    t = infer_type.infer_type(expr.value, scope)
    if not protocol.isa(t, boolean.IBoolean):
        raise errors.EfilterTypeError(root=expr,
                                      actual=t,
                                      expected=boolean.IBoolean)

    return True
예제 #7
0
    def visit_Let(self, expr, scope=None, **kwargs):
        t = self.visit(expr.context, scope=scope, **kwargs)
        if not (t is protocol.AnyType
                or protocol.isa(t, associative.IAssociative)):
            raise errors.EfilterTypeError(query=self.query, root=expr,
                                          actual=t,
                                          expected=associative.IAssociative)

        return self.visit(expr.expression, scope=t, **kwargs)
예제 #8
0
    def visit_VariadicExpression(self, expr, **kwargs):
        for subexpr in expr.children:
            t = self.visit(subexpr, **kwargs)
            if not protocol.isa(t, expr.type_signature):
                raise errors.EfilterTypeError(query=self.query,
                                              root=subexpr,
                                              expected=expr.type_signature,
                                              actual=t)

        return expr.return_signature
예제 #9
0
파일: validate.py 프로젝트: rlugojr/dotty
def validate(expr, scope):
    for subexpr in expr.children:
        validate(subexpr, scope)

        t = infer_type.infer_type(subexpr, scope)
        if not (t is protocol.AnyType or protocol.isa(t, expr.type_signature)):
            raise errors.EfilterTypeError(root=subexpr,
                                          expected=expr.type_signature,
                                          actual=t)

    return True
예제 #10
0
파일: validate.py 프로젝트: Onager/dotty
def validate(expr, scope):
    for subexpr in expr.children:
        validate(subexpr, scope)

        t = infer_type.infer_type(subexpr, scope)
        if not (t is protocol.AnyType
                or protocol.isa(t, expr.type_signature)):
            raise errors.EfilterTypeError(root=subexpr,
                                          expected=expr.type_signature,
                                          actual=t)

    return True
예제 #11
0
파일: validate.py 프로젝트: rlugojr/dotty
def validate(expr, scope):
    # Make sure there's an ELSE block.
    if expr.default() is None:
        raise errors.EfilterLogicError(
            root=expr, message="Else blocks are required in EFILTER.")

    # Make sure conditions evaluate to IBoolean.
    for condition, _ in expr.conditions():
        t = infer_type.infer_type(condition, scope)
        if not protocol.isa(t, boolean.IBoolean):
            raise errors.EfilterTypeError(root=expr,
                                          actual=t,
                                          expected=boolean.IBoolean)
예제 #12
0
파일: validate.py 프로젝트: Onager/dotty
def validate(expr, scope):
    # Make sure there's an ELSE block.
    if expr.default() is None:
        raise errors.EfilterLogicError(
            root=expr,
            message="Else blocks are required in EFILTER.")

    # Make sure conditions evaluate to IBoolean.
    for condition, _ in expr.conditions():
        t = infer_type.infer_type(condition, scope)
        if not protocol.isa(t, boolean.IBoolean):
            raise errors.EfilterTypeError(root=expr, actual=t,
                                          expected=boolean.IBoolean)
예제 #13
0
파일: testlib.py 프로젝트: aertoria/dotty
 def assertIsa(self, t, p):
     self.assertTrue(protocol.isa(t, p), "%r is not type %r." % (t, p))
예제 #14
0
 def assertIsa(self, t, p):
     self.assertTrue(protocol.isa(t, p), "%r is not type %r." % (t, p))
예제 #15
0
 def assertIsa(self, t, p):
     self.assertTrue(protocol.isa(t, p))
예제 #16
0
 def assertIsa(self, t, p):
     self.assertTrue(protocol.isa(t, p))