We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents fe7f047 + 7546ae1 commit a95fd72Copy full SHA for a95fd72
README.md
@@ -214,7 +214,7 @@ coffee ./stepX_YYY
214
215
*The Crystal implementation of mal was created by [Linda_pp](https://github.com/rhysd)*
216
217
-The Crystal implementation of mal has been tested with Crystal 0.17.4.
+The Crystal implementation of mal has been tested with Crystal 0.18.4.
218
219
```
220
cd crystal
crystal/Makefile
@@ -13,7 +13,7 @@ mal: $(LAST_STEP_BIN)
13
cp $< $@
14
15
$(STEP_BINS): %: %.cr $(MAL_LIB)
16
- crystal build --release $<
+ crystal compile --release $<
17
18
clean:
19
rm -rf $(STEP_BINS) mal .crystal
crystal/core.cr
@@ -11,7 +11,7 @@ module Mal
11
macro calc_op(op)
12
-> (args : Array(Mal::Type)) {
x, y = args[0].unwrap, args[1].unwrap
- eval_error "invalid arguments for binary operator {{op.id}}" unless x.is_a?(Int32) && y.is_a?(Int32)
+ eval_error "invalid arguments for binary operator {{op.id}}" unless x.is_a?(Int64) && y.is_a?(Int64)
Mal::Type.new(x {{op.id}} y)
}
end
@@ -33,9 +33,9 @@ def self.count(args)
33
a = args.first.unwrap
34
case a
35
when Array
36
- a.size as Int32
+ a.size.to_i64
37
when Nil
38
- 0
+ 0i64
39
else
40
eval_error "invalid argument for function 'count'"
41
@@ -92,7 +92,7 @@ end
92
def self.nth(args)
93
a0, a1 = args[0].unwrap, args[1].unwrap
94
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
+ eval_error "2nd argument of nth must be integer" unless a1.is_a? Int64
96
a0[a1]
97
98
@@ -362,7 +362,7 @@ def self.seq(args)
362
363
364
def self.time_ms(args)
365
- Time.now.epoch_ms.to_i32
+ Time.now.epoch_ms.to_i64
366
367
368
# Note:
crystal/printer.cr
@@ -4,7 +4,7 @@ def pr_str(value, print_readably = true)
4
case value
5
when Nil then "nil"
6
when Bool then value.to_s
7
- when Int32 then value.to_s
+ when Int64 then value.to_s
8
when Mal::List then "(#{value.map{|v| pr_str(v, print_readably) as String}.join(" ")})"
9
when Mal::Vector then "[#{value.map{|v| pr_str(v, print_readably) as String}.join(" ")}]"
10
when Mal::Symbol then value.str.to_s
crystal/reader.cr
@@ -77,7 +77,7 @@ class Reader
77
parse_error "expected Atom but got EOF" unless token
78
79
Mal::Type.new case
80
- when token =~ /^-?\d+$/ then token.to_i
+ when token =~ /^-?\d+$/ then token.to_i64
81
when token == "true" then true
82
when token == "false" then false
83
when token == "nil" then nil
crystal/step2_eval.cr
@@ -18,7 +18,7 @@ module Mal
def num_func(func)
20
21
- eval_error "invalid arguments" unless x.is_a?(Int32) && y.is_a?(Int32)
+ eval_error "invalid arguments" unless x.is_a?(Int64) && y.is_a?(Int64)
22
Mal::Type.new func.call(x, y)
23
24
@@ -79,10 +79,10 @@ module Mal
$repl_env = {
- "+" => Mal.num_func(->(x : Int32, y : Int32){ x + y }),
- "-" => 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 }),
+ "+" => Mal.num_func(->(x : Int64, y : Int64){ x + y }),
+ "-" => Mal.num_func(->(x : Int64, y : Int64){ x - y }),
+ "*" => Mal.num_func(->(x : Int64, y : Int64){ x * y }),
+ "/" => Mal.num_func(->(x : Int64, y : Int64){ x / y }),
86
} of String => Mal::Func
87
88
while line = my_readline("user> ")
crystal/step3_env.cr
@@ -16,16 +16,16 @@ end
$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 }))
+$repl_env.set("+", Mal::Type.new num_func(->(x : Int64, y : Int64){ x + y }))
+$repl_env.set("-", Mal::Type.new num_func(->(x : Int64, y : Int64){ x - y }))
+$repl_env.set("*", Mal::Type.new num_func(->(x : Int64, y : Int64){ x * y }))
+$repl_env.set("/", Mal::Type.new num_func(->(x : Int64, y : Int64){ x / y }))
29
30
module Mal
31
extend self
crystal/types.cr
@@ -38,7 +38,7 @@ module Mal
class Type
alias Func = (Array(Type) -> Type)
- alias ValueType = Nil | Bool | Int32 | String | Symbol | List | Vector | HashMap | Func | Closure | Atom
+ alias ValueType = Nil | Bool | Int64 | String | Symbol | List | Vector | HashMap | Func | Closure | Atom
42
43
property :is_macro, :meta
44
@@ -80,7 +80,7 @@ module Mal
{% for op in ops %}
def {{op.id}}(other : Mal::Type)
l, r = @val, other.unwrap
- {% for t in [Int32, String] %}
+ {% for t in [Int64, String] %}
if l.is_a?({{t}}) && r.is_a?({{t}})
return (l) {{op.id}} (r)
0 commit comments