Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@pretty_print_node.register(ast.Privilege)
def _(node, cx):
if node.op is not None:
return '%s<%s>(%s)' % (
node.privilege,
node.op,
pretty_print_node(node.regions, cx))
return '%s(%s)' % (
node.privilege,
pretty_print_node(node.regions, cx))
def p_expr_isnull(self, p):
'expr : ISNULL "(" expr ")"'
p[0] = ast.ExprIsnull(
span = ast.Span.from_slice(p),
pointer_expr = p[3])
@trans_node.register(ast.ExprNull)
def _(node, cx):
return Value(
node,
Expr('(ptr_t::nil())', []),
cx.type_map[node])
@region_analysis_node.register(ast.ExprConstBool)
def _(node, cx):
return Value()
@type_check_node.register(ast.FieldValues)
def _(node, cx):
return [type_check_node(field_value, cx)
for field_value in node.field_values]
@region_analysis_node.register(ast.ExprDereference)
def _(node, cx):
region_analysis_node(node.pointer_expr, cx).read(cx)
pointer_type = cx.type_map[node.pointer_expr].as_read()
return Reference(pointer_type.points_to_type, pointer_type.regions, [])
@type_check_node.register(ast.FunctionReturnType)
def _(node, cx):
return type_check_node(node.declared_type, cx)
@type_check_node.register(ast.FunctionName)
def _(node, cx):
return node.name
def p_expr_unaryop(self, p):
'''expr : "-" expr
| "!" expr
| "~" expr'''
p[0] = ast.ExprUnaryOp(
span = ast.Span.from_slice(p),
op = p[1], arg = p[2])
@type_check_node.register(ast.StatementWhile)
def _(node, cx):
condition_type = type_check_node(node.condition, cx).check_read(node.condition, cx)
type_check_node(node.block, cx)
if not types.is_bool(condition_type):
raise types.TypeError(node, 'While condition expression is not type bool')
return types.Void()