From: fennecdjay Date: Fri, 5 Jul 2019 13:38:53 +0000 (+0200) Subject: :book: Docs X-Git-Tag: nightly~2349 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=54544585c6b8fe5dd35bb490bc8defb3b7404b43;p=gwion.git :book: Docs --- diff --git a/docs/01_Overview/00_First_Steps/01_InstallingGwion.md b/docs/01_Overview/00_First_Steps/01_InstallingGwion.md deleted file mode 100644 index 1e7717b2..00000000 --- a/docs/01_Overview/00_First_Steps/01_InstallingGwion.md +++ /dev/null @@ -1,39 +0,0 @@ -# Installing gwion - -## Get the sources - -The source is accessible on [github](https://github.com). - -Provided you have git installed, you can get it with: - -``` sh -git clone https://github.com/fennecdjay/gwion -``` - -then change to the source directory -``` sh -cd gwion -``` - -### Don't forget submodules - -You'll need the sources for all base module -``` sh -git submodule update --init util ast -``` - -> At this point, you might want to configure the build. - In this case, have a look at the [configuration page](Configure.md) - - -## Build the libraries and program -``` sh -make -``` - -## Install the package - -``` sh -make install -``` -> You may need root privilege to do this. diff --git a/docs/01_Overview/00_First_Steps/Configure.md b/docs/01_Overview/00_First_Steps/Configure.md deleted file mode 100644 index b05d398b..00000000 --- a/docs/01_Overview/00_First_Steps/Configure.md +++ /dev/null @@ -1,18 +0,0 @@ -# Configuring Gwion - -## util/config.mk - -double - -gettext - -memcheck - -lto - -coverage - -## ast/config.mk - -## config.mk -Here are a few choices left diff --git a/docs/01_Overview/BUILDING.md b/docs/01_Overview/BUILDING.md deleted file mode 100644 index 1babfe52..00000000 --- a/docs/01_Overview/BUILDING.md +++ /dev/null @@ -1,38 +0,0 @@ -# Build / Configure Gwion - -## Configure -### gwion-util - - * `USE_MEMCHECK`: compile with debug flags (`-g`) and enable asserts - * `USE_COVERAGE`: add coverage instrumentation - - -## Make -Basically, all that is left to do is -```sh -make -``` -The only environment variable affecting the operation is `PREFIX` - -Except `--(no-)double`, everything can be set when running make, -using environment variables. - -Drivers can be set on using, e.g. for *alsa* : `ALSA_D=1` or `ALSA_D=on`. -In the same way, then can be disabled with `ALSA_D=0` or `ALSA_D=off` - -### Running tests -```bash -make tests -``` -to run all tests, or -```bash -bash util/test.sh my_file_or_directory (.. other files/dirs ...) -``` -to run specific ones. -look [here](#testing.md) for more. -## Install -*maybe as root* -```sh -make install -``` -The only environment variable affecting the operation is `PREFIX` diff --git a/docs/01_Overview/Keywords.md b/docs/01_Overview/Keywords.md deleted file mode 100644 index 0f8af7ce..00000000 --- a/docs/01_Overview/Keywords.md +++ /dev/null @@ -1,31 +0,0 @@ -# Keywords - - * fun/function - * operator - * return - * goto - * switch/case/default - * if/else - * break/continue - * until/do/while/for/repeat - - - - - * global/static - * private/protect - * const - - * new - * spork - * fork - * typeof - - * typedef - * class - * dtor - * extends - * enum - * union - - * auto diff --git a/docs/01_Overview/Make.md b/docs/01_Overview/Make.md deleted file mode 100644 index 45a5452d..00000000 --- a/docs/01_Overview/Make.md +++ /dev/null @@ -1,7 +0,0 @@ -# Makefile - -## Basic operations - -## translations - -## Docs diff --git a/docs/01_Overview/SpecialWords.md b/docs/01_Overview/SpecialWords.md deleted file mode 100644 index 3b4286a9..00000000 --- a/docs/01_Overview/SpecialWords.md +++ /dev/null @@ -1,6 +0,0 @@ -# Special Values - - * me - * this - * vararg - * maybe diff --git a/docs/01_Overview/Testing.md b/docs/01_Overview/Testing.md deleted file mode 100644 index 3c3a79dd..00000000 --- a/docs/01_Overview/Testing.md +++ /dev/null @@ -1,28 +0,0 @@ -# Tests -[test.sh](https://github.com/fennecdjay/Gwion/blob/dev/util/test.sh) -requires [valgrind](http://valgrind.org/) -there are two kinds of tests: - * [gwion](#gwion-tests) - * [bash](#bash-tests) - -## Gwion tests -those tests are just gwion (.gw) files, handling special comments: - * `// [skip]` (*optionally* followed by reason to skip) - * `// [todo]` (*optionally* followed by reason to delay testing) - * `// [contains]` followed by string to match - * `// [excludes]` followed by string not to match - -## Shell test -those tests are just bash (.sh) files. -they should start with this snippet -```bash -#!/bin/bash -# [test] #5 -n=0 -[ "$1" ] && n="$1" -[ "$n" -eq 0 ] && n=1 -source tests/sh/common.sh -``` - -## TODO - [ ] `bailout` system for early exit on failure diff --git a/docs/01_Overview/declaration.md b/docs/01_Overview/declaration.md deleted file mode 100644 index fcf06718..00000000 --- a/docs/01_Overview/declaration.md +++ /dev/null @@ -1,50 +0,0 @@ -# Declarations - -## Basics - -Declaring a primitive or an object is quite straight forward: -``` gw -int i; -Object o; -<<>>; -``` -0 0x56418af88660 - -## Declaring a reference -However ... -``` gw -Object @ref; -<<<"Reference points to no object yet: ", ref>>>; -//Object o @=> ref; -new Object @=> ref; -<<<"But now it does: ", ref>>>; -``` -make[1] : on entre dans le répertoire « /home/djay/src/git/gwion/gwion-github » -

