モジュール変数の GC を公開しました

OpenHSP にモジュール変数の GC を追加した「openhsp-gc」を公開しました。

たとえば、次のようなスクリプトを動かすことができます。

#module mod_human m_name
#modinit str name
	m_name = name
	return
#defcfunc new_human str name, local instance
	newmod instance, mod_human, name
	return instance
#modcfunc human_get_name
	return m_name
#global
	mes human_get_name(new_human("Taro"))
#module mod_elem m_val, m_next
#modinit int val
	m_val = val
	dimtype m_next, vartype("struct")
	return
#defcfunc new_elem int val, local instance
	newmod instance, mod_elem, val
	return instance
#modcfunc elem_get_val
	return m_val
#modcfunc elem_get_next
	return m_next
#modfunc elem_set_next struct next_
	m_next = next_
	return
#global

#module mod_list m_first, m_last
#modinit
	m_first = new_elem(0)
	m_last = m_first
	return
#defcfunc new_list local instance
	newmod instance, mod_list
	return instance
#modcfunc list_get_first
	return m_first
#modcfunc list_get_last
	return m_last
#modfunc list_push struct elem
	elem_set_next m_last, elem
	m_last = elem
	return
#modfunc list_concat struct other
	elem_set_next m_last, elem_get_next(list_get_first(other))
	m_last = list_get_last(other)
	return
#global

dimtype null, vartype("struct")

l1 = new_list()
l2 = new_list()

list_push l1, new_elem(1)
list_push l1, new_elem(2)
list_push l1, new_elem(3)

list_push l2, new_elem(5)
list_push l2, new_elem(6)

list_concat l1, l2

e = elem_get_next(list_get_first(l1))
while e != null
	mes elem_get_val(e)
	e = elem_get_next(e)
wend

インフォメーション

公開日時
2009年6月6日 午後2時34分44秒
最終更新日時
2009年6月6日 午後2時34分44秒
カテゴリ
HSP