Skip to content

Commit d43bfd6

Browse files
authored
Merge pull request #144 from julelang/new-references
jule: new reference pointers
2 parents 7edc4a2 + 646b181 commit d43bfd6

File tree

223 files changed

+4802
-4628
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

223 files changed

+4802
-4628
lines changed

src/julec/compile.jule

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fn init() {
3737
env::Compiler = "clang"
3838
}
3939

40-
fn openOutput(&path: str): &os::File {
40+
fn openOutput(path: str): &os::File {
4141
dir := filepath::Dir(path)
4242

4343
os::Stat(dir) else {
@@ -196,7 +196,7 @@ fn pushCompCmdGcc(mut args: []str): []str {
196196
}
197197

198198
// Generate compile command for backend-compiler.
199-
fn genCompileCmd(sourcePath: str, &ir: &obj::IR): (compiler: str, args: []str) {
199+
fn genCompileCmd(sourcePath: str, ir: &obj::IR): (compiler: str, args: []str) {
200200
compiler = env::CompilerPath
201201

202202
match env::Compiler {
@@ -241,7 +241,7 @@ fn getCompilePath(): str {
241241
ret filepath::Join(OutDir, OutName)
242242
}
243243

244-
fn applyTargetIndependentOptimizations(mut &ir: &obj::IR) {
244+
fn applyTargetIndependentOptimizations(mut ir: &obj::IR) {
245245
mut opt := opt::Optimizer.New(ir)
246246
opt.Optimize()
247247
}
@@ -284,7 +284,7 @@ fn checkTargetPair(os: str, arch: str) {
284284
handle::Throw("invalid target: " + os + "-" + arch)
285285
}
286286

287-
fn checkTargetFlag(&target: str) {
287+
fn checkTargetFlag(target: str) {
288288
if target == "" {
289289
handle::Throw("missing option value: --target")
290290
}
@@ -314,7 +314,7 @@ fn checkTargetFlag(&target: str) {
314314
types::UpdateTarget()
315315
}
316316

317-
fn checkOptFlag(&opt: str) {
317+
fn checkOptFlag(opt: str) {
318318
if opt == "" {
319319
handle::Throw("missing option value: --opt")
320320
}
@@ -342,7 +342,7 @@ fn checkCppStdFlag() {
342342
}
343343
}
344344

345-
fn checkFlags(&args: []str): []str {
345+
fn checkFlags(&args: *[]str): []str {
346346
mut opt := "L0"
347347
mut target := "native-native"
348348

@@ -380,7 +380,7 @@ fn checkFlags(&args: []str): []str {
380380
fs.AddVar[bool](unsafe { (&bool)(&opt::StdStrings) }, "opt-std-strings", 0, "Special optimizations for the std/strings package")
381381
fs.AddVar[bool](unsafe { (&bool)(&opt::StdMathCmplx) }, "opt-std-math-cmplx", 0, "Special optimizations for the std/math/cmplx package")
382382

383-
mut content := fs.Parse(args) else {
383+
mut content := fs.Parse(*args) else {
384384
handle::Throw(error.(str))
385385
use nil // Avoid error.
386386
}
@@ -393,17 +393,17 @@ fn checkFlags(&args: []str): []str {
393393
ret content
394394
}
395395

396-
fn setupSemaFlags(mut &flags: int) {
396+
fn setupSemaFlags(mut &flags: *int) {
397397
if env::Shadowing {
398-
flags |= sema::Shadowing
398+
*flags |= sema::Shadowing
399399
}
400400
}
401401

402-
fn buildIr(&args: []str): &obj::IR {
402+
fn buildIr(&args: *[]str): &obj::IR {
403403
content := checkFlags(args)
404404

405405
mut semaFlags := sema::Default
406-
setupSemaFlags(semaFlags)
406+
setupSemaFlags(&semaFlags)
407407

408408
if len(content) == 0 {
409409
handle::Throw(log::Logf(log::MissingCompilePath))
@@ -431,19 +431,19 @@ fn buildIr(&args: []str): &obj::IR {
431431
}
432432

433433
if logs != nil {
434-
handle::Logger.PrintLogs(logs)
434+
handle::Logger.PrintLogs(&logs)
435435
handle::Throw("")
436436
}
437437

438438
ret ir
439439
}
440440

441441
// Process compile command by "ARGS" global.
442-
fn compileCommand(mut &args: []str) {
443-
args = args[1:] // Remove program path.
444-
if args[0] == "test" {
442+
fn compileCommand(mut &args: *[]str) {
443+
*args = (*args)[1:] // Remove program path.
444+
if (*args)[0] == "test" {
445445
env::Test = true
446-
args = args[1:]
446+
*args = (*args)[1:]
447447
}
448448
mut ir := buildIr(args)
449449

src/julec/handle/logger.jule

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ struct Logger{}
1212

1313
impl Logger {
1414
// Prints flag log.
15-
fn LogFlat(&l: log::Log) {
15+
fn LogFlat(&l: *log::Log) {
1616
println(l.Text)
1717
}
1818

1919
// Prints error log.
20-
fn LogError(&l: log::Log) {
20+
fn LogError(&l: *log::Log) {
2121
print(AnsiRed)
2222
print("error: ")
2323
print(l.Text)
@@ -62,7 +62,7 @@ impl Logger {
6262
}
6363

6464
// Log.
65-
fn Log(&l: log::Log) {
65+
fn Log(&l: *log::Log) {
6666
match l.Kind {
6767
| log::Flat:
6868
Logger.LogFlat(l)
@@ -72,12 +72,12 @@ impl Logger {
7272
}
7373

7474
// Prints all logs.
75-
fn PrintLogs(&logs: []log::Log) {
76-
for _, l in logs {
77-
Logger.Log(l)
75+
fn PrintLogs(&logs: *[]log::Log) {
76+
for _, l in *logs {
77+
Logger.Log(&l)
7878
}
7979
print("=== ")
80-
print(conv::Itoa(len(logs)))
80+
print(conv::Itoa(len(*logs)))
8181
println(" error generated ===")
8282
}
8383
}

src/julec/main.jule

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fn printErrorMessage(msg: str) {
3737
}
3838

3939
// Command: julec help
40-
fn help(&args: []str, pan: int) {
40+
fn help(args: []str, pan: int) {
4141
if len(args) > 2 {
4242
printErrorMessage("invalid command: " + args[2])
4343
ret
@@ -67,7 +67,7 @@ fn help(&args: []str, pan: int) {
6767
}
6868

6969
// Command: julec version
70-
fn version(&args: []str) {
70+
fn version(args: []str) {
7171
if len(args) > 2 {
7272
printErrorMessage("invalid command: " + args[2])
7373
ret
@@ -108,7 +108,7 @@ fn toolDistarch() {
108108
}
109109

110110
// Command: julec tool
111-
fn tool(&args: []str) {
111+
fn tool(args: []str) {
112112
if len(args) == 2 {
113113
println(`tool commands:
114114
targets List all supported target pairs
@@ -134,7 +134,7 @@ fn tool(&args: []str) {
134134
}
135135

136136
// Command: julec julenv
137-
fn julenv(&args: []str) {
137+
fn julenv(args: []str) {
138138
if len(args) > 2 {
139139
printErrorMessage("invalid command: " + args[2])
140140
ret
@@ -147,7 +147,7 @@ fn julenv(&args: []str) {
147147
}
148148

149149
// Command: julec mod
150-
fn mod(&args: []str) {
150+
fn mod(args: []str) {
151151
if len(args) == 2 {
152152
println("no command given, try julec mod init")
153153
ret
@@ -170,7 +170,7 @@ fn mod(&args: []str) {
170170

171171
// Try to process compiler commands.
172172
// Reports whether "ARGS" is command and processed.
173-
fn processCommand(&args: []str): bool {
173+
fn processCommand(args: []str): bool {
174174
match args[1] {
175175
| CmdHelp:
176176
help(args, 0)
@@ -227,5 +227,5 @@ fn main() {
227227
ret
228228
}
229229

230-
compileCommand(args)
230+
compileCommand(&args)
231231
}

0 commit comments

Comments
 (0)