Skip to content

Commit 71b82b3

Browse files
committed
Rename ir.Const to ir.Literal
1 parent edf1256 commit 71b82b3

3 files changed

Lines changed: 20 additions & 20 deletions

File tree

src/ir.jl

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@ struct Var <: IR
66
id::String
77
end
88

9-
struct Const <: IR
9+
struct Literal <: IR
1010
value::Real
1111
end
1212

1313
struct Mat <: IR
14-
id::Union{Var,Const}
14+
id::Union{Var,Literal}
1515
end
1616

1717
struct Vec <: IR
18-
id::Union{Var,Const}
18+
id::Union{Var,Literal}
1919
end
2020

2121
struct Scal <: IR
22-
id::Union{Var,Const}
22+
id::Union{Var,Literal}
2323
end
2424

2525
struct Identity <: IR end
@@ -102,7 +102,7 @@ function _get_variables(arg::Var)
102102
return arg.id
103103
end
104104

105-
function _get_variables(arg::Const)
105+
function _get_variables(arg::Literal)
106106
return _get_variables(arg.value)
107107
end
108108

@@ -221,21 +221,21 @@ function to_ir(arg::Literal)
221221

222222
if length(ids) == 2
223223
if flip(ids[1]) == ids[2]
224-
return ir.Trace(ir.Mat(ir.Const(arg.value)))
224+
return ir.Trace(ir.Mat(ir.Literal(arg.value)))
225225
elseif typeof(ids[1]) == Upper && typeof(ids[2]) == Lower
226-
return ir.Mat(ir.Const(arg.value))
226+
return ir.Mat(ir.Literal(arg.value))
227227
elseif typeof(ids[1]) == Lower && typeof(ids[2]) == Upper
228-
return ir.Transpose(ir.Mat(ir.Const(arg.value)))
228+
return ir.Transpose(ir.Mat(ir.Literal(arg.value)))
229229
end
230230
elseif length(ids) == 1
231231
if typeof(ids[1]) == Upper
232-
return ir.Vec(ir.Const(arg.value))
232+
return ir.Vec(ir.Literal(arg.value))
233233
elseif typeof(ids[1]) == Lower
234-
return ir.Transpose(ir.Vec(ir.Const(arg.value)))
234+
return ir.Transpose(ir.Vec(ir.Literal(arg.value)))
235235
end
236236
end
237237

238-
return ir.Scal(ir.Const(arg.value))
238+
return ir.Scal(ir.Literal(arg.value))
239239
end
240240

241241
function to_ir(arg::KrD)
@@ -259,21 +259,21 @@ function to_ir(arg::Zero)
259259

260260
if length(ids) == 2
261261
if typeof(ids[1]) == Upper && typeof(ids[2]) == Lower
262-
return ir.Mat(ir.Const(0))
262+
return ir.Mat(ir.Literal(0))
263263
elseif typeof(ids[1]) == Lower && typeof(ids[2]) == Upper
264-
return ir.Transpose(ir.Mat(ir.Const(0)))
264+
return ir.Transpose(ir.Mat(ir.Literal(0)))
265265
end
266266
elseif length(ids) == 1
267267
if typeof(ids[1]) == Upper
268-
return ir.Vec(ir.Const(0))
268+
return ir.Vec(ir.Literal(0))
269269
elseif typeof(ids[1]) == Lower
270-
return ir.Transpose(ir.Vec(ir.Const(0)))
270+
return ir.Transpose(ir.Vec(ir.Literal(0)))
271271
end
272272
end
273273
end
274274

275275
function to_ir(arg::Real)
276-
return ir.Scal(ir.Const(arg))
276+
return ir.Scal(ir.Literal(arg))
277277
end
278278

279279
function to_ir(arg::UnaryOperation{Abs})
@@ -370,9 +370,9 @@ function to_ir(arg::BinaryOperation{Mult})
370370
)
371371
elseif all(typeof.(terms) .== KrD)
372372
if typeof(target_indices[1]) == Upper
373-
return ir.Vec(ir.Const(1))
373+
return ir.Vec(ir.Literal(1))
374374
else
375-
return ir.Transpose(ir.Vec(ir.Const(1)))
375+
return ir.Transpose(ir.Vec(ir.Literal(1)))
376376
end
377377
elseif arg.arg1 isa Literal || arg.arg2 isa Literal
378378
tensor = if arg.arg1 isa Literal

src/julia.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ function to_julia(arg::ir.Var)
33
return Symbol(arg.id)
44
end
55

6-
function to_julia(arg::ir.Const)
6+
function to_julia(arg::ir.Literal)
77
return :($(arg.value))
88
end
99

src/stdstr.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function to_std_str(arg::ir.Var)
2727
return arg.id
2828
end
2929

30-
function to_std_str(arg::ir.Const)
30+
function to_std_str(arg::ir.Literal)
3131
return to_std_str(arg.value)
3232
end
3333

0 commit comments

Comments
 (0)