Skip to content

Commit e2a3f44

Browse files
committed
Changed from Generator to Trnasformer everywhere.
1 parent 1fe0261 commit e2a3f44

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+376
-362
lines changed

Makefile

+5-5
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ database/string.c \
5454
database/util.c \
5555
database/value.c \
5656
database/variable.c \
57-
generator/constprop.c \
58-
generator/generator.c \
59-
generator/iterator.c \
60-
generator/memmanage.c \
57+
transformer/constprop.c \
58+
transformer/transformer.c \
59+
transformer/iterator.c \
60+
transformer/memmanage.c \
6161
llvm/debug.c \
6262
llvm/genllvm.c \
6363
llvm/lldatabase.c \
@@ -145,7 +145,7 @@ clean:
145145
cd bootstrap/database ; make clean
146146

147147
obj: include/dedatabase.h llvm/lldatabase.h
148-
mkdir -p obj/database obj/llvm obj/parse obj/runtime obj/src obj/util obj/rpc obj/bind obj/generator
148+
mkdir -p obj/database obj/llvm obj/parse obj/runtime obj/src obj/util obj/rpc obj/bind obj/transformer
149149

150150
obj/%.o: %.c $(DEPS)
151151
$(CC) $(CFLAGS) -c -o $@ $<

README.md

