@@ -31,22 +31,24 @@ struct formatter {
3131 indentLen: int
3232 indentStr: str
3333
34- mut i: int
35- mut buf: strings::Builder
36- mut f: &ast::AST
37- mut indent: []byte
38- mut cm: &CommentMap
39- mut row: int
34+ mut i: int
35+ mut buf: strings::Builder
36+ mut f: &ast::AST
37+ mut atomIndent: str // Single indentation
38+ mut indent: []byte // Whole indentation based on the current indentation level
39+ mut cm: &CommentMap
40+ mut row: int
4041
4142 mut ef: &exprFormatter
4243}
4344
4445impl formatter {
45- static fn new(): &formatter {
46+ fn new(): &formatter {
4647 mut fmt := new(formatter)
4748 fmt.ef = exprFormatter.new(fmt)
4849 fmt.indentLen = 1
4950 fmt.indentStr = "\t"
51+ fmt.atomIndent = strings::Repeat(fmt.indentStr, fmt.indentLen)
5052 ret fmt
5153 }
5254
@@ -63,8 +65,7 @@ impl formatter {
6365 }
6466
6567 fn addIndent(&self) {
66- static indent = []byte(strings::Repeat(self.indentStr, self.indentLen))
67- self.indent = append(self.indent, indent...)
68+ self.indent = append(self.indent, self.atomIndent...)
6869 }
6970
7071 fn doneIndent(&self) {
@@ -467,9 +468,6 @@ impl formatter {
467468 self.directives(d.Directives)
468469 self.buf.Write(self.indent)!
469470 }
470- if d.Statically {
471- self.write("static ")
472- }
473471 if d.Binded {
474472 self.write("cpp ")
475473 }
@@ -668,8 +666,8 @@ impl formatter {
668666 if d.Binded {
669667 self.write("cpp let ")
670668 } else {
671- if d.Statically {
672- self.write("static ")
669+ if d.Static {
670+ self.write("let ")
673671 } else if d.Constant {
674672 self.write("const ")
675673 } else if d.Setter == nil || d.Setter.Id == token::Eq {
@@ -1238,7 +1236,7 @@ struct exprFormatter {
12381236}
12391237
12401238impl exprFormatter {
1241- static fn new(&fmt: &formatter): &exprFormatter {
1239+ fn new(&fmt: &formatter): &exprFormatter {
12421240 mut ef := &exprFormatter{
12431241 fmt: unsafe { *(&fmt) },
12441242 }
@@ -1636,7 +1634,7 @@ struct binaryFormatter {
16361634
16371635impl binaryFormatter {
16381636 // Reports whether operator should take space for formatting.
1639- static fn isOp(op: int): bool {
1637+ fn isOp(op: int): bool {
16401638 ret op == token::DblVline ||
16411639 op == token::DblAmper ||
16421640 op == token::Gt ||
@@ -1649,7 +1647,7 @@ impl binaryFormatter {
16491647
16501648 // Reports whether the operator is have high formatting precedence.
16511649 // Returns 1 for high precedence, otherwise returns 0.
1652- static fn opPrec(op: int): int {
1650+ fn opPrec(op: int): int {
16531651 match op {
16541652 | token::Shl
16551653 | token::Shr
@@ -1664,7 +1662,7 @@ impl binaryFormatter {
16641662 }
16651663
16661664 // Reports whether operator zips operands.
1667- static fn isHardZipOp(op: int): bool {
1665+ fn isHardZipOp(op: int): bool {
16681666 ret op == token::DblVline ||
16691667 op == token::DblAmper
16701668 }
0 commit comments