File 1291-compiler-Add-ASM-form-to-compile-forms-2-spec.patch of Package erlang
From 434d1e8ad396c9c4c96e232741614da97ae3de15 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jean-S=C3=A9bastien=20P=C3=A9dron?=
<jean-sebastien.pedron@dumbbell.fr>
Date: Mon, 18 Oct 2021 17:22:41 +0200
Subject: [PATCH] compiler: Add ASM form to compile:forms/2 spec
This was missing so far because the assembly form was never specified.
This patch adds a type spec for the assembly form to the beam_disasm
module. This location was chosen because it also defines the #function{}
record which is used in the assembly form.
---
lib/compiler/src/beam_disasm.erl | 8 ++++++++
lib/compiler/src/compile.erl | 4 +---
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/lib/compiler/src/beam_disasm.erl b/lib/compiler/src/beam_disasm.erl
index 40359c1c54..94d4a53ab6 100644
--- a/lib/compiler/src/beam_disasm.erl
+++ b/lib/compiler/src/beam_disasm.erl
@@ -44,6 +44,14 @@
-type disasm_tag() :: symbolic_tag() | 'fr' | 'atom' | 'float' | 'literal'.
-type disasm_term() :: 'nil' | {disasm_tag(), _}.
+-type asm_form() :: {module(),
+ [{atom(), arity()}],
+ [beam_lib:attrib_entry()],
+ [#function{}],
+ beam_lib:label()}.
+
+-export_type([asm_form/0]).
+
%%-----------------------------------------------------------------------
-define(NO_DEBUG(Str,Xs), ok).
diff --git a/lib/compiler/src/compile.erl b/lib/compiler/src/compile.erl
index faed60e938..5c3b4d138a 100644
--- a/lib/compiler/src/compile.erl
+++ b/lib/compiler/src/compile.erl
@@ -48,9 +48,7 @@
-type abstract_code() :: [erl_parse:abstract_form()].
-%% Internal representations used for 'from_asm' and 'from_beam' compilation can
-%% also be valid, but have no relevant types defined.
--type forms() :: abstract_code() | cerl:c_module().
+-type forms() :: abstract_code() | cerl:c_module() | beam_disasm:asm_form().
-type option() :: atom() | {atom(), term()} | {'d', atom(), term()}.
--
2.31.1