+11-6
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@ than C++ for most memory-intensive applications, due to its Structure-of-Array
2626
\([SoA](https://en.wikipedia.org/wiki/AoS_and_SoA#:~:text=AoS%20vs.,AoS%20case%20easier%20to%20handle.)\)
2727
memory management.
2828

29-
It provides many of its features by deeply integrating the ["DataDraw"](https://datadraw.sourceforge.net) tool into the primitives and constructs of the language. DataDraw is a code-generation tool that generates highly-optimized C code which outperforms e.g., the C++ STL given a declarative description of data-structures and relationships between them. For more information, see the [DataDraw 3.0 Manual](https://datadraw.sourceforge.net/manual.pdf).
29+
It provides many of its features by deeply integrating features similar to the
30+
["DataDraw"](https://datadraw.sourceforge.net) tool into the primitives and
31+
constructs of the language. DataDraw is a code-generation tool that generates
32+
highly-optimized C code which outperforms e.g., the C++ STL given a declarative
33+
description of data-structures and relationships between them. For more
34+
information, see the [DataDraw 3.0
35+
Manual](https://datadraw.sourceforge.net/manual.pdf).
3036

3137
Additional documentation:
3238

@@ -90,9 +96,8 @@ both SQL and Rune.
9096
class Human(self: Human, name: string, mother: Human? = null(self), father: Human? = null(self)) {
9197
self.name = name
9298

93-
// The methods "appendMotheredHuman" and "appendFatheredHuman" are generated by the "datadraw"
94-
// code-generation tool -- an embedded part of the Rune compiler toolchain and vital ingredient
95-
// to Rune's performance.
99+
// The methods "appendMotheredHuman" and "appendFatheredHuman" are generated
100+
// by code "transformers", a key factor in Rune's performance.
96101
//
97102
// We'll learn more about these methods in the next section ("How does this work?").
98103
if !isnull(mother) {
@@ -123,8 +128,8 @@ class Human(self: Human, name: string, mother: Human? = null(self), father: Huma
123128
// its children are recursively destroyed.
124129
// (In other words, manual invalidation of pointers is not required)
125130
//
126-
// This ability is also provided by the "datadraw" code-generation tool.
127-
// See: Page 6 of the DataDraw 3.0 Manual: https://datadraw.sourceforge.net/manual.pdf
131+
// This ability is also provided by code transformers. See
132+
// builtin/doublylinked.rn
128133
relation DoublyLinked Human:"Mother" Human:"Mothered" cascade
129134
relation DoublyLinked Human:"Father" Human:"Fathered" cascade
130135

TODO

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ Add an option for generating SoA vs AoS memory layout so folks can do their own
66
Write a C or C++ backend code generator for improved debugging of Rune, and so folks can benchmark with
77
full front-end optimization of different C compilers for benchmarking.
88
Enhance gdb pretty printer so that we don't have to generate show methods.
9-
Figure out when relationship generators should run. Right now it is in the order statements are bound so that module-level variables can be passed into the generators, but we assume all generators are run before binding a constructor, which is currently false. Figure out the right thing and do it.
9+
Figure out when relationship transformers should run. Right now it is in the order statements are bound so that module-level variables can be passed into the transformers, but we assume all transformers are run before binding a constructor, which is currently false. Figure out the right thing and do it.
1010
Use concrete type constraints in binding. This can help eleminate problems
1111
in binding recursive functions, and also non-template classes.
1212
Don't allow generated fields to be written outside of generated code.
1313
Add an Object class that matches all types, so we can have case (Object, Object, Object).
1414
Defend vs Spectre/Meltdown: duplicate bignum functions in runtime to have constant-time vs
1515
non-constant time APIs. Do not pass in a secret bit.
16-
Figure out how to programatically manipulate labels in generators.
16+
Figure out how to programatically manipulate labels in transformers.
1717
Flesh out index overloading: write is not yet supported.
1818
Support Overloading method get/set methods.
1919
Improve safe mode:
@@ -52,7 +52,7 @@ Support overloading modular operations, so we can support modular polynomials, e
5252
Add multi-threading support.
5353
Add schema-level reuse statements
5454
Write a schema generator for Rune similar to the dataview program for DataDraw schemas.
55-
Flush out generator's Rune code interpreter.
55+
Flush out transformers's Rune code interpreter.
5656
Finish transition to memory pools, and allocation of global arrays with mmap of the memory available on the machine so large arrays never move.
5757
Add support for 32-bit mode.
5858

bind/bind.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Binding in Rune is challenging. The usual one-pass per function fails because:
2424
2525
* Recursive binding: While binding a function signature that calls itself, we
2626
are blocked on the recursive call since the return type is still unknown.
27-
* Code generation: While binding a function signature, there is an undefined
27+
* Code transforms: While binding a function signature, there is an undefined
2828
identifier. This may be real, or maybe it hasn't been generated yet.
2929
* Undefined class data members: While binding class A, we refer to a method in
3030
class B that uses an undefined member variable on B. These members are
@@ -85,13 +85,13 @@ In A.rn:
8585
... The rest is unit test code that does not use B.
8686
}
8787
88-
The problem is that the DoublyLinked code generator added lines to A's
88+
The problem is that the DoublyLinked code transformer added lines to A's
8989
constructor:
9090
9191
self.firstB = null(B)
9292
self.lastB = null(B)
9393
94-
In A's destructor, the code generator added a loop to destroy all the B
94+
In A's destructor, the code transformer added a loop to destroy all the B
9595
objects, and that loop refers to self.firstB. The statement self.firstB =
9696
null(B) does not provide enough information to fully specify the type of B,
9797
which is a template class due to the <value> parameter. The type hint gets
@@ -112,7 +112,7 @@ will be uniquified per signature, before binding, so binding can be done once.
112112
Similarly a Binding has a list of Expression objects representing the queue
113113
of expressions to be bound for a statement, default value expression, or type
114114
expression. The new scheme allows multiple expression trees to be bound in
115-
parallel, and the assembly code generator no longer has to rebind a function
115+
parallel, and the assembly code transformer no longer has to rebind a function
116116
signature before generating code.
117117
118118
Binding objects, when created, are appended to a global queue of binding objects

bind/bindexpr.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,7 @@ static void bindNotExpression(deBlock scopeBlock, deExpression expression) {
942942
// can also cast a string to a [u8] array and vise-versa. Object references
943943
// can be cast to their underlying integer type and back, e.g <u32>Point(1,2),
944944
// or <Point(u64, u64)>1u32. Object-to-integer casts are dangerous and we
945-
// should probably restrict its use to code generators.
945+
// should probably restrict its use to code transformers and unsafe code.
946946
static void verifyCast(deExpression expression, deDatatype leftDatatype,
947947
deDatatype rightDatatype, deLine line) {
948948
if (leftDatatype == rightDatatype) {

bind/bindformat.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ static void checkExpressionIsPrintable(deExpression expression) {
2222
deDatatype datatype = deExpressionGetDatatype(expression);
2323
switch (deDatatypeGetType(datatype)) {
2424
case DE_TYPE_EXPR:
25-
deExprError(expression, "Cannot print generator expressions");
25+
deExprError(expression, "Cannot print transformer expressions");
2626
break;
2727
case DE_TYPE_NONE:
2828
deExprError(expression, "Printed argument has no type");

bootstrap/database/function.rn

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ enum FuncType {
3535
Final
3636
Struct
3737
Enum
38-
Generator
38+
Transformer
3939
Unittest
4040
}
4141

@@ -64,7 +64,7 @@ func getFuncTypeName(type: FuncType) -> string {
6464
FuncType.Final => return "final"
6565
FuncType.Struct => return "struct"
6666
FuncType.Enum => return "enum"
67-
FuncType.Generator => return "generator"
67+
FuncType.Transformer => return "transformer"
6868
}
6969
}
7070

bootstrap/database/rel.rn

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
use gen
15+
use trans
1616
use template
1717
use root
1818

19-
class Relation(self, gen: Generator, parent: Template, child: Template) {
19+
class Relation(self, gen: Transformer, parent: Template, child: Template) {
2020
gen.appendRelation(self)
2121
parent.appendChildRelation(self)
2222
child.appendParentRelation(self)
2323
}
2424

25-
relation DoublyLinked Generator Relation cascade
25+
relation DoublyLinked Transformer Relation cascade
2626
relation DoublyLinked Template:"Parent" Relation:"Child" cascade
2727
relation DoublyLinked Template:"Child" Relation:"Parent" cascade

bootstrap/database/gen.rn bootstrap/database/trans.rn

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
use function
1616
use root
1717

18-
class Generator(self, function: Function) {
19-
function.insertGenerator(self)
18+
class Transformer(self, function: Function) {
19+
function.insertTransformer(self)
2020
}
2121

22-
relation OneToOne Function Generator cascade
22+
relation OneToOne Function Transformer cascade

builtin/arraylist.rn

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
generator ArrayList(A: Class, B: Class, cascadeDelete:bool = false,
15+
transformer ArrayList(A: Class, B: Class, cascadeDelete:bool = false,
1616
labelA: string = "", labelB: string = "", pluralB = "") {
1717
if pluralB == "" {
1818
pluralB = "$B_s"

builtin/doublylinked.rn

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
generator DoublyLinked(A: Class, B: Class, cascadeDelete:bool = false,
15+
transformer DoublyLinked(A: Class, B: Class, cascadeDelete:bool = false,
1616
labelA: string = "", labelB: string = "", pluralB: string = "") {
1717
if pluralB == "" {
1818
pluralB = "$B_s"

builtin/hashed.rn

+3-3
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,16 @@ func hashValue(value) -> u64 {
7474
}
7575
}
7676

77-
// This is a one-to-many relation generator that adds a hash table between
77+
// This is a one-to-many relation transformer that adds a hash table between
7878
// class A and B. The hash table is always a power of 2, and dynamically grows
7979
// as needed, when the number of hash table elements equals the size of the
8080
// table. The child class B must have a data member matching the value of keyField.
8181
// No two elements in the hash table can have the same keyField value.
8282
//
83-
// This generator embeds a singly-linked list between A and B, which on average
83+
// This transformer embeds a singly-linked list between A and B, which on average
8484
// will never have more than one element, so the expected insert/remove time is
8585
// still constant.
86-
generator Hashed(A: Class, B: Class, cascadeDelete: bool = false,
86+
transformer Hashed(A: Class, B: Class, cascadeDelete: bool = false,
8787
labelA: string = "", labelB: string = "", keyField: string = "hash", pluralB: string = "") {
8888
if pluralB == "" {
8989
pluralB = "$B_s";

builtin/hashedclass.rn

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
// This is a one-to-many relation generator that adds a hash table between
15+
// This is a one-to-many relation transformer that adds a hash table between
1616
// class A and B. The hash table is always a power of 2, and dynamically grows
1717
// as needed, when the number of hash table elements equals the size of the
1818
// table. The child class B must have two methods: hash() -> u64, and
1919
// equals(other) which compares the two instances of class B and returns true
2020
// if they are equivalent.
2121
//
22-
// This generator embeds a singly-linked list between A and B, which on average
22+
// This transformer embeds a singly-linked list between A and B, which on average
2323
// will never have more than one element, so the expected insert/remove time is
2424
// still constant.
25-
generator HashedClass(A: Class, B: Class, cascadeDelete: bool = false,
25+
transformer HashedClass(A: Class, B: Class, cascadeDelete: bool = false,
2626
labelA: string = "", labelB: string = "", pluralB: string = "") {
2727
if pluralB == "" {
2828
pluralB = "$B_s";

builtin/heapqlist.rn

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
generator HeapqList(A: Class, B: Class, cascadeDelete:bool = false,
15+
transformer HeapqList(A: Class, B: Class, cascadeDelete:bool = false,
1616
labelA: string = "", labelB: string = "", ascend: bool = true, pluralB = "") {
1717
if pluralB == "" {
1818
pluralB = "$B_s"

builtin/linkedlist.rn

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
generator LinkedList(A: Class, B: Class, cascadeDelete:bool = false,
15+
transformer LinkedList(A: Class, B: Class, cascadeDelete:bool = false,
1616
labelA: string = "", labelB: string = "", pluralB = "") {
1717
if pluralB == "" {
1818
pluralB = "$B_s"

builtin/onetoone.rn

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
generator OneToOne(A: Class, B: Class, cascadeDelete:bool = false,
15+
transformer OneToOne(A: Class, B: Class, cascadeDelete:bool = false,
1616
labelA: string = "", labelB: string = "") {
1717
prependcode A {
1818
self.$labelB$B = null(B)

builtin/taillinked.rn

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
generator TailLinked(A: Class, B: Class, cascadeDelete:bool = false,
15+
transformer TailLinked(A: Class, B: Class, cascadeDelete:bool = false,
1616
labelA: string = "", labelB: string = "", pluralB = "") {
1717
if pluralB == "" {
1818
pluralB = "$B_s"

database/Rune.dd

+12-12
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ enum StatementType
3030
DE_STATEMENT_PRINT // print "Hello, World!\n"
3131
DE_STATEMENT_THROW
3232
DE_STATEMENT_RETURN
33-
DE_STATEMENT_GENERATE
33+
DE_STATEMENT_TRANSFORM
3434
DE_STATEMENT_RELATION
3535
DE_STATEMENT_APPENDCODE
3636
DE_STATEMENT_PREPENDCODE
@@ -40,7 +40,7 @@ enum StatementType
4040
DE_STATEMENT_IMPORTRPC
4141
DE_STATEMENT_FOREACH
4242
DE_STATEMENT_YIELD
43-
DE_STATEMENT_REF // These two are used by generators to manage reference counts.
43+
DE_STATEMENT_REF // These two are used by transformers to manage reference counts.
4444
DE_STATEMENT_UNREF
4545

4646
enum ExpressionType
@@ -154,7 +154,7 @@ enum DatatypeType
154154
DE_TYPE_STRUCT
155155
DE_TYPE_ENUM
156156
DE_TYPE_ENUMCLASS
157-
DE_TYPE_EXPR // Only used to pass expression values to generators.
157+
DE_TYPE_EXPR // Only used to pass expression values to transformers.
158158

159159
enum IdentType
160160
DE_IDENT_FUNCTION
@@ -176,7 +176,7 @@ enum FunctionType
176176
DE_FUNC_FINAL
177177
DE_FUNC_STRUCT
178178
DE_FUNC_ENUM
179-
DE_FUNC_GENERATOR
179+
DE_FUNC_TRANSFORMER
180180
DE_FUNC_UNITTEST
181181

182182
enum BlockType
@@ -313,8 +313,8 @@ class Function
313313
bool Extern // Provided by an external library or RPC.
314314
ExpressionType opType // For functions that overload operators.
315315

316-
// A code generator definition.
317-
class Generator
316+
// A code transformer definition.
317+
class Transformer
318318
Line line
319319

320320
class Variable
@@ -330,12 +330,12 @@ class Variable
330330
bool initializedAtTop
331331
bool inTemplateSignature
332332
sym savedName
333-
Value value cascade // Used in generation.
333+
Value value cascade // Used in code transforms.
334334
bool generated // We don't reference count via generated variables.
335335
uint32 entryValue // Set for variables representing enum entries.
336336
Datatype savedDatatype // Used in matching overloaded operators.
337337

338-
// Used during generation to compute expression values. May also get used for constant propagation.
338+
// Used by code transoforms to compute expression values. May also get used for constant propagation.
339339
class Value
340340
DatatypeType type
341341
Variable variable
@@ -355,7 +355,7 @@ class Statement
355355
Line line
356356
bool instantiated
357357
bool executed // Only for relation statements, so we don't execute them twice.
358-
bool generated // This statement was generated by a generator.
358+
bool generated // This statement was generated by a transformer.
359359
bool isFirstAssignment // True if this is the first assignment to a variable, at top level.
360360

361361
// Hash table bins for data types.
@@ -447,7 +447,7 @@ class Binding
447447
// that are blocked on this event. These events take certain forms: A
448448
// signature has been bound, a module's global variable has been assigned a
449449
// non-null type, or a local variable in a class or function as been bound to
450-
// non-null type. Sometimes a code generator runs and creates an identifier
450+
// non-null type. Sometimes a code transformer runs and creates an identifier
451451
// that was previously undefined.
452452
class Event
453453
EventType type
@@ -521,7 +521,7 @@ relationship Template Class doubly_linked mandatory
521521
relationship Class:Owning Block:Sub cascade
522522
relationship Function:Owning Block:Sub cascade
523523
relationship Function:Type Expression:Type cascade
524-
relationship Function Generator cascade
524+
relationship Function Transformer cascade
525525
relationship Statement:Owning Block:Sub cascade
526526
relationship Statement Expression cascade
527527
relationship Expression Expression doubly_linked cascade
@@ -534,7 +534,7 @@ relationship Template:Parent Relation:Child doubly_linked mandatory
534534
relationship Template:Child Relation:Parent doubly_linked mandatory
535535
relationship Relation:Generated Statement:Generated doubly_linked cascade
536536
relationship Relation:Generated Function:Generated doubly_linked cascade
537-
relationship Generator Relation doubly_linked mandatory
537+
relationship Transformer Relation doubly_linked mandatory
538538
relationship Variable MemberRel mandatory
539539
relationship Class:Parent MemberRel:Child doubly_linked mandatory
540540
relationship Class:Child MemberRel:Parent doubly_linked mandatory

database/block.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ static void updateReachability(deStatement statement, bool* canContinue, bool* c
293293
case DE_STATEMENT_APPENDCODE:
294294
case DE_STATEMENT_PREPENDCODE:
295295
case DE_STATEMENT_RELATION:
296-
case DE_STATEMENT_GENERATE:
296+
case DE_STATEMENT_TRANSFORM:
297297
utExit("Unexpected statement type");
298298
break;
299299
}

0 commit comments

Comments
 (0)