Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: crystal-lang/crystal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 993bda11f166
Choose a base ref
...
head repository: crystal-lang/crystal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: acd6a7685ed4
Choose a head ref
  • 2 commits
  • 7 files changed
  • 1 contributor

Commits on Jul 5, 2016

  1. Compiler: move core_ext method to util (simpler)

    Ary Borenszweig committed Jul 5, 2016
    Copy the full SHA
    2a3be51 View commit details
  2. Some fixes related to the ifdef -> flag? change

    Ary Borenszweig committed Jul 5, 2016
    Copy the full SHA
    acd6a76 View commit details
3 changes: 2 additions & 1 deletion samples/sdl/sdl/lib_sdl.cr
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
{% else %}
@[Link("SDL")]
{% end %}

lib LibSDL
INIT_TIMER = 0x00000001_u32
INIT_AUDIO = 0x00000010_u32
@@ -160,6 +161,6 @@ end
end
{% elsif flag?(:darwin) %}
redefine_main(SDL_main) do |main|
{{main}}
\{{main}}
end
{% end %}
5 changes: 0 additions & 5 deletions src/compiler/crystal/core_ext/enumerable.cr

This file was deleted.

2 changes: 1 addition & 1 deletion src/compiler/crystal/macros/macros.cr
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ module Crystal
end
normalize(generated_node, inside_exp: inside_exp)
rescue ex : Crystal::SyntaxException
node.raise "macro didn't expand to a valid program, it expanded to:\n\n#{"=" * 80}\n#{"-" * 80}\n#{generated_source.lines.to_s_with_line_numbers}\n#{"-" * 80}\n#{ex.to_s_with_source(generated_source)}\n#{"=" * 80}"
node.raise "macro didn't expand to a valid program, it expanded to:\n\n#{"=" * 80}\n#{"-" * 80}\n#{Crystal.with_line_numbers(generated_source)}\n#{"-" * 80}\n#{ex.to_s_with_source(generated_source)}\n#{"=" * 80}"
end
end
end
4 changes: 0 additions & 4 deletions src/compiler/crystal/semantic/cleanup_transformer.cr
Original file line number Diff line number Diff line change
@@ -406,10 +406,6 @@ module Crystal
node
end

def number_lines(source)
source.lines.to_s_with_line_numbers
end

class ClosuredVarsCollector < Visitor
getter vars : Array(ASTNode)
@a_def : Def
3 changes: 1 addition & 2 deletions src/compiler/crystal/semantic/exception.cr
Original file line number Diff line number Diff line change
@@ -87,9 +87,8 @@ module Crystal
append_error_message io, msg
end
when VirtualFile
lines = filename.source.lines.to_a
io << "in macro '#{filename.macro.name}' #{filename.macro.location.try &.filename}:#{filename.macro.location.try &.line_number}, line #{@line}:\n\n"
io << lines.to_s_with_line_numbers
io << Crystal.with_line_numbers(filename.source)
is_macro = true
else
lines = source ? source.lines.to_a : nil
2 changes: 1 addition & 1 deletion src/compiler/crystal/tools/formatter.cr
Original file line number Diff line number Diff line change
@@ -1228,7 +1228,7 @@ module Crystal
end

def format_ifdef_cond(cond : ASTNode)
cond.raise "Bug: unexpected node in ifdef condition"
raise "Bug: unexpected node in ifdef condition"
end

def format_ifdef_nested_cond(cond)
4 changes: 4 additions & 0 deletions src/compiler/crystal/util.cr
Original file line number Diff line number Diff line change
@@ -41,4 +41,8 @@ module Crystal
def self.tempfile(basename)
CacheDir.instance.join("crystal-run-#{basename}.tmp")
end

def self.with_line_numbers(source : String)
source.lines.map_with_index { |line, i| "#{"%3d" % (i + 1)}. #{line.to_s.chomp}" }.join "\n"
end
end