This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "spec" | |
| module UTF16 | |
| def self.encode(string : String) : Slice(UInt16) | |
| size = 0 | |
| string.each_char do |char| | |
| size += char.ord < 0x10000 ? 1 : 2 | |
| end | |
| slice = Slice(UInt16).new(size) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Foo | |
| def foo(x) | |
| # Rename this call from "bar" to "baz": | |
| # What other things change in this file? | |
| # | |
| # According to what's called, Bar#bar needs | |
| # to change. But what about Baz#bar? I can | |
| # also pass Baz.new to Foo.new.foo. There's | |
| # no way to tell if that should be renamed too. | |
| # |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "csv" | |
| class CSV | |
| macro mapping(mappings) | |
| {% for key, value in mappings %} | |
| {% mappings[key] = {type: value} unless value.is_a?(HashLiteral) %} | |
| {% end %} | |
| {% for key, mapping in mappings %} | |
| property {{key}} : {{mapping[:type]}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/src/compiler/crystal/semantic/cleanup_transformer.cr b/src/compiler/crystal/semantic/cleanup_transformer.cr | |
| index 40693c55a..bd90f1c3e 100644 | |
| --- a/src/compiler/crystal/semantic/cleanup_transformer.cr | |
| +++ b/src/compiler/crystal/semantic/cleanup_transformer.cr | |
| @@ -23,6 +23,8 @@ module Crystal | |
| initializer.node = initializer.node.transform(transformer) | |
| end | |
| end | |
| + | |
| + TypesAndMethodsPrinter.new.print_type_with_methods(self) |
This file has been truncated, but you can view the full file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| |=== <Program> ===| | |
| #__crystal_get_exception(Pointer(LibUnwind::Exception)) | |
| #__crystal_malloc(UInt32) | |
| #__crystal_malloc_atomic(UInt32) | |
| #__crystal_personality(Int32, LibUnwind::Action, UInt64, Pointer(LibUnwind::Exception), Pointer(Void)) | |
| #__crystal_raise(Pointer(LibUnwind::Exception)) | |
| #__crystal_raise_string(Pointer(UInt8)) | |
| #__crystal_realloc(Pointer(Void), UInt32) | |
| #__crystal_sigfault_handler(Int32, Pointer(Void)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def sozcore2(num, start_num, mod) | |
| residues, rescnt = make_residues_rescnt(mod) # parameters for the PG | |
| maxprms, x = pcs_to_num(num, mod, rescnt, residues, true) # num pcs <= end_num | |
| # for start_num pc, find num pcs <, residue index, and resgroup mod value | |
| pcs2start, rs, modks = pcs_to_num(start_num, mod, rescnt, residues, false) | |
| sqrtN = Math.sqrt(num).to_i # sqrt of end_num (end of range) | |
| pcs2sqrtN, y = pcs_to_num(sqrtN, mod, rescnt, residues, true) # num pcs <= sqrt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "big_int" | |
| require "benchmark" | |
| lib LibGMP | |
| fun sizeinbase = __gmpz_sizeinbase(op : MPZ*, base : Int32) : Int32 | |
| fun export = __gmpz_export(rop : Void*, countp : Int32*, order : Int32, size : Int32, endian : Int32, nails : Int32, op : MPZ*) : UInt8* | |
| end | |
| struct BigInt | |
| def size |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "http/client" | |
| require "yaml" | |
| record PosRange, start : Int32, end : Int32 | |
| repo = ARGV[0]? | |
| unless repo | |
| abort "missing repo" | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @[Link("lmdb")] | |
| lib LibLMDB | |
| alias Int = LibC::Int | |
| alias UInt = LibC::UInt | |
| alias Char = LibC::Char | |
| alias SizeT = LibC::SizeT | |
| type Env = Void* | |
| type Txn = Void* | |
| type Cursor = Void* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ### References | |
| # | |
| # * [Christian Lindig, Strictly Pretty, March 2000](http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.34.2200) | |
| # * [Philip Wadler, A prettier printer, March 1998](http://homepages.inf.ed.ac.uk/wadler/topics/language-design.html#prettier) | |
| class PrettyPrinter | |
| # :nodoc: | |
| private alias Element = Break | Text | Group | |
| # :nodoc: | |
| private record Break, string : String do |