-(int[]) (nil)
-(int[]) 0x4dedc10
-t: (nil)
-But now it does: 0x4dedc30
-✔ -

-make[1] : on quitte le répertoire « /home/djay/src/git/gwion/gwion-github » - -## Arrays - -### array as refs - -``` gw -int ref[]; -<<>>; -new int[2] @=> ref; -<<>>; -``` -make[1] : on entre dans le répertoire « /home/djay/src/git/gwion/gwion-github » -

-(int[]) (nil)
-(int[]) 0x4dedc10
-t: (nil)
-But now it does: 0x4dedc30
-✔ -

-make[1] : on quitte le répertoire « /home/djay/src/git/gwion/gwion-github » diff --git a/docs/01_Overview/globalvalues.md b/docs/01_Overview/globalvalues.md deleted file mode 100644 index 81566954..00000000 --- a/docs/01_Overview/globalvalues.md +++ /dev/null @@ -1,16 +0,0 @@ -# Global Values - - * adc - * blackhole - * dac - * pi - * null - * samp - * ms - * second - * hour - * me - * this - * \__func__ - * \__file__ - * \__line__ diff --git a/docs/02_Reference/01_Functions/Lambdas.md b/docs/02_Reference/01_Functions/Lambdas.md deleted file mode 100644 index bf261a83..00000000 --- a/docs/02_Reference/01_Functions/Lambdas.md +++ /dev/null @@ -1,46 +0,0 @@ -# Lambda - -## Overview - -Simply put, *lambda*s are anonymous functions. - -The syntax to create them is simple: -``` -\ variable0 variable1 ... { your code here } -``` -You can even use it to -### Call a function just once -``` gw -\ i { <<<"passed '", i, "'">>>; }(3); -``` -

-passed '3'
-✔ -

- - -## Use case - -### Passing to a function pointer -``` gw -typedef void fptr_t(int); -\ i { <<<"passed '", i, "'">>>; } @=> fptr_t fptr; -fptr(4); -``` -

-passed '4'
-✔ -

- -### As Argument to Functions -``` gw -typedef void fptr_t(int); -fun void test(fptr_t fptr) { - fptr(5); -} -test(\ i { <<<"passed '", i, "'">>>; }); -``` -

