Skip to content

Commit 8db9938

Browse files
committed
building integer
1 parent 8aef304 commit 8db9938

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed

doc/language/builtin/int.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Ranged integer
2+
3+
The basic integer used in the language.
4+
5+
```
6+
struct int[range : interval[long]] {
7+
let N = make_number_of_digits(range, register_type)
8+
let is_signed = range.low < 0
9+
var _digits : array[register_type, N]
10+
}
11+
```
12+
13+
```
14+
fn foo(x)
15+
{
16+
return x * 2
17+
}
18+
19+
var my_type = array[long, int[10..=12]];
20+
var foo = my_type();
21+
22+
fn bar(x : int[5..=6]) {
23+
foo[x * 2] = 42
24+
}
25+
26+
var my_enum = enum {
27+
red, green, blue
28+
};
29+
30+
var my_color_table_type = my_type
31+
my_color_table_type.index_type = my_enum
32+
var my_color_table = my_color_table_type();
33+
my_color_table[red] = 5
34+
35+
36+
```

doc/language/builtin/interval.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Interval
2+
3+
```
4+
struct range[T : type] {
5+
low : T
6+
high : T
7+
};
8+
```
9+
10+
A type performs interval arithmatic on numeric values.

doc/language/builtin/long.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Long Integer
2+
3+
A long integer is one that has a variable size.
4+
5+
## Internal Representation
6+
7+
```
8+
struct long {
9+
_data : u64
10+
_size : u32
11+
_capacity : u32
12+
}
13+
```
14+
15+
`_data` is a pointer to the a variable sized 2's compliment signed integer in
16+
native endian order. `_size` contains the number of 'digits' (a digit is
17+
an unsigned integer of the native register size). `_capacity` contains the
18+
number of bytes of the allocation.
19+
20+
If `_capacity` is zero, then `_data` contains the integer itself SIO
21+
(Short Integer Optimization).

0 commit comments

Comments
 (0)