Skip to content

Commit a95fd72

Browse files
authored
Merge pull request #225 from rhysd/crystal-0.18.4
Crystal 0.18.4
2 parents fe7f047 + 7546ae1 commit a95fd72

File tree

8 files changed

+21
-21
lines changed

8 files changed

+21
-21
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ coffee ./stepX_YYY
214214

215215
*The Crystal implementation of mal was created by [Linda_pp](https://github.com/rhysd)*
216216

217-
The Crystal implementation of mal has been tested with Crystal 0.17.4.
217+
The Crystal implementation of mal has been tested with Crystal 0.18.4.
218218

219219
```
220220
cd crystal

crystal/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ mal: $(LAST_STEP_BIN)
1313
cp $< $@
1414

1515
$(STEP_BINS): %: %.cr $(MAL_LIB)
16-
crystal build --release $<
16+
crystal compile --release $<
1717

1818
clean:
1919
rm -rf $(STEP_BINS) mal .crystal

crystal/core.cr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module Mal
1111
macro calc_op(op)
1212
-> (args : Array(Mal::Type)) {
1313
x, y = args[0].unwrap, args[1].unwrap
14-
eval_error "invalid arguments for binary operator {{op.id}}" unless x.is_a?(Int32) && y.is_a?(Int32)
14+
eval_error "invalid arguments for binary operator {{op.id}}" unless x.is_a?(Int64) && y.is_a?(Int64)
1515
Mal::Type.new(x {{op.id}} y)
1616
}
1717
end
@@ -33,9 +33,9 @@ def self.count(args)
3333
a = args.first.unwrap
3434
case a
3535
when Array
36-
a.size as Int32
36+
a.size.to_i64
3737
when Nil
38-
0
38+
0i64
3939
else
4040
eval_error "invalid argument for function 'count'"
4141
end
@@ -92,7 +92,7 @@ end
9292
def self.nth(args)
9393
a0, a1 = args[0].unwrap, args[1].unwrap
9494
eval_error "1st argument of nth must be list or vector" unless a0.is_a? Array
95-
eval_error "2nd argument of nth must be integer" unless a1.is_a? Int32
95+
eval_error "2nd argument of nth must be integer" unless a1.is_a? Int64
9696
a0[a1]
9797
end
9898

@@ -362,7 +362,7 @@ def self.seq(args)
362362
end
363363

364364
def self.time_ms(args)
365-
Time.now.epoch_ms.to_i32
365+
Time.now.epoch_ms.to_i64
366366
end
367367

368368
# Note:

crystal/printer.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ def pr_str(value, print_readably = true)
44
case value
55
when Nil then "nil"
66
when Bool then value.to_s
7-
when Int32 then value.to_s
7+
when Int64 then value.to_s
88
when Mal::List then "(#{value.map{|v| pr_str(v, print_readably) as String}.join(" ")})"
99
when Mal::Vector then "[#{value.map{|v| pr_str(v, print_readably) as String}.join(" ")}]"
1010
when Mal::Symbol then value.str.to_s

crystal/reader.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class Reader
7777
parse_error "expected Atom but got EOF" unless token
7878

7979
Mal::Type.new case
80-
when token =~ /^-?\d+$/ then token.to_i
80+
when token =~ /^-?\d+$/ then token.to_i64
8181
when token == "true" then true
8282
when token == "false" then false
8383
when token == "nil" then nil

crystal/step2_eval.cr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module Mal
1818
def num_func(func)
1919
-> (args : Array(Mal::Type)) {
2020
x, y = args[0].unwrap, args[1].unwrap
21-
eval_error "invalid arguments" unless x.is_a?(Int32) && y.is_a?(Int32)
21+
eval_error "invalid arguments" unless x.is_a?(Int64) && y.is_a?(Int64)
2222
Mal::Type.new func.call(x, y)
2323
}
2424
end
@@ -79,10 +79,10 @@ module Mal
7979
end
8080

8181
$repl_env = {
82-
"+" => Mal.num_func(->(x : Int32, y : Int32){ x + y }),
83-
"-" => Mal.num_func(->(x : Int32, y : Int32){ x - y }),
84-
"*" => Mal.num_func(->(x : Int32, y : Int32){ x * y }),
85-
"/" => Mal.num_func(->(x : Int32, y : Int32){ x / y }),
82+
"+" => Mal.num_func(->(x : Int64, y : Int64){ x + y }),
83+
"-" => Mal.num_func(->(x : Int64, y : Int64){ x - y }),
84+
"*" => Mal.num_func(->(x : Int64, y : Int64){ x * y }),
85+
"/" => Mal.num_func(->(x : Int64, y : Int64){ x / y }),
8686
} of String => Mal::Func
8787

8888
while line = my_readline("user> ")

crystal/step3_env.cr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ end
1616
def num_func(func)
1717
-> (args : Array(Mal::Type)) {
1818
x, y = args[0].unwrap, args[1].unwrap
19-
eval_error "invalid arguments" unless x.is_a?(Int32) && y.is_a?(Int32)
19+
eval_error "invalid arguments" unless x.is_a?(Int64) && y.is_a?(Int64)
2020
Mal::Type.new func.call(x, y)
2121
}
2222
end
2323

2424
$repl_env = Mal::Env.new nil
25-
$repl_env.set("+", Mal::Type.new num_func(->(x : Int32, y : Int32){ x + y }))
26-
$repl_env.set("-", Mal::Type.new num_func(->(x : Int32, y : Int32){ x - y }))
27-
$repl_env.set("*", Mal::Type.new num_func(->(x : Int32, y : Int32){ x * y }))
28-
$repl_env.set("/", Mal::Type.new num_func(->(x : Int32, y : Int32){ x / y }))
25+
$repl_env.set("+", Mal::Type.new num_func(->(x : Int64, y : Int64){ x + y }))
26+
$repl_env.set("-", Mal::Type.new num_func(->(x : Int64, y : Int64){ x - y }))
27+
$repl_env.set("*", Mal::Type.new num_func(->(x : Int64, y : Int64){ x * y }))
28+
$repl_env.set("/", Mal::Type.new num_func(->(x : Int64, y : Int64){ x / y }))
2929

3030
module Mal
3131
extend self

crystal/types.cr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ module Mal
3838

3939
class Type
4040
alias Func = (Array(Type) -> Type)
41-
alias ValueType = Nil | Bool | Int32 | String | Symbol | List | Vector | HashMap | Func | Closure | Atom
41+
alias ValueType = Nil | Bool | Int64 | String | Symbol | List | Vector | HashMap | Func | Closure | Atom
4242

4343
property :is_macro, :meta
4444

@@ -80,7 +80,7 @@ module Mal
8080
{% for op in ops %}
8181
def {{op.id}}(other : Mal::Type)
8282
l, r = @val, other.unwrap
83-
{% for t in [Int32, String] %}
83+
{% for t in [Int64, String] %}
8484
if l.is_a?({{t}}) && r.is_a?({{t}})
8585
return (l) {{op.id}} (r)
8686
end

0 commit comments

Comments
 (0)