Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:25
erlang
2520-stdlib-Parse-SSA-annotation-checks.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 2520-stdlib-Parse-SSA-annotation-checks.patch of Package erlang
From a08697cd3c649b6a963c4ee54da6ddb0182d1cf3 Mon Sep 17 00:00:00 2001 From: Frej Drejhammar <frej.drejhammar@gmail.com> Date: Thu, 1 Dec 2022 11:21:39 +0100 Subject: [PATCH 10/13] stdlib: Parse SSA annotation checks Extend the grammar for SSA annotation checks to include support for checking annotations. --- lib/compiler/src/beam_ssa_check.erl | 4 ++-- lib/stdlib/src/erl_parse.yrl | 24 ++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/lib/compiler/src/beam_ssa_check.erl b/lib/compiler/src/beam_ssa_check.erl index f7855bb89e..53cec045f4 100644 --- a/lib/compiler/src/beam_ssa_check.erl +++ b/lib/compiler/src/beam_ssa_check.erl @@ -117,7 +117,7 @@ check_exprs(Exprs, Env, #b_function{bs=Blocks}=F) -> {File,_} = beam_ssa:get_anno(location, F), check_expr_seq(Exprs, Code, Env, never, File). -check_expr_seq([{check_expr,Loc,Args}|Rest]=Checks, +check_expr_seq([{check_expr,Loc,Args,_}|Rest]=Checks, [First|Code], Env0, LastMatchedLoc, File) -> Env = try ?DP("trying:~n pat: ~p~n i: ~p~n", [Args, First]), @@ -141,7 +141,7 @@ check_expr_seq([{check_expr,Loc,Args}|Rest]=Checks, check_expr_seq([], _Blocks, _Env, _LastMatchedLoc, _File) -> %% Done and all expressions matched. []; -check_expr_seq([{check_expr,Loc,Args}|_], [], Env, LastMatchedLoc, File) -> +check_expr_seq([{check_expr,Loc,Args,_}|_], [], Env, LastMatchedLoc, File) -> %% We didn't find a match and we have no more code to look at [{File,[{Loc,?MODULE,{no_match,Args,LastMatchedLoc,Env}}]}]. diff --git a/lib/stdlib/src/erl_parse.yrl b/lib/stdlib/src/erl_parse.yrl index 467a96f05e..b193ca1c94 100644 --- a/lib/stdlib/src/erl_parse.yrl +++ b/lib/stdlib/src/erl_parse.yrl @@ -51,6 +51,9 @@ map_pair_types map_pair_type bin_base_type bin_unit_type maybe_expr maybe_match_exprs maybe_match clause_body_exprs +ssa_check_anno +ssa_check_anno_clause +ssa_check_anno_clauses ssa_check_args ssa_check_binary_lit ssa_check_binary_lit_bytes_ls @@ -586,8 +589,20 @@ ssa_check_when_clause -> '%ssa%' ssa_check_clause_args_ls 'when' atom '->' ssa_check_exprs '.' : {ssa_check_when, ?anno('$1'), {atom,?anno('$1'),pass}, '$2', '$4', '$6'}. -ssa_check_exprs -> ssa_check_expr : ['$1']. -ssa_check_exprs -> ssa_check_expr ',' ssa_check_exprs : ['$1'|'$3']. +ssa_check_exprs -> ssa_check_expr : [add_anno_check('$1', [])]. +ssa_check_exprs -> ssa_check_expr ssa_check_anno : [add_anno_check('$1', '$2')]. +ssa_check_exprs -> ssa_check_expr ',' ssa_check_exprs : + [add_anno_check('$1', [])|'$3']. +ssa_check_exprs -> ssa_check_expr ssa_check_anno ',' ssa_check_exprs : + [add_anno_check('$1', '$2')|'$4']. + +ssa_check_anno -> '{' ssa_check_anno_clauses '}' : '$2'. + +ssa_check_anno_clauses -> ssa_check_anno_clause : ['$1']. +ssa_check_anno_clauses -> ssa_check_anno_clause ',' ssa_check_anno_clauses : + ['$1'|'$3']. + +ssa_check_anno_clause -> atom '=>' ssa_check_pat : {term, '$1', '$3'}. ssa_check_expr -> var '=' atom ssa_check_args : {check_expr, ?anno('$1'), [set, '$1', '$3'|'$4']}. @@ -681,6 +696,8 @@ ssa_check_map_key_elements -> ssa_check_map_key_element ',' ssa_check_map_key_el ssa_check_map_key_element -> ssa_check_map_key '=>' ssa_check_map_key: {'$1', '$3'}. +%% ssa_check_map_key_element -> ssa_check_map_key '::' top_type: +%% {type, '$1', '$3'}. ssa_check_map_key_tuple_elements -> ssa_check_map_key : ['$1']. ssa_check_map_key_tuple_elements -> ssa_check_map_key ',' ssa_check_map_key_tuple_elements: @@ -1975,4 +1992,7 @@ build_ssa_check_label({atom,_,label}, Lbl) -> build_ssa_check_label({atom,L,_}, _) -> return_error(L, "expected 'label'"). +add_anno_check({check_expr,Loc,Args}, AnnoCheck) -> + {check_expr,Loc,Args,AnnoCheck}. + %% vim: ft=erlang -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor