// foo->member_function(...)
static SymresStatus symres_method_call(AstBinaryOp** mcall) {
// :EliminatingSymres
+
+ // We have to check this no matter what, because if we return to symbol resolution
+ // the left hand side could be something different. In particular this was a problem
+ // when expanding `some_map["value"]->unwrap()`, as the left hand side expands to a
+ // macro.
+ SYMRES(expression, &(*mcall)->left);
+
if (((*mcall)->flags & Ast_Flag_Has_Been_Symres) == 0) {
- SYMRES(expression, &(*mcall)->left);
if ((*mcall)->left == NULL) return Symres_Error;
if ((*mcall)->right->kind != Ast_Kind_Call) {
hashes : [] i32;
entries : [..] Entry(Key_Type, Value_Type);
- // The value provided by `map.get`, if nothing was found.
- default_value : Value_Type;
-
Entry :: struct (K: type_expr, V: type_expr) {
next : i32;
hash : u32;
#doc """
Creates and initializes a new map using the types provided.
"""
-make :: macro ($Key: type_expr, $Value: type_expr, default := Value.{}) -> Map(Key, Value) {
+make :: macro ($Key: type_expr, $Value: type_expr) -> Map(Key, Value) {
map : Map(Key, Value);
- #this_package.init(&map, default = default);
+ #this_package.init(&map);
return map;
}
#doc "Initializes a map."
-init :: (use map: &Map($K, $V), default := V.{}) {
+init :: (use map: &Map($K, $V)) {
__initialize(map);
allocator = context.allocator;
- default_value = default;
hashes = builtin.make([] u32, 8, allocator=allocator);
array.fill(hashes, -1);
lr := lookup(map, key);
if lr.entry_index >= 0 do return entries[lr.entry_index].value;
- return default_value;
+ return .{};
}
#doc """
registers them to be used in format_any and parse_any.
"""
custom_formatters_initialized :: #init () {
- map.init(&custom_formatters, default=null_proc);
- map.init(&custom_parsers, default=null_proc);
+ map.init(&custom_formatters);
+ map.init(&custom_parsers);
#if Enable_Custom_Formatters {
use runtime.info {*};
file := contents;
- mem := map.make(u64, u64, default=0);
+ mem := map.make(u64, u64);
defer map.free(&mem);
mask : Bitmask;
// The current implementation of Map is rather slow at a large scale.
// Any changes to the implementation of Map should be tested on this
// file to validate if they 1) work and 2) are faster.
- nums := map.make(u32, spoken_times, .{});
+ nums := map.make(u32, spoken_times);
defer map.free(&nums);
turn := 1;
file := contents;
- cubes := map.make(CubePos, CubeState, .{});
+ cubes := map.make(CubePos, CubeState);
defer map.free(&cubes);
z := 0;
tiles := array.make(Tile);
defer array.free(&tiles);
- tile_map := map.make(u32, &Tile, null);
+ tile_map := map.make(u32, &Tile);
defer map.free(&tile_map);
tile_data := cast(&TileData) calloc(200 * sizeof TileData);
file := contents;
- map.init(&ingredient_map, .{});
- map.init(&allergen_map, .{});
+ map.init(&ingredient_map);
+ map.init(&allergen_map);
defer {
map.free(&ingredient_map);
map.free(&allergen_map);
}
recursive_combat :: (player1: &[..] u32, player2: &[..] u32) -> u32 {
- hand_seen := map.make(str, bool, false);
+ hand_seen := map.make(str, bool);
defer map.free(&hand_seen);
while player1.count > 0 && player2.count > 0 {
file_stream := io.buffer_stream_make(contents);
file := io.reader_make(&file_stream);
- grid := map.make(Vec2, Cell, .{}); // `true` is black
+ grid := map.make(Vec2, Cell); // `true` is black
defer map.free(&grid);
while !io.reader_empty(&file) {
dlp_bsgs :: (n: u32, a: u32, b: u32) -> u32 {
m := cast(u32) math.ceil(math.sqrt(cast(f64) n));
- t := map.make(u32, u32, default=0);
+ t := map.make(u32, u32);
defer map.free(&t);
tmp: u64 = 1;
bg_init :: (use graph: &BagGraph) {
array.init(&nodes, 16);
- map.init(&node_map, null);
+ map.init(&node_map);
}
bg_free :: (use graph: &BagGraph) {
// Returns if the program successfully exited.
get_acc_value :: (instrs: [..] Instruction, ret_acc: &i32) -> bool {
- already_been := map.make(i32, bool, false);
+ already_been := map.make(i32, bool);
defer map.free(&already_been);
ip := 0;
// This is so much cleaner than the alternative.
- ages := map.make(str, u32, default=0);
+ ages := map.make(str, u32);
defer delete(&ages);
map.put(&ages, "Dwight", 32);
main :: (args: [] cstr) {
imap : Map(i32, str);
- map.init(&imap, "");
+ map.init(&imap);
defer {
print("Freeing map\n");
map.free(&imap);