rlang 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f054ef2e82e78f558e0009be4172691837965fdde99c73cba4003754445d55c4
4
- data.tar.gz: 5faf8f230a9f810b4db1219e8ecfcf6eab85c7bb253b5a6f691ae10070f5c601
3
+ metadata.gz: 2faf9d24b118829cdd2317c26e88bd720a97ccd04844469798640596284aad82
4
+ data.tar.gz: 2e1cd589da638a7711022e08a6f4c7070ce26e36c0dd7dcaef4520e404f12cc4
5
5
  SHA512:
6
- metadata.gz: a945ad14f3a76f454fdab52def8d61916fe429fdc44acc5497d5d741bb96177849c01efbe304774e34f0ab2ec84fbc9927e3fd9dcf523233f0e31cdaabd73733
7
- data.tar.gz: 5057fb8e68fcd98bb5d76993550cfbc4c06211ec8424261862545cba9905348db52d884049fd3d26c39f3e0df61127b65b9953abe14753d75523a6d6677fe648
6
+ metadata.gz: e050812a81279acc76f15e191d40510e575e4f0dd935883b3292a3a2ca14b497b82b0d0185feccc79b4250f8e510c73c4c44c788a904e3083c28a5f14a213920
7
+ data.tar.gz: c689cfb6e10ec680592629f7e4c71ec44d4abd1b4e8723284633676765d189e29d5c8dd3c81ee71bcfd02597173798550b87b9ec0a7d15623a7bc53c0493eeca
data/.gitignore CHANGED
@@ -7,4 +7,6 @@
7
7
  /spec/reports/
8
8
  /tmp/
9
9
  # added for rlang
10
- *.gem
10
+ *.gem
11
+ *~
12
+ .rake_tasks
data/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ ## 0.3.1
2
+ * Add ruby parser as runtime dependency in gemspec
3
+ * DAta directive documented in Rlang manual
4
+
5
+ ## 0.3.0
6
+ * First published release on rubygems.org
data/Gemfile.lock ADDED
@@ -0,0 +1,30 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rlang (0.3.0)
5
+ parser
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ast (2.4.0)
11
+ minitest (5.14.0)
12
+ parser (2.7.0.2)
13
+ ast (~> 2.4.0)
14
+ rake (12.3.3)
15
+ rutie (0.0.4)
16
+ wasmer (0.3.0)
17
+ rutie (~> 0.0.3)
18
+
19
+ PLATFORMS
20
+ ruby
21
+
22
+ DEPENDENCIES
23
+ bundler (~> 2.0)
24
+ minitest (~> 5.0)
25
+ rake (~> 12.0)
26
+ rlang!
27
+ wasmer (~> 0.3)
28
+
29
+ BUNDLED WITH
30
+ 2.0.2
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Rlang : a (subset of) Ruby to WebAssembly compiler
2
2
 
3
- Rlang is meant to create fast and uncluttered [WebAssembly](https://webassembly.org) code from the comfort of the Ruby language.
3
+ Rlang is meant to generate fast and uncluttered [WebAssembly](https://webassembly.org) code from the comfort of the Ruby language.
4
4
 
5
- Rlang actually two things: 1) a subset of the Ruby language and 2) a **compiler** transforming this Ruby subset in a valid, fully runnable and native WebAssembly module.
5
+ Rlang is two things: 1) a subset of the Ruby language and 2) a **compiler** transforming this Ruby subset in a valid, fully runnable and native WebAssembly module.
6
6
 
