Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cbuilder: most of ccgstmts #24420

Merged
merged 7 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions compiler/cbuilderexprs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ template addCast(builder: var Builder, typ: Snippet, valueBody: typed) =
proc cAddr(value: Snippet): Snippet =
"&" & value

proc cLabelAddr(value: TLabel): Snippet =
"&&" & value

proc cDeref(value: Snippet): Snippet =
"(*" & value & ")"

Expand Down
13 changes: 9 additions & 4 deletions compiler/cbuilderstmts.nim
Original file line number Diff line number Diff line change
Expand Up @@ -257,21 +257,26 @@ proc addLabel(builder: var Builder, name: TLabel) =
proc addReturn(builder: var Builder) =
builder.add("return;\n")

proc addReturn(builder: var Builder, value: string) =
proc addReturn(builder: var Builder, value: Snippet) =
builder.add("return ")
builder.add(value)
builder.add(";\n")

template addGoto(builder: var Builder, label: TLabel) =
proc addGoto(builder: var Builder, label: TLabel) =
builder.add("goto ")
builder.add(label)
builder.add(";\n")

template addIncr(builder: var Builder, val: Snippet) =
proc addComputedGoto(builder: var Builder, value: Snippet) =
builder.add("goto *")
builder.add(value)
builder.add(";\n")

proc addIncr(builder: var Builder, val: Snippet) =
builder.add(val)
builder.add("++;\n")

template addDecr(builder: var Builder, val: Snippet) =
proc addDecr(builder: var Builder, val: Snippet) =
builder.add(val)
builder.add("--;\n")

Expand Down
Loading