Class: Erlang::ETF::NewFun

Inherits:
Object
  • Object
show all
Includes:
Term
Defined in:
lib/erlang/etf/new_fun.rb

Overview

1 4 1 16 4 4 N1 N2 N3 N4 N5
112 Size Arity Uniq Index NumFree Module Oldindex OldUniq Pid Free Vars

This is the new encoding of internal funs:

fun F/A and fun(Arg1,..) -> ... end.

Size

is the total number of bytes, including the Size field.

Arity

is the arity of the function implementing the fun.

Uniq

is the 16 bytes MD5 of the significant parts of the Beam file.

Index

is an index number. Each fun within a module has an unique index. Index is stored in big-endian byte order.

NumFree

is the number of free variables.

Module

is an encoded as an atom, using ATOM_EXT, SMALL_ATOM_EXT or ATOM_CACHE_REF. This is the module that the fun is implemented in.

OldIndex

is an integer encoded using SMALL_INTEGER_EXT or INTEGER_EXT. It is typically a small index into the module's fun table.

OldUniq

is an integer encoded using SMALL_INTEGER_EXT or INTEGER_EXT. Uniq is the hash value of the parse tree for the fun.

Pid

is a process identifier as in PID_EXT. It represents the process in which the fun was created.

Free vars

is NumFree number of terms, each one encoded according to its type.

(see NEW_FUN_EXT)

Constant Summary

Constants included from Term

Term::BERT_PREFIX, Term::BIN_LSB_PACK, Term::BIN_MSB_PACK

Instance Method Summary collapse

Methods included from Term

#==, #__erlang_evolve__, #__erlang_type__, #__ruby_evolve__, included

Constructor Details

#initialize(arity, uniq, index, mod, old_index, old_uniq, pid, free_vars = []) ⇒ NewFun

Returns a new instance of NewFun.



108
109
110
111
112
113
114
115
116
117
# File 'lib/erlang/etf/new_fun.rb', line 108

def initialize(arity, uniq, index, mod, old_index, old_uniq, pid, free_vars = [])
  self.arity     = arity
  self.uniq      = uniq
  self.index     = index
  self.mod       = mod
  self.old_index = old_index
  self.old_uniq  = old_uniq
  self.pid       = pid
  self.free_vars = free_vars
end

Instance Method Details

#deserialize_uniq(buffer) ⇒ Object



80
81
82
# File 'lib/erlang/etf/new_fun.rb', line 80

def deserialize_uniq(buffer)
  self.uniq = buffer.read(16).unpack(UINT8_PACK + '*')
end

#serialize_uniq(buffer) ⇒ Object



85
86
87
# File 'lib/erlang/etf/new_fun.rb', line 85

def serialize_uniq(buffer)
  buffer << uniq.pack(UINT8_PACK + '*')
end