Skip to content

Commit

Permalink
Merge pull request #145 from wrapl/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
rajamukherji authored Jul 23, 2023
2 parents 25bdbe3 + a6125bc commit 44627b7
Show file tree
Hide file tree
Showing 28 changed files with 597 additions and 197 deletions.
22 changes: 11 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ $(SUBDIRS):

*.o: *.h

CFLAGS += \
override CFLAGS += \
-std=gnu99 -fstrict-aliasing -foptimize-sibling-calls \
-Wstrict-aliasing -Wall \
-Iobj -Isrc -pthread -DGC_THREADS -D_GNU_SOURCE -D$(PLATFORM)
LDFLAGS += -lm
override LDFLAGS += -lm

ifdef DEBUG
CFLAGS += -g -DGC_DEBUG -DDEBUG
LDFLAGS += -g
override CFLAGS += -g -DGC_DEBUG -DDEBUG
override LDFLAGS += -g
else
CFLAGS += -O3 -g
LDFLAGS += -g
override CFLAGS += -O3 -g
override LDFLAGS += -g
endif

obj/ml_config.h: | obj
Expand Down Expand Up @@ -80,23 +80,23 @@ common_objects = \
platform_objects =

ifeq ($(MACHINE), i686)
CFLAGS += -fno-pic
override CFLAGS += -fno-pic
endif

ifeq ($(PLATFORM), Linux)
platform_objects += obj/linenoise.o
LDFLAGS += -lgc
override LDFLAGS += -lgc
endif

ifeq ($(PLATFORM), FreeBSD)
platform_objects += obj/linenoise.o
CFLAGS += -I/usr/local/include
LDFLAGS += -L/usr/local/lib -lgc-threaded
override CFLAGS += -I/usr/local/include
override LDFLAGS += -L/usr/local/lib -lgc-threaded
endif

ifeq ($(PLATFORM), Darwin)
platform_objects += obj/linenoise.o
LDFLAGS += -lgc
override LDFLAGS += -lgc
endif

minilang_objects = $(common_objects) $(platform_objects) \
Expand Down
4 changes: 4 additions & 0 deletions docs/_static/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ div.folders ul li:after {
top: 0;
}

div.highlight {
margin-bottom: 2em;
}

