Esempio n. 1
0
def serialize_ast(node, context):
    if node.is_enum:
        # <ast::op>'Add'
        return IR.enum_member(node.base_name, node.kind_name)
    else:
        # (INSERT ast::BinOp {.left := ..., ...})
        reference = apply_ast(node, context)
        context.new_reference(reference.id)

        # (SELECT ast::expr FILTER .id = ... LIMIT 1)
        return IR.select(
            node.base_name, filters=IR.object_ref(reference), limit=1
        )
Esempio n. 2
0
def convert_match_enum(node, state):
    expr = IR.enum_member(node.base, node.name)
    return IR.filter(state.compute_path(), expr, "=")