main 602baa7

expr.go RawHistoryFolder

1package main
2
3import "fmt"
4
5// renderExpr centralizes expression lowering; callers supply parameter, owned
6// field, or getter references. No expression decisions are left to templates.
7func renderExpr(n *Node, ref func(string) string, m *Module) (string, error) {
8	if n == nil {
9		return "", nil
10	}
11	switch n.Kind {
12	case "value":
13		return n.Text, nil
14	case "fieldref":
15		return ref(n.Text), nil
16	case "enumref":
17		e, owner := findEnum(m, n.Attr["ref"])
18		if e == nil {
19			return "", n.fail("unknown enum %s", n.Attr["ref"])
20		}
21		return "int(" + qualified(m, owner, e.Name+goName(n.Text)) + ")", nil
22	case "op", "unop", "popcount":
23		var parts []string
24		for _, c := range n.Children {
25			s, err := renderExpr(c, ref, m)
26			if err != nil {
27				return "", err
28			}
29			parts = append(parts, s)
30		}
31		if n.Kind == "popcount" {
32			return "bits.OnesCount(uint(" + parts[0] + "))", nil
33		}
34		if n.Kind == "unop" {
35			return "(^" + parts[0] + ")", nil
36		}
37		if len(parts) != 2 {
38			return "", n.fail("invalid binary expression")
39		}
40		return "(" + parts[0] + " " + n.Attr["op"] + " " + parts[1] + ")", nil
41	}
42	return "", fmt.Errorf("%s:%d: unsupported expression %s", n.File, n.Line, n.Kind)
43}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 1

↑↓ moveenter openesc close