.highlight {
color: #333333 !important;
background-color: #f5f5f5;
Expand Down
2 changes: 1 addition & 1 deletion docs/library/array.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1703,7 +1703,7 @@ array
.. code-block:: mini
let B := buffer(16)
:> <16:E0F4EA12517F00004C49545F434F554E>
:> <16:80491B34647F000055524E2856616C75>
array::wrap(array::uint16, B, [2, 2, 2], [8, 4, 2]) :>
Expand Down
12 changes: 1 addition & 11 deletions docs/library/buffer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,6 @@ buffer
A buffer represents a writable bounded section of memory.


:mini:`meth (Buffer: buffer) + (Offset: integer): buffer`
Returns the buffer at offset :mini:`Offset` from :mini:`Address`.

.. code-block:: mini
let B := buffer(16)
:> <16:C0CADD12517F0000206E6F742063616C>
B + 8 :> <8:206E6F742063616C>
:mini:`meth (Buffer: buffer):put(Value: address): buffer`
Puts the bytes of :mini:`Value` in :mini:`Buffer`.

Expand Down Expand Up @@ -93,6 +83,6 @@ buffer

.. code-block:: mini
buffer(16) :> <16:6062CF12517F0000203C67632F67635F>
buffer(16) :> <16:00271034647F0000655F726F775F7420>
36 changes: 36 additions & 0 deletions docs/library/file.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,34 @@ file
Flushes any pending writes to :mini:`File`.


:mini:`type file::mode < enum`
*TBD*


:mini:`type file::stat`
*TBD*


:mini:`meth (Arg₁: file::stat):atime`
*TBD*


:mini:`meth (Arg₁: file::stat):ctime`
*TBD*


:mini:`meth (Arg₁: file::stat):mode`
*TBD*


:mini:`meth (Arg₁: file::stat):mtime`
*TBD*


:mini:`meth (Arg₁: file::stat):size`
*TBD*


:mini:`type popen < file`
A file that reads or writes to a running subprocess.

Expand All @@ -60,6 +88,10 @@ file
Waits for the subprocess to finish and returns the exit status.


:mini:`fun file::exists(Path: string): string | nil`
*TBD*


:mini:`fun file::rename(Old: string, New: string)`
Renames the file :mini:`Old` to :mini:`New`.

Expand All @@ -68,3 +100,7 @@ file
Removes the file at :mini:`Path`.


:mini:`fun mlfilestat(Arg₁: string)`
*TBD*


2 changes: 2 additions & 0 deletions docs/library/hierarchy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ hierarchy
"any":e -> "gir::callbackinstance":w;
"function":e -> "gir::function":w;
"stream":e -> "file":w;
"any":e -> "file::stat":w;
"enum":e -> "file::mode":w;
"sequence":e -> "dir":w;
"file":e -> "popen":w;
"state":e -> "compiler::function":w;
Expand Down
4 changes: 2 additions & 2 deletions docs/library/list.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ list
.. code-block:: mini
let L := list("cake") :> ["c", "a", "k", "e"]
L:random :> "a"
L:random :> "k"
L:random :> "e"
L:random :> "c"
:mini:`meth (Buffer: string::buffer):append(List: list)`
Expand Down
24 changes: 20 additions & 4 deletions docs/library/number.rst
Original file line number Diff line number Diff line change
Expand Up @@ -543,18 +543,24 @@ number
*TBD*


:mini:`def real::Inf: real`
Positive infinity.


:mini:`def real::NaN: real`
Not a number.


:mini:`def real::Inf: real`
Positive infinity.


:mini:`meth real(String: string): real | error`
Returns the real number in :mini:`String` or an error if :mini:`String` does not contain a valid real number.


:mini:`meth (Real₁: real) % (Real₂: real): integer`
Returns the remainder of :mini:`Real₁` divided by :mini:`Real₂`.
Note: the result is calculated by rounding towards 0. In particular, if :mini:`Real₁` is negative, the result will be negative.
For a nonnegative remainder, use :mini:`Real₁ mod Real₂`.


:mini:`meth complex(Arg₁: real)`
*TBD*

Expand All @@ -563,6 +569,16 @@ number
*TBD*


:mini:`meth (Real₁: real):div(Real₂: real): integer`
Returns the quotient of :mini:`Real₁` divided by :mini:`Real₂`.
The result is calculated by rounding down in all cases.


:mini:`meth (Int₁: real):mod(Int₂: real): integer`
Returns the remainder of :mini:`Int₁` divided by :mini:`Int₂`.
Note: the result is calculated by rounding down in all cases. In particular, the result is always nonnegative.


:mini:`meth number(String: string): integer | real | complex | error`
Returns the number in :mini:`String` or an error if :mini:`String` does not contain a valid number.

Expand Down
26 changes: 23 additions & 3 deletions docs/library/sequence.rst
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,18 @@ sequence
count2("banana") :> {"b" is 1, "a" is 3, "n" is 2}
:mini:`fun distill(Initial?: any, Sequence: sequence, Fn: function): any | nil`
Returns a sequence that produces :mini:`Initial`, :mini:`Fn(Initial, V₁)`, :mini:`Fn(Fn(Initial, V₁), V₂)`, ... .
If :mini:`Initial` is omitted, the first value produced by :mini:`Sequence` is used.

.. code-block:: mini
list(distill(1 .. 10, +))
:> [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]
list(distill(20, 1 .. 10, +))
:> [21, 23, 26, 30, 35, 41, 48, 56, 65, 75]
:mini:`fun fold(Sequence: sequence): sequence`
Returns a new sequence that treats alternating values produced by :mini:`Sequence` as keys and values respectively.

Expand Down Expand Up @@ -370,7 +382,11 @@ sequence
:mini:`meth (Sequence: sequence) // (Initial: any, Fn: function): sequence`
Returns an sequence that produces :mini:`Initial`, :mini:`Fn(Initial, V₁)`, :mini:`Fn(Fn(Initial, V₁), V₂)`, ... .
Returns a sequence that produces :mini:`Initial`, :mini:`Fn(Initial, V₁)`, :mini:`Fn(Fn(Initial, V₁), V₂)`, ... .

.. deprecated:: 2.9.0

Use :mini:`distill` instead.

.. code-block:: mini
Expand All @@ -379,7 +395,11 @@ sequence
:mini:`meth (Sequence: sequence) // (Fn: function): sequence`
Returns an sequence that produces :mini:`V₁`, :mini:`Fn(V₁, V₂)`, :mini:`Fn(Fn(V₁, V₂), V₃)`, ... .
Returns a sequence that produces :mini:`V₁`, :mini:`Fn(V₁, V₂)`, :mini:`Fn(Fn(V₁, V₂), V₃)`, ... .

.. deprecated:: 2.9.0

Use :mini:`distill` instead.

.. code-block:: mini
Expand Down Expand Up @@ -534,7 +554,7 @@ sequence

.. code-block:: mini
random("cake") :> "a"
random("cake") :> "k"
random([]) :> nil
Expand Down
2 changes: 1 addition & 1 deletion docs/library/time.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Provides time and date operations.

.. code-block:: mini
time() :> 2023-06-22T08:59:52.215403
time() :> 2023-07-23T22:01:49.308638
:mini:`meth time(Year: integer, Month: integer, Day: integer, Hour: integer, Minute: integer, Second: integer): time`
Expand Down
8 changes: 6 additions & 2 deletions docs/library/uuid.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@ uuid
.. code-block:: mini
import: uuid("util/uuid")
address(uuid()) :> <16:2A8CDE5B3B294C708B86B72948E6F388>
address(uuid()) :> <16:A99495CE237B40299D136FD31693E8EF>
:mini:`type uuid`
A UUID.


:mini:`meth uuid(Address: address): uuid | error`
Returns a new UUID with the bytes of :mini:`Address`.


:mini:`meth uuid(String: string): uuid | error`
Parses :mini:`String` as a UUID, returning an error if :mini:`String` does not have the correct format.

Expand All @@ -42,7 +46,7 @@ uuid
.. code-block:: mini
import: uuid("util/uuid")
uuid() :> daecb9b2-0ed9-4511-a85d-9590d03aa63a
uuid() :> 604d5ca3-5b06-4e38-8e77-cb1f3df2cab6
:mini:`meth (Arg₁: uuid) <> (Arg₂: uuid)`
Expand Down
4 changes: 2 additions & 2 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
sphinx == 4.5.0
sphinx
sphinxcontrib-domaintools
sphinxcontrib-fulltoc
sphinx_toolbox
sphinx-a4doc
sphinxawesome-theme == 3.3.7
sphinxawesome-theme
22 changes: 12 additions & 10 deletions src/build.rabs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ end
GC_DEBUG := defined("GC_DEBUG")

if DEBUG then
CFLAGS := old + ["-O1", "-g", "-DGC_DEBUG", "-DDEBUG"]
CFLAGS := old + ["-O1", "-g", "-DDEBUG"]
LDFLAGS := old + ["-g"]
GC_DEBUG and CFLAGS:put("-DGC_DEBUG")
elseif GC_DEBUG then
CFLAGS := old + ["-O3", "-g", "-DGC_DEBUG"]
LDFLAGS := old + ["-g"]
Expand Down Expand Up @@ -189,7 +190,8 @@ if MINILANG_STATICGC or defined("STATICGC") then
GC := Lib
PREBUILDS := old + [Lib]
CFLAGS := old + ['-I{PATH / "include"}']
LDFLAGS := old + ['-L{PATH / "lib"}', '-pthread']
Libraries:put(Lib)
:>LDFLAGS := old + ['-L{PATH / "lib"}', '-pthread']
end

if MINILANG_DEFAULTS or defined("DEFAULTS") then
Expand Down Expand Up @@ -479,10 +481,10 @@ if MINILANG_TRE then
:>execute("sed -i s/HAVE_WCTYPE/HAVE_WCTYPE_OFF/g config.h")
execute("make clean")
execute("make -j4 -C lib")
execute('make -j4 -C lib PREFIX={PATH} install')
end
PREBUILDS := old + [Lib]
CFLAGS := old + ["-DML_TRE", '-I{Dir / "lib"}']
:>LDFLAGS := old + ["-ltre"]
CFLAGS := old + ["-DML_TRE"]
Libraries:put(Lib)
end

Expand All @@ -500,15 +502,15 @@ end

if MINILANG_TIMEZONES then
let Header := file("timelib_mem.h")
let TIMELIB := file("timelib/timelib.a")[GC, Header] => fun(Target) do
let Lib := file("timelib/timelib.a")[GC, Header] => fun(Target) do
file("timelib"):rmdir
execute("git clone https://github.com/derickr/timelib.git", Dir)
file("timelib"):chdir
execute('make timelib.a FLAGS=\"{CFLAGS} -DHAVE_STDINT_H -DHAVE_GETTIMEOFDAY -DHAVE_UNISTD_H -DHAVE_DIRENT_H -I. --include {Header}\"')
end
PREBUILDS := old + [TIMELIB]
PREBUILDS := old + [Lib]
CFLAGS := old + ["-DML_TIMEZONES"]
Libraries:put(TIMELIB)
Libraries:put(Lib)
end

if MINILANG_UUID then
Expand All @@ -532,14 +534,14 @@ end

if PLATFORM = "Linux" then
Objects:put(file("linenoise.o"))
LDFLAGS := old + ["-lgc"]
GC or LDFLAGS := old + ["-lgc"]
elseif PLATFORM = "FreeBSD" then
Objects:put(file("linenoise.o"))
CFLAGS := old + ["-I/usr/local/include"]
LDFLAGS := old + ["-L/usr/local/lib", "-lgc-threaded"]
GC or LDFLAGS := old + ["-L/usr/local/lib", "-lgc-threaded"]
elseif PLATFORM = "Darwin" then
Objects:put(file("linenoise.o"))
LDFLAGS := old + ["-lgc"]
GC or LDFLAGS := old + ["-lgc"]
elseif PLATFORM = "Mingw" then
end

Expand Down
Loading

0 comments on commit 44627b7

Please sign in to comment.