Skip to content

Commit

Permalink
maintain: refactor all jule codebase with julefmt
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Sep 27, 2024
1 parent 463863e commit d0ab555
Show file tree
Hide file tree
Showing 118 changed files with 664 additions and 664 deletions.
2 changes: 1 addition & 1 deletion src/julec/handle/logger.jule
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl Logger {
out("\n ")
out(strings::Repeat(" ", len(row)))
out(" | ")
out(strings::Repeat(" ", l.Column - offset))
out(strings::Repeat(" ", l.Column-offset))
out("^")
if len(l.Suggestion) != 0 {
out("\n ")
Expand Down
2 changes: 1 addition & 1 deletion src/julec/main.jule
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn help(&args: []str) {
const Space = 5 // Space of between command name and description.
for i, part in HelpMap {
s.WriteStr(part[0])
s.WriteStr(strings::Repeat(" ", (max - len(part[0])) + Space))
s.WriteStr(strings::Repeat(" ", (max-len(part[0]))+Space))
s.WriteStr(part[1])
if i+1 < len(HelpMap) {
s.WriteByte('\n')
Expand Down
8 changes: 4 additions & 4 deletions src/julec/obj/cxx/expr.jule
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ impl exprCoder {
| x == MinF32:
self.oc.write("jule::MIN_F32")
|:
ftoa(self.oc.Buf, x, 1 << 5)
ftoa(self.oc.Buf, x, 1<<5)
self.oc.write("f")
}
}
Expand All @@ -189,7 +189,7 @@ impl exprCoder {
| x == MinF64:
self.oc.write("jule::MIN_F64")
|:
ftoa(self.oc.Buf, x, 1 << 6)
ftoa(self.oc.Buf, x, 1<<6)
}
}

Expand Down Expand Up @@ -1224,7 +1224,7 @@ impl exprCoder {
self.oc.write(mapVar)
self.oc.write(" = ")
identCoder.funcIns(self.oc.Buf, maker)
self.oc.write("(); ")
self.oc.write("(); ")
for (_, mut pair) in m.Entries {
self.oc.write("(*")
identCoder.funcIns(self.oc.Buf, f)
Expand Down Expand Up @@ -2094,7 +2094,7 @@ fn operatorOverloadingBinary(mut &buf: StrBuilder, mut &s: &StructIns, &l: str,
// Equal method not exist. Compiler will create, use default method.
identCoder.structureIns(buf, s)
buf.WriteStr(structDefaultEqMethodSuffix)
goto common
goto common
}
panic("binary operator overloading is not exist, this is an implementation mistake")
}
Expand Down
6 changes: 3 additions & 3 deletions src/julec/obj/cxx/object.jule
Original file line number Diff line number Diff line change
Expand Up @@ -1315,8 +1315,8 @@ impl ObjectCoder {
fn end(mut &self) {
self.write(`int main(int argc, char *argv[], char *envp[]) {`)
self.write("\n\n")
self.initGlobals()
self.write(`
self.initGlobals()
self.write(`
__jule_argc = static_cast<jule::Int>(argc);
__jule_argv = reinterpret_cast<jule::U8**>(argv);
__jule_envp = reinterpret_cast<jule::U8**>(envp);
Expand All @@ -1338,7 +1338,7 @@ impl ObjectCoder {

fn insertBuf(mut &self, mut &buf: StrBuilder, pos: int) {
if buf.Len() > 0 {
mut head := make([]byte, 0, self.Buf.Len() + buf.Len())
mut head := make([]byte, 0, self.Buf.Len()+buf.Len())
head = append(head, unsafe { self.Buf.Buf() }[:pos]...)
head = append(head, unsafe { buf.Buf() }...)
head = append(head, unsafe { self.Buf.Buf() }[pos:]...)
Expand Down
4 changes: 2 additions & 2 deletions src/julec/opt/deadcode/scope.jule
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ impl scopeDeadCode {
}

fn eliminateDeadCodeOfScope(mut s: &Scope) {
labels := make([]&Label, 0, 1 << 4)
gotos := make([]&GotoSt, 0, 1 << 4)
labels := make([]&Label, 0, 1<<4)
gotos := make([]&GotoSt, 0, 1<<4)
mut sdc := &scopeDeadCode{
s: s,
labels: unsafe { (&[]&Label)(&labels) },
Expand Down
8 changes: 4 additions & 4 deletions std/bytes/bytes.jule
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn Repeat(s: []byte, mut n: int): []byte {
panic("std::bytes: repeat: integer buffer size overflow")
}

mut buff := make([]byte, len(s) * n)
mut buff := make([]byte, len(s)*n)
mut i := 0
for n > 0; n-- {
i += copy(buff[i:], s)
Expand Down Expand Up @@ -116,7 +116,7 @@ loop:
// returns -1 if not exist any match. Starts searching at right
// of slice to left.
fn FindLast(s: []byte, sub: []byte): int {
ret FindLastAt(s, sub, len(s) - 1)
ret FindLastAt(s, sub, len(s)-1)
}

// Returns index of first matched item with specified byte,
Expand Down Expand Up @@ -210,7 +210,7 @@ fn FindFnLastAt(s: []byte, mut i: int, f: fn(mut rune): bool): int {
// returns -1 if not exist any match. Starts searching at right
// of slice to left.
fn FindFnLast(s: []byte, f: fn(mut rune): bool): int {
ret FindFnLastAt(s, len(s) - 1, f)
ret FindFnLastAt(s, len(s)-1, f)
}

// Returns index of first matched item with any of runes,
Expand Down Expand Up @@ -336,7 +336,7 @@ fn Replace(mut s: []byte, sub: []byte, new: []byte, mut n: int): []byte {
n = m
}

mut ss := make([]byte, 0, len(s) + n * (len(new) - len(sub)))
mut ss := make([]byte, 0, len(s)+n*(len(new)-len(sub)))
mut i := 0
for n > 0; n-- {
j := FindAt(s, sub, i)
Expand Down
30 changes: 15 additions & 15 deletions std/conv/atof.jule
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ loop_end:
continue
}
if e < 10000 {
e = e * 10 + int(s[i]) - '0'
e = e*10 + int(s[i]) - '0'
}
}
dp += e * esign
Expand Down Expand Up @@ -315,7 +315,7 @@ impl decimal {
continue
}
if e < 10000 {
e = e * 10 + int(s[i]) - '0'
e = e*10 + int(s[i]) - '0'
}
}
self.dp += e * esign
Expand Down Expand Up @@ -406,21 +406,21 @@ impl decimal {
}

// Denormalized?
if mant&(1 << flt.mantbits) == 0 {
if mant&(1<<flt.mantbits) == 0 {
exp = flt.bias
}
goto out

overflow:
// ±inf
mant = 0
exp = int(uint(1) << flt.expbits - 1 + uint(flt.bias))
exp = int(uint(1)<<flt.expbits - 1 + uint(flt.bias))
overflow = true

out:
// Assemble bits.
mut bits := mant & (1 << flt.mantbits - 1)
bits |= u64((exp - flt.bias) & int(1 << flt.expbits - 1)) << flt.mantbits
mut bits := mant & (1<<flt.mantbits - 1)
bits |= u64((exp-flt.bias)&int(1<<flt.expbits-1)) << flt.mantbits
if self.neg {
bits |= 1 << flt.mantbits << flt.expbits
}
Expand Down Expand Up @@ -554,7 +554,7 @@ fn atof32exact(mantissa: u64, mut exp: int, mut neg: bool): (f: f32, ok: bool) {
// The string s has already been parsed into a mantissa, exponent, and sign (neg==true for negative).
// If trunc is true, trailing non-zero bits have been omitted from the mantissa.
fn atofHex(&flt: floatInfo, mut mantissa: u64, mut exp: int, neg: bool, trunc: bool): (f64, ConvError) {
maxExp := int(1 << flt.expbits) + flt.bias - 2
maxExp := int(1<<flt.expbits) + flt.bias - 2
minExp := flt.bias + 1
exp += int(flt.mantbits) // mantissa now implicitly divided by 2^mantbits.

Expand All @@ -571,16 +571,16 @@ fn atofHex(&flt: floatInfo, mut mantissa: u64, mut exp: int, neg: bool, trunc: b
if trunc {
mantissa |= 1
}
for mantissa>>(1 + flt.mantbits + 2) != 0 {
mantissa = mantissa >> 1 | mantissa & 1
for mantissa>>(1+flt.mantbits+2) != 0 {
mantissa = mantissa>>1 | mantissa&1
exp++
}

// If exponent is too negative,
// denormalize in hopes of making it representable.
// (The -2 is for the rounding bits.)
for mantissa > 1 && exp < minExp-2 {
mantissa = mantissa >> 1 | mantissa & 1
mantissa = mantissa>>1 | mantissa&1
exp++
}

Expand All @@ -591,7 +591,7 @@ fn atofHex(&flt: floatInfo, mut mantissa: u64, mut exp: int, neg: bool, trunc: b
exp += 2
if round == 3 {
mantissa++
if mantissa == 1<<(1 + flt.mantbits) {
if mantissa == 1<<(1+flt.mantbits) {
mantissa >>= 1
exp++
}
Expand All @@ -607,8 +607,8 @@ fn atofHex(&flt: floatInfo, mut mantissa: u64, mut exp: int, neg: bool, trunc: b
err = ConvError.OutOfRange
}

mut bits := mantissa & (1 << flt.mantbits - 1)
bits |= u64((exp - flt.bias) & int(1 << flt.expbits - 1)) << flt.mantbits
mut bits := mantissa & (1<<flt.mantbits - 1)
bits |= u64((exp-flt.bias)&int(1<<flt.expbits-1)) << flt.mantbits
if neg {
bits |= 1 << flt.mantbits << flt.expbits
}
Expand Down Expand Up @@ -656,7 +656,7 @@ fn atof32(s: str): (f: f32, n: int, err: ConvError) {
// have found the correct result. Confirm by
// converting the upper mantissa bound.
mut fUp := f32(0)
fUp, ok = eiselLemire32(mantissa + 1, exp, neg)
fUp, ok = eiselLemire32(mantissa+1, exp, neg)
if ok && f == fUp {
ret f, n, ConvError.Ok
}
Expand Down Expand Up @@ -713,7 +713,7 @@ fn atof64(s: str): (f: f64, n: int, err: ConvError) {
// have found the correct result. Confirm by
// converting the upper mantissa bound.
mut fUp := 0.
fUp, ok = eiselLemire64(mantissa + 1, exp, neg)
fUp, ok = eiselLemire64(mantissa+1, exp, neg)
if ok && f == fUp {
ret f, n, ConvError.Ok
}
Expand Down
8 changes: 4 additions & 4 deletions std/conv/atoi.jule
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ fn parseUint(mut &s: str, mut base: int, mut bitSize: int): (u64, ConvError) {
mut cutoff := u64(0)
match base {
| 10:
cutoff = u64.Max / 10 + 1
cutoff = u64.Max/10 + 1
| 16:
cutoff = u64.Max / 16 + 1
cutoff = u64.Max/16 + 1
|:
cutoff = u64.Max / u64(base) + 1
cutoff = u64.Max/u64(base) + 1
}

mut maxVal := u64(0)
Expand Down Expand Up @@ -193,7 +193,7 @@ fn ParseInt(mut s: str, base: int, mut bitSize: int)!: i64 {
bitSize = IntSize
}

cutoff := u64(1 << uint(bitSize - 1))
cutoff := u64(1 << uint(bitSize-1))
if !neg && un >= cutoff {
error(ConvError.OutOfRange)
}
Expand Down
12 changes: 6 additions & 6 deletions std/conv/decimal.jule
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ impl decimal {
mut i := 0
mut n := u64(0)
for i < self.dp && i < self.nd; i++ {
n = n * 10 + u64(self.d[i] - '0')
n = n*10 + u64(self.d[i]-'0')
}
for i < self.dp; i++ {
n *= 10
Expand Down Expand Up @@ -301,11 +301,11 @@ fn rightShift(mut &a: decimal, k: uint) {
break
}
c := uint(a.d[r])
n = n * 10 + c - '0'
n = n*10 + c - '0'
}
a.dp -= r - 1

mask := uint(1 << k) - 1
mask := uint(1<<k) - 1

// Pick up a digit, put down a digit.
for r < a.nd; r++ {
Expand All @@ -314,7 +314,7 @@ fn rightShift(mut &a: decimal, k: uint) {
n &= mask
a.d[w] = byte(dig + '0')
w++
n = n * 10 + c - '0'
n = n*10 + c - '0'
}

// Put down extra digits.
Expand Down Expand Up @@ -364,7 +364,7 @@ fn leftShift(mut &a: decimal, k: uint) {
for r >= 0; r-- {
n += (uint(a.d[r]) - '0') << k
quo := n / 10
rem := n - 10 * quo
rem := n - 10*quo
w--
if w < len(a.d) {
a.d[w] = byte(rem + '0')
Expand All @@ -377,7 +377,7 @@ fn leftShift(mut &a: decimal, k: uint) {
// Put down extra digits.
for n > 0 {
quo := n / 10
rem := n - 10 * quo
rem := n - 10*quo
w--
if w < len(a.d) {
a.d[w] = byte(rem + '0')
Expand Down
8 changes: 4 additions & 4 deletions std/conv/eisel_lemire.jule
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ fn eiselLemire64(mut man: u64, exp10: int, neg: bool): (f: f64, ok: bool) {
clz := bits::LeadingZeros64(man)
man <<= uint(clz)
const f64ExponentBias = 1023
mut retExp2 := u64(217706 * exp10 >> 16 + 64 + f64ExponentBias) - u64(clz)
mut retExp2 := u64(217706*exp10>>16+64+f64ExponentBias) - u64(clz)

// Multiplication.
mut xHi, mut xLo := bits::Mul64(man, detailedPowsOfTen[exp10-detailedPowsOfTenMinExp10][1])
Expand Down Expand Up @@ -100,7 +100,7 @@ fn eiselLemire64(mut man: u64, exp10: int, neg: bool): (f: f64, ok: bool) {
if retExp2-1 >= 0x7FF-1 {
ret 0, false
}
mut retBits := retExp2 << 52 | retMantissa & 0x000FFFFFFFFFFFFF
mut retBits := retExp2<<52 | retMantissa&0x000FFFFFFFFFFFFF
if neg {
retBits |= 0x8000000000000000
}
Expand Down Expand Up @@ -132,7 +132,7 @@ fn eiselLemire32(mut man: u64, exp10: int, neg: bool): (f: f32, ok: bool) {
clz := bits::LeadingZeros64(man)
man <<= uint(clz)
const f32ExponentBias = 127
mut retExp2 := u64(217706 * exp10 >> 16 + 64 + f32ExponentBias) - u64(clz)
mut retExp2 := u64(217706*exp10>>16+64+f32ExponentBias) - u64(clz)

// Multiplication.
mut x_hi, mut x_lo := bits::Mul64(man, detailedPowsOfTen[exp10-detailedPowsOfTenMinExp10][1])
Expand Down Expand Up @@ -175,7 +175,7 @@ fn eiselLemire32(mut man: u64, exp10: int, neg: bool): (f: f32, ok: bool) {
if retExp2-1 >= 0xFF-1 {
ret 0, false
}
mut retBits := retExp2 << 23 | retMantissa & 0x007FFFFF
mut retBits := retExp2<<23 | retMantissa&0x007FFFFF
if neg {
retBits |= 0x80000000
}
Expand Down
Loading

0 comments on commit d0ab555

Please sign in to comment.