core: allow byte as member type

This commit is contained in:
hellerve 2019-10-24 12:08:49 +02:00
parent f1f252639f
commit 15c27bdb49
4 changed files with 73 additions and 0 deletions

View File

@ -76,3 +76,12 @@
(defn random-sized [n]
(from-chars &(Array.repeat n &Char.random)))
)
(defmodule Byte
(defn random-between [lower upper]
(Byte.from-int (Int.random-between (Byte.to-int lower) (Byte.to-int upper))))
(defn random []
(Byte.from-int (Int.random)))
)

View File

@ -208,6 +208,7 @@
)
(defmodule Int (defn prn [x] (Int.str x)))
(defmodule Byte (defn prn [x] (Byte.str x)))
(defmodule IntRef
(defn prn [x] (Int.str @x))
(defn str [x] (Int.str @x))
@ -217,6 +218,11 @@
(defn prn [x] (Bool.str @x))
(defn str [x] (Bool.str @x)))
(defmodule ByteRef
(defn prn [x] (Byte.str @x))
(defn str [x] (Byte.str @x))
)
(defmodule Long (defn prn [x] (Long.str x)))
(defmodule Float (defn prn [x] (Float.str x)))
(defmodule Double (defn prn [x] (Double.str x)))

View File

@ -622,6 +622,63 @@
</p>
</div>
<div class="binder">
<a class="anchor" href="#prn">
<h3 id="prn">
prn
</h3>
</a>
<div class="description">
defn
</div>
<p class="sig">
(λ [Byte] String)
</p>
<pre class="args">
(prn x)
</pre>
<p class="doc">
</p>
</div>
<div class="binder">
<a class="anchor" href="#random">
<h3 id="random">
random
</h3>
</a>
<div class="description">
defn
</div>
<p class="sig">
(λ [] Byte)
</p>
<pre class="args">
(random)
</pre>
<p class="doc">
</p>
</div>
<div class="binder">
<a class="anchor" href="#random-between">
<h3 id="random-between">
random-between
</h3>
</a>
<div class="description">
defn
</div>
<p class="sig">
(λ [Byte, Byte] Byte)
</p>
<pre class="args">
(random-between lower upper)
</pre>
<p class="doc">
</p>
</div>
<div class="binder">
<a class="anchor" href="#str">
<h3 id="str">

View File

@ -38,6 +38,7 @@ canBeUsedAsMemberType typeEnv typeVariables t xobj =
IntTy -> return ()
FloatTy -> return ()
DoubleTy -> return ()
ByteTy -> return ()
LongTy -> return ()
BoolTy -> return ()
StringTy -> return ()