1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

obeamのtype_t逆引き対応表

Posted at

obeamとは

Erlangの静的解析をするときに便利なobeamというライブラリがある。 erl +debug_info でコンパイルしたbeamファイルに内包される構文木を引っ張ってきてくれるocamlのライブラリだ。opamにも登録されているので簡単に opam install obeam できる。

逆引き対応表

obeamの Abstract_format.type_t で提供される構造がぱっとわからない時があるので逆引き対応表を作ってみた。
基本的には http://erlang.org/doc/reference_manual/typespec.html で定められている型式を順番に調べた。

syntax for typesの表にある型

Erlangの型式 Abstract Format の type_t
any() TyPredef(_, "any", [])
none() TyPredef(_, "none", [])
pid() TyPredef(_, "pid", [])
port() TyPredef(_, "port", [])
reference() TyPredef(_, "reference", [])
[] TyPredef(_, "nil", [])
atom() TyPredef(_, "atom", [])
'ok' TyLit(LitAtom(_, "ok"))
<<>> TyBitstring(_, TyLit(LitInteger(_, 0)), TyLit(LitInteger(_, 0)))
<<_:1, _:_*2>> TyBitstring(_, TyLit(LitInteger(_, 1)), TyLit(LitInteger(_, 2)))
float() TyPredef(_, "float", [])
integer() TyPredef(_, "integer", [])
42 TyLit(LitInteger(_, 42))
$a (* 未実装 *)
1 + 2 TyBinOp(_, TyLit(LitInteger(_, 1)), "+", TyLit(LitIntegr(_, 2)))
bnot 0 TyUnaryOp(_, "bnot", TyLit(LitAtom(_, 0)))
1..12 TyRange(_, TyLit(LitInteger(_, 1)), TyLit(LitInteger(_, 12)))
fun() TyFunAny _
fun((...) -> ok) TyFunAnyArity(_, _, TyLit(LitAtom(_, "ok")))
fun((atom()) -> ok) TyFun(_, _, [TyPredef(_, "atom", [])], TyLit(LitAtom(_, "ok")))
list(atom()) TyPredef(_, "list", [TyPredef(_, "atom", [])])
maybe_improper_list(number(), atom()) TyPredef(_, "maybe_improper_list", [...])
nonempty_improper_list(number(), atom()) TyPredef(_, "nonempty_improper_list", [...])
nonempty_list(atom()) TyPredef(_, "nonempty_list", [...])
map() TyAnyMap _
#{} TyMap(_, [])
#{'foo' := number(), 'bar' => atom()} TyMap(_, [TyAssocExact(...); TyAssoc(...)])
tuple() TyAnyTuple _
{} TyTuple(_, [])
{atom()} TyTuple(_, [TyPredef(_, "atom", [])])
undefined | number() TyUnion(_, [TyLit(LitAtom(_, "undefined")); TyPredef(_, "number", [])])
foo(number() TyUser(_, "foo", [TyPredef(_, "number", [])])

表7.1のBuilt-in types

Erlangの型式 Abstract Format の type_t
term() TyPredef(_, "term", [])
binary() TyPredef(_, "binary", [])
bitstring() TyPredef(_, "bitstring", [])
boolean() TyPredef(_, "boolean", [])
byte() TyPredef(_, "byte", [])
char() TyPredef(_, "char", [])
nil() TyPredef(_, "nil", [])
number() TyPredef(_, "number", [])
list() TyPredef(_, "list", [])
maybe_improper_list() TyPredef(_, "maybe_improper_list", [])
nonempty_list() TyPredef(_, "nonempty_list", [])
string() TyPredef(_, "string", [])
nonempty_string() TyPredef(_, "nonempty_string", [])
iodata() TyPredef(_, "iodata", [])
iolist() TyPredef(_, "iolist", [])
function() TyPredef(_, "function", [])
module() TyPredef(_, "module", [])
mfa() TyPredef(_, "mfa", [])
arity() TyPredef(_, "arity", [])
identifier TyPredef(_, "identifier", [])
node() TyPredef(_, "node", [])
timeout() TyPredef(_, "timeout", [])
no_return() TyPredef(_, "no_return", [])
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?