-passed '5'
-✔ -

diff --git a/docs/02_Reference/01_Functions/Variadic.md b/docs/02_Reference/01_Functions/Variadic.md deleted file mode 100644 index 092b3dd0..00000000 --- a/docs/02_Reference/01_Functions/Variadic.md +++ /dev/null @@ -1,18 +0,0 @@ -# Variadic functions - -> A function whoses arity is not fixed. - -Well, a function that takes a fixed number of arguments, and additionnal ones. - -## a simple example -``` gw -fun void variadic_test(int i, ...) { - <<< "first argument is ", i >>>; - vararg.start; - <<< "\tadditionnal argument", vararg.i >>>; - vararg.end; -} -variadic_test(1); -variadic_test(1, 2); -variadic_test(1, 2, 3); -``` diff --git a/docs/02_Reference/01_Functions/function.md b/docs/02_Reference/01_Functions/function.md deleted file mode 100644 index d5034ef9..00000000 --- a/docs/02_Reference/01_Functions/function.md +++ /dev/null @@ -1,23 +0,0 @@ -# Functions - -## a simple (commented example) - -``` gw -// declare function 'test_function' -// with return type int -// taking an int as argument -fun int test_function(int arg) { - // return the argument + 2 - return arg + 2; -} - -// now call the function (and debug print the result) -<<>>; -// or use alternate syntax -<<<1 => test_function>>>; -``` -

-(int) 2
-(int) 3
-✔ -

diff --git a/docs/02_Reference/ControlFlow/ControlFlow.md b/docs/02_Reference/ControlFlow/ControlFlow.md deleted file mode 100644 index 2e9c1854..00000000 --- a/docs/02_Reference/ControlFlow/ControlFlow.md +++ /dev/null @@ -1,4 +0,0 @@ -# Control Flow - -## Repeats -let start simple ;-) diff --git a/docs/02_Reference/ControlFlow/Loops.md b/docs/02_Reference/ControlFlow/Loops.md deleted file mode 100644 index 4b787b4b..00000000 --- a/docs/02_Reference/ControlFlow/Loops.md +++ /dev/null @@ -1 +0,0 @@ -# Loops diff --git a/docs/02_Reference/ControlFlow/forloop.md b/docs/02_Reference/ControlFlow/forloop.md deleted file mode 100644 index 8510a1e5..00000000 --- a/docs/02_Reference/ControlFlow/forloop.md +++ /dev/null @@ -1,111 +0,0 @@ -# For Loops -**For** loops in Gwion is pretty similar to classic **C** syntax - -## basic loops -``` gw -for(int i; i < 3; ++i) - <<>>; -``` -

-(int) 0
-(int) 1
-(int) 2
-✔ -

- -Of course, it also works with a block of code. - -``` gw -for(int i; i < 3; ++i) { - i/2 => float f1; - i/2. => float f2; - <<>>; -} -``` -

-0 0.0000 0.0000
-1 0.0000 0.5000
-2 1.0000 1.0000
-✔ -

- -## Nested Loops -``` gw -int array[3][4]; - -for(int i; i < 3; ++i) { - for(int j; j < 4; ++j) { - <<>>; - } -} -``` -

-(int) 0
-(int) 0
-(int) 0
-(int) 0
-(int) 0
-(int) 0
-(int) 0
-(int) 0
-(int) 0
-(int) 0
-(int) 0
-(int) 0
-✔ -

- -### Auto Loops - -#### Simple auto loop -``` gw -int array[2][3]; -for(auto a: array) { - <<>>; - for(auto b: a) - <<>>; -} -``` -

-(int[]) 0x4e0ff00
-(int) 0
-(int) 0
-(int) 0
-(int[]) 0x4e0ff20
-(int) 0
-(int) 0
-(int) 0
-✔ -

- -### Auto Pointer loop -With the simple auto loop, you only get the value in the array. -If you want to change it, you need a pointer - -``` gw -int array[2][3]; -int i; -for(auto a: array) { - for(auto @b: a) - <<<++i => *b>>>; -} -for(auto a: array) { - for(auto @b: a) - <<<*b>>>; -} -``` -