7
7
  Rlang can be seen as a foundational language that can help you quickly develop and debug high performance WebAssembly modules. For the rationale behind the creation of Rlang see [below](#why-rlang).
8
8
 
@@ -10,7 +10,7 @@ What you'll find in the current version is a first implementation of Rlang. It w
10
10
 
11
11
  ## Dependencies
12
12
 
13
- * **WABT toolit**: the rlang compiler can generate both WebAssembly source code (WAT file) and WebAssembly bytecode (WASM file). To generate WASM bytecode the rlang compiler uses wat2wasm. This utility is part of the [WABT toolkit](https://github.com/WebAssembly/wabt)
13
+ * **WABT toolkit**: the rlang compiler can generate both WebAssembly source code (WAT file) and WebAssembly bytecode (WASM file). To generate WASM bytecode the rlang compiler uses wat2wasm. This utility is part of the [WABT toolkit](https://github.com/WebAssembly/wabt)
14
14
  * **wasmer runtime** (optional): [Wasmer](https://wasmer.io/) is a fast WebAssembly runtime. You'll need it if you want to run the test suite from the source repo. You can also use it to run the compiled WASM code generated by the rlang compiler. You can get Wasmer at [wasmer.io](https://wasmer.io/)
15
15
 
16
16
 
@@ -32,7 +32,9 @@ To check that the installation went well, run `rlang --help` and see if the help
32
32
  ## The Rlang language
33
33
  Ruby features supported by Rlang are detailed in the [Rlang Manual](https://github.com/ljulliar/rlang/blob/master/docs/RlangManual.md)
34
34
 
35
- You can also look at the rlang test suite in [test/rlang_test_files](https://github.com/ljulliar/rlang/blob/master/test/rlang_test_files/) to get a flavor of the subset of Ruby currently supported.
35
+ You can look at the rlang test suite in [test/rlang_test_files](https://github.com/ljulliar/rlang/blob/master/test/rlang_test_files/) to get a flavor of the subset of Ruby currently supported.
36
+
37
+ For a more involved example of Ruby code, I invite you to look at the [dynamic memory allocator](https://github.com/ljulliar/rlang/blob/master/lib/rlang/lib/malloc.rb) provided with the Rlang library.
36
38
 
37
39
  ## rlang compiler
38
40
  The Rlang compiler can be invoked through the `rlang` command. See the [Rlang Compiler Documentation](https://github.com/ljulliar/rlang/blob/master/docs/RlangCompiler.md) for more details about the command line options.
data/docs/RlangManual.md CHANGED
@@ -21,6 +21,7 @@ Rlang provides:
21
21
  * Integers and booleans
22
22
  * Constants
23
23
  * Global variables
24
+ * Static Data
24
25
  * Control constructs (if, while, until, break, next,...)
25
26
  * Arithmetic, relational and logical operators
26
27
  * WebAssembly source code (WAT) inlining
@@ -290,6 +291,31 @@ class TestB
290
291
  end
291
292
  end
292
293
  ```
294
+ ## Static Data
295
+ WebAssembly allows for the definition of static data stored the WebAssembly memory. Rlang provides the ability to both define the value of static data and reference this data in your Rlang code.
296
+
297
+ You can define static data by using the **DAta** class. Note that the upper case **A** in DAta is not a typo. The Data (with lower case a) class cannot be used as it is already defined by Ruby.
298
+
299
+ Let's see a few examples of how to define and reference static data:
300
+
301
+ ```ruby
302
+ # Where to implant the data in memory
303
+ # Here we start at address 2048 in memory
304
+ DAta.address = 2048
305
+ # a long (I32) integer (4 bytes in memory)
306
+ DAta[:my_integer] = 16384
307
+ # a null terminated string (13 bytes)
308
+ DAta[:my_string] = "Hello World!\00"
309
+ # Align to the next multiple of 4 in memory
310
+ DAta.align(4)
311
+ # a series of four I32 integers followed by a fifth
312
+ # integer that points to the address of :my_first_string
313
+ DAta[:my_series] = [1, 2, 3, 4, Data[:my_first_string]]
314
+ ```
315
+ The last example shows how to reference an existing piece of static data using `DAta[:label]` where `:label` is the label you used in the first place to define your data. Data reference can either be used in static data definition or anywhere in the Rlang code.
316
+
317
+ Also note that data are implanted in memory in sequential order. In the example above `:my_integer` is stored at address 2048 to 2051 (4 bytes), `:my_string` goes from 2052 to 2064 (13 bytes). Without the `DAta.align(4)` directive the next integer from `:my_series` would use bytes 2065 to 2068. Here it will actually use bytes 2068 to 2071 and the 3 bytes at address 2065 to 2067 will actually be unused.
318
+
293
319
 
294
320
  ## Conditional statements
295
321
  Rlang supports the following Ruby conditional statements:
@@ -62,7 +62,7 @@ module Rlang::Parser
62
62
  end
63
63
  end
64
64
 
65
- def self.current_address=(address)
65
+ def self.address=(address)
66
66
  @@current_address = address
67
67
  end
68
68
 
data/lib/rlang/parser.rb CHANGED
@@ -883,10 +883,10 @@ module Rlang::Parser
883
883
  # Special case : DAta initializers
884
884
  #
885
885
  # Example (setting DAta address)
886
- # DAta.current_address = 0
886
+ # DAta.address = 0
887
887
  # ---------
888
888
  # (send
889
- # (const nil :DAta) :current_address=
889
+ # (const nil :DAta) :address=
890
890
  # (int 0))
891
891
  #
892
892
  # Example (setting DAta alignment)
@@ -950,10 +950,10 @@ module Rlang::Parser
950
950
 
951
951
  if recv_node.type == :const && recv_node.children.last == :DAta
952
952
  case method_name
953
- when :current_address=
953
+ when :address=
954
954
  value_node = node.children[2]
955
955
  raise "DAta address must be an integer" unless value_node.type == :int
956
- DAta.current_address = value_node.children.last
956
+ DAta.address = value_node.children.last
957
957
  when :align
958
958
  value_node = node.children[2]
959
959
  raise "DAta alignment argument must be an integer" unless value_node.type == :int
data/lib/rlang/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rlang
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -65,7 +65,7 @@ class DAta
65
65
  end
66
66
  end
67
67
 
68
- def self.current_address=(address)
68
+ def self.address=(address)
69
69
  @@current_address = address
70
70
  end
71
71
 
data/rlang.gemspec CHANGED
@@ -31,8 +31,10 @@ Gem::Specification.new do |spec|
31
31
  spec.executables << "rlang"
32
32
  spec.require_paths = ["lib"]
33
33
 
34
+ spec.add_runtime_dependency 'parser'
35
+
34
36
  spec.add_development_dependency "bundler", "~> 2.0"
35
- spec.add_development_dependency "rake", "~> 10.0"
37
+ spec.add_development_dependency "rake", "~> 12.0"
36
38
  spec.add_development_dependency "minitest", "~> 5.0"
37
39
  spec.add_development_dependency "wasmer", "~> 0.3"
38
40
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rlang
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Laurent Julliard
@@ -10,6 +10,20 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2020-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: parser
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -30,14 +44,14 @@ dependencies:
30
44
  requirements:
31
45
  - - "~>"
32
46
  - !ruby/object:Gem::Version
33
- version: '10.0'
47
+ version: '12.0'
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
52
  - - "~>"
39
53
  - !ruby/object:Gem::Version
40
- version: '10.0'
54
+ version: '12.0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: minitest
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -78,10 +92,11 @@ extensions: []
78
92
  extra_rdoc_files: []
79
93
  files:
80
94
  - ".gitignore"
81
- - ".rake_tasks~"
82
95
  - ".travis.yml"
96
+ - CHANGELOG.md
83
97
  - CODE_OF_CONDUCT.md
84
98
  - Gemfile
99
+ - Gemfile.lock
85
100
  - LICENSE
86
101
  - README.md
87
102
  - Rakefile
data/.rake_tasks~ DELETED
File without changes