annotate modules/compiler.tp @ 329:eef8a5cea812

Use a smarter algorithm for calculating module init order and break some circular module dependencies in the standard library
author Michael Pavone <pavone@retrodev.com>
date Sat, 28 Mar 2015 13:26:03 -0700
parents 004946743678
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
252
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
1 #{
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
2 main <- :args {
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
3 if: (args length) > 1 {
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
4 file <- os open: (args get: 1) (os O_RDONLY)
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
5
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
6 code <- ""
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
7 chunksize <- 1024
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
8 readsize <- chunksize
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
9 while: { readsize = chunksize} do: {
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
10 seg <- os read: file chunksize
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
11 code <- code . seg
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
12 readsize <- seg byte_length
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
13 }
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
14 res <- parser top: code
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
15 if: res {
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
16 methods <- symbols buildMethodTable: (res yield)
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
17 print: methods
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
18 } else: {
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
19 print: "Parse failed!\n"
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
20 }
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
21 } else: {
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
22 print: "Usage compiler FILE\n"
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
23 }
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
24 }
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
25 }