-(int) 1
-(int) 2
-(int) 3
-(int) 4
-(int) 5
-(int) 6
-(int) 1
-(int) 2
-(int) 3
-(int) 4
-(int) 5
-(int) 6
-✔ -

diff --git a/docs/02_Reference/Extending/WIP_Driver.md b/docs/02_Reference/Extending/WIP_Driver.md deleted file mode 100644 index 20478632..00000000 --- a/docs/02_Reference/Extending/WIP_Driver.md +++ /dev/null @@ -1,9 +0,0 @@ -# Giving gwion a new driver - -## basics - -> in order to use GWION_CTL ... - -# concept - -# upd driver diff --git a/docs/02_Reference/Extending/WIP_Plugins.md b/docs/02_Reference/Extending/WIP_Plugins.md deleted file mode 100644 index cd1822fd..00000000 --- a/docs/02_Reference/Extending/WIP_Plugins.md +++ /dev/null @@ -1,68 +0,0 @@ -# Writing a Gwion plugin - -> THIS IS OUTDATED. please look at the source code in src/lib/ instead - - * [getting started] - -## Getting started -use the script - -### headers -``` -#include "vm.h" -#include "instr.h" -#include "import.h -``` - - -### Class -Define the type: -``` -struct Type_ t_mytype = { "MyType", SZ_INT, &t_object}; -``` -> every type extending t_object should have SZ_INT - -### Handling Constructors and Destructors -#### CTOR -``` -CTOR(mytype_ctor) { - /* constructor code here */ -} -``` -#### DTOR -``` -DTOR(mytype_dtor) { - /* destructor code here */ -} -``` - -those macros provide two variables: - * `o`: the *M_Object* for the (con/des)tructor - * `shred`: the *VM_Shred* for the (con/des)tructor - -``` -CHECK_BB(import_class_begin(env, &t_mytpe, env->global_nspc, mytype_ctor, mytype_dtor)) -``` -#### variable -declare a `m_int`. coding convention require - * a leading *_o* - * a following *_type_* -```c -m_int o_mytype_myvaroffset; -``` -#### function -```c -/* declare a member function */ -MFUN(mytype_memberfunction) { - /* code here */ -} - -SFUN(mtype_staticfunction) { - /* code here */ -} -``` - -#### operator - -### Import function - diff --git a/docs/Extending/WIP_Driver.md b/docs/Extending/WIP_Driver.md deleted file mode 100644 index 20478632..00000000 --- a/docs/Extending/WIP_Driver.md +++ /dev/null @@ -1,9 +0,0 @@ -# Giving gwion a new driver - -## basics - -> in order to use GWION_CTL ... - -# concept - -# upd driver diff --git a/docs/Extending/WIP_Plugins.md b/docs/Extending/WIP_Plugins.md deleted file mode 100644 index cd1822fd..00000000 --- a/docs/Extending/WIP_Plugins.md +++ /dev/null @@ -1,68 +0,0 @@ -# Writing a Gwion plugin - -> THIS IS OUTDATED. please look at the source code in src/lib/ instead - - * [getting started] - -## Getting started -use the script - -### headers -``` -#include "vm.h" -#include "instr.h" -#include "import.h -``` - - -### Class -Define the type: -``` -struct Type_ t_mytype = { "MyType", SZ_INT, &t_object}; -``` -> every type extending t_object should have SZ_INT - -### Handling Constructors and Destructors -#### CTOR -``` -CTOR(mytype_ctor) { - /* constructor code here */ -} -``` -#### DTOR -``` -DTOR(mytype_dtor) { - /* destructor code here */ -} -``` - -those macros provide two variables: - * `o`: the *M_Object* for the (con/des)tructor - * `shred`: the *VM_Shred* for the (con/des)tructor - -``` -CHECK_BB(import_class_begin(env, &t_mytpe, env->global_nspc, mytype_ctor, mytype_dtor)) -``` -#### variable -declare a `m_int`. coding convention require - * a leading *_o* - * a following *_type_* -```c -m_int o_mytype_myvaroffset; -``` -#### function -```c -/* declare a member function */ -MFUN(mytype_memberfunction) { - /* code here */ -} - -SFUN(mtype_staticfunction) { - /* code here */ -} -``` - -#### operator - -### Import function - diff --git a/docs/assets/benchmark/binary-trees.dat b/docs/assets/benchmark/binary-trees.dat index bc78c854..fb8e99ce 100644 --- a/docs/assets/benchmark/binary-trees.dat +++ b/docs/assets/benchmark/binary-trees.dat @@ -1,3 +1,3 @@ -gwion 0.18650 0.58 -wren 0.23149 1.00 -lua 0.30273 1.31 +gwion 0.191172 0.51 +wren 0.23937 0.44 +lua 0.30958 0.46 diff --git a/docs/assets/benchmark/binary-trees.png b/docs/assets/benchmark/binary-trees.png index a69a778d..61bef3ec 100644 Binary files a/docs/assets/benchmark/binary-trees.png and b/docs/assets/benchmark/binary-trees.png differ diff --git a/docs/assets/benchmark/fib-recurs.dat b/docs/assets/benchmark/fib-recurs.dat index 68f31f11..2a8f7e6b 100644 --- a/docs/assets/benchmark/fib-recurs.dat +++ b/docs/assets/benchmark/fib-recurs.dat @@ -1,3 +1,3 @@ -gwion 5.2823 0.38 -wren 13.4943 0.44 -lua 7.3512 0.89 +gwion 5.3121 0.52 +wren 13.5283 0.47 +lua 7.4075 0.63 diff --git a/docs/assets/benchmark/fib-recurs.png b/docs/assets/benchmark/fib-recurs.png index 12e95df9..085ab844 100644 Binary files a/docs/assets/benchmark/fib-recurs.png and b/docs/assets/benchmark/fib-recurs.png differ diff --git a/docs/assets/benchmark/fib.dat b/docs/assets/benchmark/fib.dat index 5ca617ec..fa2a73ca 100644 --- a/docs/assets/benchmark/fib.dat +++ b/docs/assets/benchmark/fib.dat @@ -1,3 +1,3 @@ -gwion 0.084083 0.72 -wren 0.210827 0.32 -lua 0.209405 0.47 +gwion 0.086447 0.50 +wren 0.22208 0.66 +lua 0.21990 0.76 diff --git a/docs/assets/benchmark/fib.png b/docs/assets/benchmark/fib.png index 039ee7d7..67fe777e 100644 Binary files a/docs/assets/benchmark/fib.png and b/docs/assets/benchmark/fib.png differ diff --git a/docs/assets/benchmark/method-call.dat b/docs/assets/benchmark/method-call.dat index 21a3b323..721144b6 100644 --- a/docs/assets/benchmark/method-call.dat +++ b/docs/assets/benchmark/method-call.dat @@ -1,3 +1,3 @@ -gwion 0.09491 1.85 -wren 0.11345 5.40 -lua 0.25868 1.48 +gwion 0.091942 0.20 +wren 0.108581 0.42 +lua 0.25822 1.11 diff --git a/docs/assets/benchmark/method-call.png b/docs/assets/benchmark/method-call.png index da5d03be..90dfb94f 100644 Binary files a/docs/assets/benchmark/method-call.png and b/docs/assets/benchmark/method-call.png differ diff --git a/docs/index.md b/docs/index.md deleted file mode 100644 index dcc9457d..00000000 --- a/docs/index.md +++ /dev/null @@ -1,26 +0,0 @@ -# Welcome to Gwion - -gwion is a easy yet powerful, strongly-timed programming language, - -## And now for the hello world - -So, as it is mandatory, here is the piece of code you're waiting -for: - -``` gw -<<<"Hello, World!", "">>>; -``` -

-Hello, World!
-✔ -

- -## (Bag of) Features - * horizontal inheritance - * typedef (function pointers and type aliases) - * enums and unions - * templates (both class and functions) - * easy concurrency/async - * [lambdas](Functions/Lambdas) - * memoization - * [variadic](Functions/Variadic) functions