Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overflow prepare compiler #7262

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion spec/compiler/codegen/alias_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe "Code gen: alias" do
if n == 0
1
else
foo(n - 1).as(Foo)
foo(n &- 1).as(Foo)
end
end

Expand Down
16 changes: 8 additions & 8 deletions spec/compiler/codegen/array_literal_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe "Code gen: array literal spec" do
end

def <<(element)
@value += element
@value &+= element
end

def value
Expand All @@ -30,7 +30,7 @@ describe "Code gen: array literal spec" do
end

def <<(element : T)
@value += element
@value &+= element
end

def value
Expand All @@ -51,7 +51,7 @@ describe "Code gen: array literal spec" do
end

def <<(element : T)
@value += element
@value &+= element
end

def value
Expand All @@ -72,7 +72,7 @@ describe "Code gen: array literal spec" do
end

def <<(element : T)
@value += element
@value &+= element
end

def value
Expand All @@ -95,7 +95,7 @@ describe "Code gen: array literal spec" do
end

def <<(element : T)
@value += element
@value &+= element
end

def value
Expand All @@ -118,7 +118,7 @@ describe "Code gen: array literal spec" do
end

def <<(element)
@value += element
@value &+= element
end

def value
Expand All @@ -140,7 +140,7 @@ describe "Code gen: array literal spec" do
end

def <<(element)
@value += element
@value &+= element
end

def value
Expand All @@ -163,7 +163,7 @@ describe "Code gen: array literal spec" do
end

def <<(element : T)
@value += element
@value &+= element
end

def value
Expand Down
48 changes: 26 additions & 22 deletions spec/compiler/codegen/block_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe "Code gen: block" do
end

foo do |x|
x + 1
x &+ 1
end
").to_i.should eq(2)
end
Expand All @@ -32,7 +32,7 @@ describe "Code gen: block" do
end

foo(3) do |x|
x + 1
x &+ 1
end
").to_i.should eq(4)
end
Expand All @@ -46,7 +46,7 @@ describe "Code gen: block" do
end

3.foo do |x|
x + 1
x &+ 1
end
").to_i.should eq(4)
end
Expand All @@ -60,7 +60,7 @@ describe "Code gen: block" do
end

3.foo(2) do |x, i|
x + i
x &+ i
end
").to_i.should eq(5)
end
Expand All @@ -73,7 +73,7 @@ describe "Code gen: block" do

x = 1
foo do
x + 1
x &+ 1
end
").to_i.should eq(2)
end
Expand All @@ -90,7 +90,7 @@ describe "Code gen: block" do
end

Foo.new.foo do |x|
x + 1
x &+ 1
end
").to_i.should eq(2)
end
Expand Down Expand Up @@ -127,7 +127,7 @@ describe "Code gen: block" do
end
end

Foo.new.foo { |x| x + 1 }
Foo.new.foo { |x| x &+ 1 }
").to_i.should eq(2)
end

Expand Down Expand Up @@ -320,6 +320,8 @@ describe "Code gen: block" do

it "call block from dispatch and use local vars" do
run("
require \"prelude\"

def bar(y)
yield y
end
Expand Down Expand Up @@ -377,7 +379,7 @@ describe "Code gen: block" do
end

a = 0
foo { a += 1; break }
foo { a &+= 1; break }
a
").to_i.should eq(1)
end
Expand Down Expand Up @@ -445,7 +447,7 @@ describe "Code gen: block" do
require \"nil\"

def foo
1 + yield
1 &+ yield
end

foo { break 2 }.to_i
Expand Down Expand Up @@ -494,7 +496,7 @@ describe "Code gen: block" do
end

def foo
bar { 1 + yield }
bar { 1 &+ yield }
end

foo { break 3 }
Expand Down Expand Up @@ -906,6 +908,8 @@ describe "Code gen: block" do

it "codegens dispatch with block and break (1)" do
run("
require \"prelude\"

class Foo(T)
def initialize(@x : T)
end
Expand Down Expand Up @@ -1021,7 +1025,7 @@ describe "Code gen: block" do
end

foo = Foo.new do |a|
a + 1
a &+ 1
end
foo.x
)).to_i.should eq(2)
Expand Down Expand Up @@ -1135,7 +1139,7 @@ describe "Code gen: block" do
foo do |key|
if 1 == 1
extra = 1
extra + key
extra &+ key
end
end

