File tree Expand file tree Collapse file tree 7 files changed +44
-2
lines changed
Expand file tree Collapse file tree 7 files changed +44
-2
lines changed Original file line number Diff line number Diff line change 1+ // BCG: These might deserve to be more central types.
2+
13class PACT.Packfile.Constant
24{
35 var value;
6+ // BCG: Probably want to specify a common API to all of them here.
47}
58
9+ // BCG: We may also want a Key class. Keys are not terribly friendly to
10+ // edit.
11+
612class PACT.Packfile.Constant.Integer : PACT.Packfile.Constant
713{
814 function Integer(int value)
@@ -15,6 +21,11 @@ class PACT.Packfile.Constant.Integer : PACT.Packfile.Constant
1521 return int(self.value);
1622 }
1723
24+ // BCG: We probably want to have a type enum/constants
25+ // String comparison is not speedy.
26+ // Alternative is single character types so we can switch on their ord
27+ // I'd like to get typing right quickly so that all levels can share
28+ // the type information.
1829 function get_type()
1930 {
2031 return "int";
Original file line number Diff line number Diff line change 1+ // BCG: Probably also want subs stored in their namespace.
2+ // That's not how the packfile is organized, but it's probably more sane.
13class PACT.Packfile.Namespace
24{
35 var name;
Original file line number Diff line number Diff line change @@ -15,6 +15,8 @@ class PACT.Packfile.Op
1515 self.labels = [];
1616 }
1717
18+ // BCG: Not sure if results and operands can be separated sanely in
19+ // all instances.
1820 function add_results(var results [slurpy])
1921 {
2022 for (var r in results)
@@ -38,6 +40,9 @@ class PACT.Packfile.Op
3840 push(self.labels, label);
3941 }
4042
43+ // BCG: We probably want an inverse of this method as well
44+ // BCG: I would probably also do this as a stage rather than
45+ // put the guts in this class. See docs/stages.mkd
4146 function get_opcode_pmc()
4247 {
4348 // TODO: Create and return a representation of this op expressed in
Original file line number Diff line number Diff line change @@ -22,20 +22,26 @@ class PACT.Packfile
2222 return self.root_ns.get_child_ns(name);
2323 }
2424
25+ // BCG: ns optional, perhaps?
2526 function new_sub(string name, var ns)
2627 {
2728 if (ns == null)
2829 ns = self.root_ns;
2930 var s = new PACT.Packfile.Subroutine(self, name, ns);
3031 }
3132
33+ // BCG: I'm not sure I'd worry about a constant table at this level.
34+ // I think the PackfileConstantTable has convenient methods to
35+ // deal with addition and de-dup when we output.
36+ // It's simpler if we don't have to worry about it until then.
3237 function add_constant(var constant)
3338 {
3439 // TODO: We need to de-duplicate. Do we do that on input or do that
3540 // on output?
3641 push(self.constants, constant);
3742 }
3843
44+ // BCG: Again with wanting an inverse and doing it as a stage.
3945 function get_packfile()
4046 {
4147 // TODO: This is the biggie. Create the entire Packfile PMC structure
Original file line number Diff line number Diff line change 11class PACT.Packfile.Subroutine
22{
3- var program;
3+ var program; // BCG: What is this? The packfile?
44 var ops;
55 var name;
66 var flags;
77 var parent_namespace;
88 var annotations;
99 var identifier;
10+
11+ // BCG: This feels like scope-like information that really
12+ // belongs at levels higher than Packfile.
1013 var variables;
1114 var temp_variables;
1215
@@ -70,6 +73,8 @@ class PACT.Packfile.Subroutine
7073 }
7174 }
7275
76+ // BCG: These feel like they're in the wrong place.
77+ // The subroutine doesn't have to care about constants.
7378 function get_constant(int i)
7479 {
7580 var c = new PACT.Packfile.Constant.Integer(i);
Original file line number Diff line number Diff line change 1+ // BCG: Do the flags need to be separate classes?
2+ // Could they just as sanely be stored in a hash?
3+ // Or as variables in subroutine with an array for tags, perhaps?
14class PACT.Packfile.Subroutine.Flag
25{
3-
6+ // BCG: Subroutine uses name(), which isn't defined here
47}
58
69class PACT.Packfile.Subroutine.Flag.Main : PACT.Packfile.Subroutine.Flag
Original file line number Diff line number Diff line change 1+ // BCG: I would expect the Packfile classes to be too deep for things like
2+ // Variables. I would expect raw Registers instead.
3+ // My vision for the Packfile classes was that it would be a PACT-oriented
4+ // and simpler method of dealing with packfiles more-or-less as they
5+ // are. Once that's in place we can deal with adding things like
6+ // variables and register allocation and the like.
7+
18class PACT.Packfile.Variable
29{
310 var id; // A human-readable name for the variable
411 var index; // the actual register index (integer)
512 // TODO: It might be nice to store first/last use lifetime information for
613 // the register allocator to use.
14+ // BCG: I would probably perform a separate lifetime analysis and store the
15+ // data there than relying on the Variable to keep it up to date.
16+ // Also, again with defining common API in the base class.
717}
818
919class PACT.Packfile.Variable.Integer : PACT.Packfile.Variable
You can’t perform that action at this time.
0 commit comments