summaryrefslogtreecommitdiff
blob: d0462a05cddb5d003791d342a82a9e2630e1cf33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
---
menuTitle: <Computation>
title: Computation
weight: 3
---
This page presents all the `<Computation>`s that can be performed in Wyrd.
`<Computation>`s do not modify the memory, but they always return a `<Value>`.

**Shortcut to each `<Computation>`:**
* [`(add_text_effect {name: String} {parameters: <Computation> List} {values: <Computation> list})`](#add_text_effect)
* [`(address <value_or_target: Computation>)`](#address)
* [`(cast {from: String} {to: String} <content: Computation>)`](#cast)
* [`(constant {type: String} {value: String})`](#constant)
* [`(get_allocable_address)`](#get_allocable_address)
* [`(if_else <condition: Computation> <if_true: Computation> <if_false: Computation>)`](#if_else)
* [`(last_choice_index)`](#last_choice_index)
* [`(newline)`](#newline)
* [`(operation {operator: String} <x: Computation>)`](#unary-operation)
* [`(operation {operator: String} <x: Computation> <y: Computation>)`](#operation)
* [`(relative_address <target: Computation> <extra: Computation>)`](#relative_address)
* [`(size <target: Computation>)`](#target)
* [`(text {values: <Computation> List})`](#text)
* [`(value_of <target: Computation>)`](#value_of)
* [`({extra_computation} {parameters: <Computation> List})`](#extra_computation)

### add_text_effect
`(add_text_effect {name: String} {parameters: <Computation> List} {values: <Computation> list})`

Add an effect to a list of texts, returning it as a single text.

**Parameters:**
* `name` is a `{String}` indicating the name of the effect.
* `parameters` is a `{List}` of `<Computation>` that will yield the `<Value>`s
   used as parameters for the effect.
* `values` is a `{<Computation> List}` that will yield the texts to merge and
   apply the effect to. These will yield `<TextValue>`s.

**Process:**
* Compute the `{params: <Value> List}` corresponding to `parameters` (keep the
   order).
* Compute the `{texts: <Value> List}` corresponding to `values` (keep the
   order).
* Return a new `<AugmentedText>` `<TextValue>` with `texts` as `content`,
   `name` as `effect_name`, and `params` as `effect_parameters`.

### address
`(address <value_or_target: Computation>)`

Converts to an address.

**Parameters:**
* `value_or_target` is a `<Computation>` that will either result in in a
   `<PointerValue>` or a `<StringValue>`.

**Process:**
* Compute the `<Value>` corresponding to `value_or_target`.
* If this resulted in a `<PointerValue>`, return the value as is.
* If this resulted in a `<StringValue>`, interpret the value as
   `{addr: String}`, return a new `<PointerValue>` built from a singleton list
   with `addr` as its only element.

### cast
`(cast {from: String} {to: String} <content: Computation>)`

Convert from one type to another.

**Parameters:**
* `from` is a `{String}` naming the type `content` will result to.
* `to` is a `{String}` naming the type to convert `content` to.
* `content` is a `<Computation>` that will yield the `<Value>` to convert.

**Process:**
* Compute the `<Value>` associate with `content`.
* Convert this `<Value>` from `from` to `to`.
* Return the converted value.

**Note:**
The following conversions are expected to be available:
* A type to the same type, returning the same value.
* `<BoolValue>` to `<StringValue>`, returning `(StringValue "true")` if
   `<Value>` is `(BoolValue TRUE)` and `(StringValue "false")` otherwise.
* `<BoolValue>` to `<TextValue>`, same as above, but with text instead of
  string.
* `<FloatValue>` to `<StringValue>`.
* `<FloatValue>` to `<TextValue>`.
* `<FloatValue>` to `<IntValue>`, using a *floor* function.
* `<IntValue>` to `<StringValue>`.
* `<IntValue>` to `<TextValue>`.
* `<IntValue>` to `<FloatValue>`.
* `<IntValue>` to `<BoolValue>`, with `0` being `(BoolValue FALSE)` and
   anything else being `(BoolValue TRUE)`.
* `<StringValue>` to `<FloatValue>`.
* `<StringValue>` to `<IntValue>`.
* `<StringValue>` to `<BoolValue>`, `(BoolValue TRUE)` if the string is
   `"true"`, `(BoolValue FALSE)` if it is `"false"`. Convert to lowercase prior
   to checking.
* `<TextValue>` to `<StringValue>`, by recursively converting all content to
   `{String}`, discarding effects and newlines, and appending it all.
* `<TextValue>` to `<IntValue>`, by converting it to `<StringValue>` first.
* `<TextValue>` to `<FloatValue>`, by converting it to `<StringValue>` first.
* `<TextValue>` to `<BoolValue>`, by converting it to `<StringValue>` first.

### constant
`(constant {type: String} {value: String})`

**Parameters:**

**Process:**

### get_allocable_address
`(get_allocable_address)`

**Process:**

### if_else
`(if_else <condition: Computation> <if_true: Computation> <if_false: Computation>)`

**Parameters:**

**Process:**

### last_choice_index
`(last_choice_index)`

**Process:**

### newline
`(newline)`

**Process:**

### Unary operation
`(operation {operator: String} <x: Computation>)`

**Parameters:**

**Process:**

### operation
`(operation {operator: String} <x: Computation> <y: Computation>)`

**Parameters:**

**Process:**

### relative_address
`(relative_address <target: Computation> <extra: Computation>)`

**Parameters:**

**Process:**

### size
`(size <target: Computation>)`

**Parameters:**

**Process:**

### text
`(text {values: <Computation> List})`

**Parameters:**

**Process:**

### value_of
`(value_of <target: Computation>)`

**Parameters:**

**Process:**

### extra_computation
`({extra_computation} {parameters: <Computation> List})`

**Parameters:**

**Process:**