Skip to content

Commit cd13a52

Browse files
committed
juledoc: update to new static declaration logic
1 parent 686ae4d commit cd13a52

File tree

3 files changed

+20
-22
lines changed

3 files changed

+20
-22
lines changed

builder/formatter.jule

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -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

4445
impl 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

12401238
impl 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

16371635
impl 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
}

gen/markdown/markdown.jule

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const spacePerIndent = 4
1212

1313
// Derived from "std/html" for HTML support, stay up to date.
1414
// Additionaly includes special Markdown characters.
15-
static markdownEscaper = strings::Replacer.New(
15+
let markdownEscaper = strings::Replacer.New(
1616
`&`, "&",
1717
`'`, "'",
1818
`<`, "&lt;",
@@ -39,11 +39,11 @@ static markdownEscaper = strings::Replacer.New(
3939

4040
// Replaces special characters for identifiers.
4141
// If a name will used for a hyperlink in the page, this replacer should be used.
42-
static idEscaper = strings::Replacer.New(
42+
let idEscaper = strings::Replacer.New(
4343
"_", "-")
4444

4545
// Replaces special characters for jump-table index.
46-
static jmpReplacer = strings::Replacer.New("\n", " ", "\t", "")
46+
let jmpReplacer = strings::Replacer.New("\n", " ", "\t", "")
4747

4848
// Generates Markdown documentation from documentation data.
4949
struct gen {

src/main.jule

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use "std/os"
1717
use "std/os/filepath"
1818
use "std/strings"
1919

20-
static mut _W = new(bool, false) // Flag -w
20+
let mut _W = new(bool, false) // Flag -w
2121

2222
fn writeError(message: str) {
2323
os::Stderr().WriteStr(message)!

0 commit comments

Comments
 (0)