Expand Down Expand Up @@ -1201,7 +1205,7 @@ describe "Code gen: block" do

a = 0
foo do |x|
a += x
a &+= x
next if true
break
end
Expand All @@ -1219,7 +1223,7 @@ describe "Code gen: block" do

a = 0
foo do |x|
a += x
a &+= x
next if 1 == 1
break
end
Expand Down Expand Up @@ -1358,7 +1362,7 @@ describe "Code gen: block" do

a = 0
foo do |x|
a += x
a &+= x
end
a
)).to_i.should eq(4)
Expand All @@ -1372,7 +1376,7 @@ describe "Code gen: block" do
end

foo do |x, y, z|
x + y + z
x &+ y &+ z
end
)).to_i.should eq(6)
end
Expand All @@ -1396,7 +1400,7 @@ describe "Code gen: block" do
end

foo do |*args|
args[0] + args[1] + args[2]
args[0] &+ args[1] &+ args[2]
end
)).to_i.should eq(6)
end
Expand All @@ -1408,7 +1412,7 @@ describe "Code gen: block" do
end

foo do |x, y, *z, w|
((((x + y) * z[0]) - z[1]) * z[2]) - w
((((x &+ y) &* z[0]) &- z[1]) &* z[2]) &- w
end
)).to_i.should eq(((((1 + 2) * 3) - 4) * 5) - 6)
end
Expand All @@ -1422,7 +1426,7 @@ describe "Code gen: block" do

total = 0
foo do |*args|
total += args[0].to_i
total &+= args[0].to_i
end
total
)).to_i.should eq(3)
Expand All @@ -1436,7 +1440,7 @@ describe "Code gen: block" do
end

foo do |x, y, z|
(x + y) * z
(x &+ y) &* z
end
)).to_i.should eq((1 + 2) * 4)
end
Expand All @@ -1453,7 +1457,7 @@ describe "Code gen: block" do
w = 4
foo do |(x, y), (z, w)|
end
x + y + z + w
x &+ y &+ z &+ w
)).to_i.should eq(10)
end

Expand Down Expand Up @@ -1506,7 +1510,7 @@ describe "Code gen: block" do

a = fn(1 || 'a') { 2 }
b = fn('a' || 1) { 2 }
a + b
a &+ b
)).to_i.should eq(3)
end

Expand Down
2 changes: 1 addition & 1 deletion spec/compiler/codegen/c_struct_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ describe "Code gen: struct" do
end

point = LibC::Point.new x: 1, y: 2
point.x + point.y
point.x &+ point.y
)).to_i.should eq(3)
end

Expand Down
2 changes: 1 addition & 1 deletion spec/compiler/codegen/class_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe "Code gen: class" do

f = Foo.new(2)
g = Foo.new(40)
f.coco + g.coco
f.coco &+ g.coco
").to_i.should eq(42)
end

Expand Down
14 changes: 7 additions & 7 deletions spec/compiler/codegen/class_var_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,15 @@ describe "Codegen: class var" do
@@var : Int32
@@var = begin
a = class_method
a + 3
a &+ 3
end

def self.var
@@var
end

def self.class_method
1 + 2
1 &+ 2
end
end

Expand All @@ -130,7 +130,7 @@ describe "Codegen: class var" do
run(%(
class Foo
@@var2 : Int32
@@var2 = @@var + 1
@@var2 = @@var &+ 1

@@var = 41

Expand Down Expand Up @@ -199,7 +199,7 @@ describe "Codegen: class var" do
def foo
a = 1
b = 2
a + b
a &+ b
end

CONST = foo()
Expand Down Expand Up @@ -256,7 +256,7 @@ describe "Codegen: class var" do
@@foo = begin
a = 1
b = 2
a + b
a &+ b
end

def self.foo
Expand All @@ -274,7 +274,7 @@ describe "Codegen: class var" do
@@foo : Int32 = begin
a = 1
b = 2
a + b
a &+ b
end

def self.foo
Expand Down Expand Up @@ -548,7 +548,7 @@ describe "Codegen: class var" do
c = f2.bar
f2.bar = 20
d = f1.bar
a + b + c + d
a &+ b &+ c &+ d
)).to_i.should eq(1 + 1 + 10 + 20)
end
end
Loading