How to use the constructs.Reference function in constructs

To help you get started, we’ve selected a few constructs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bollu / polymage / sandbox / expression.py View on Github external
def getType(expr):
    expr = Value.numericToValue(expr)
    assert(isinstance(expr, AbstractExpression))
    if (isinstance(expr, Value)):
        return expr.typ
    elif (isinstance(expr, constructs.Variable)):
        return expr.typ
    elif (isinstance(expr, constructs.Reference)):
        return expr.objectRef.typ
    elif (isinstance(expr, AbstractBinaryOpNode)):
        left_type = getType(expr.left)
        right_type = getType(expr.right)
        return result_type(left_type, right_type)
    elif (isinstance(expr, AbstractUnaryOpNode)):
        return getType(expr.child)
    elif (isinstance(expr, constructs.Cast)):
        return expr.typ
    elif (isinstance(expr, constructs.Select)):
        true_type = getType(expr.trueExpression)
        false_type = getType(expr.falseExpression)
        assert true_type == false_type
        return true_type
    elif (isinstance(expr, InbuiltFunction)):
        return expr.getType()

constructs

A programming model for software-defined state

Apache-2.0
Latest version published 25 days ago

Package Health Score

94 / 100
Full package analysis