Skip to content

Commit

Permalink
rename: HashTable => Dict, IdTable => ObjectIdDict [closes #766].
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanKarpinski committed Apr 26, 2012
1 parent ccfc195 commit 9296f4f
Show file tree
Hide file tree
Showing 24 changed files with 181 additions and 179 deletions.
12 changes: 6 additions & 6 deletions base/array.jl
Expand Up @@ -203,7 +203,7 @@ function ref(A::Array, I::Indices...)
X = similar(A, d[1:i])

if is(ref_cache,nothing)
ref_cache = HashTable()
ref_cache = Dict()
end
gen_cartesian_map(ref_cache, ivars -> quote
X[storeind] = A[$(ivars...)]
Expand Down Expand Up @@ -358,7 +358,7 @@ let assign_cache = nothing
global assign
function assign(A::Array, x, I0::Indices, I::Indices...)
if is(assign_cache,nothing)
assign_cache = HashTable()
assign_cache = Dict()
end
gen_cartesian_map(assign_cache, ivars->:(A[$(ivars...)] = x),
tuple(I0, I...),
Expand All @@ -372,7 +372,7 @@ let assign_cache = nothing
global assign
function assign(A::Array, X::AbstractArray, I0::Indices, I::Indices...)
if is(assign_cache,nothing)
assign_cache = HashTable()
assign_cache = Dict()
end
gen_cartesian_map(assign_cache, ivars->:(A[$(ivars...)] = X[refind];
refind += 1),
Expand Down Expand Up @@ -926,7 +926,7 @@ function findn{T}(A::StridedArray{T})
ranges = ntuple(ndims(A), d->(1:size(A,d)))

if is(findn_cache,nothing)
findn_cache = HashTable()
findn_cache = Dict()
end

gen_cartesian_map(findn_cache, findn_one, ranges,
Expand Down Expand Up @@ -1023,7 +1023,7 @@ function areduce(f::Function, A::StridedArray, region::Region, v0, RType::Type)
R = similar(A, RType, dimsR)

if is(areduce_cache,nothing)
areduce_cache = HashTable()
areduce_cache = Dict()
end

key = ndimsA
Expand Down Expand Up @@ -1345,7 +1345,7 @@ function permute(A::StridedArray, perm)
end

if is(permute_cache,nothing)
permute_cache = HashTable()
permute_cache = Dict()
end

gen_cartesian_map(permute_cache, permute_one, ranges,
Expand Down
2 changes: 1 addition & 1 deletion base/client.jl
Expand Up @@ -187,7 +187,7 @@ function _start()
ccall(:jl_register_toplevel_eh, Void, ())
ccall(:jl_start_io_thread, Void, ())
global const Workqueue = WorkItem[]
global const Waiting = HashTable(64)
global const Waiting = Dict(64)

if !anyp(a->(a=="--worker"), ARGS)
# start in "head node" mode
Expand Down
20 changes: 10 additions & 10 deletions base/inference.jl
Expand Up @@ -60,7 +60,7 @@ isType(t::ANY) = isa(t,AbstractKind) && is((t::AbstractKind).name,Type.name)

isseqtype(t::ANY) = isa(t,AbstractKind) && is((t::AbstractKind).name.name,:...)

const t_func = IdTable()
const t_func = ObjectIdDict()
#t_func[tuple] = (0, Inf, (args...)->limit_tuple_depth(args))
t_func[throw] = (1, 1, x->None)
t_func[boxsi8] = (1, 1, x->Int8)
Expand Down Expand Up @@ -318,7 +318,7 @@ function builtin_tfunction(f::ANY, args::ANY, argtypes::ANY)
if is(f,tuple)
return limit_tuple_depth(argtypes)
end
tf = get(t_func::IdTable, f, false)
tf = get(t_func::ObjectIdDict, f, false)
if is(tf,false)
# struct constructor
if isa(f, CompositeKind)
Expand All @@ -342,7 +342,7 @@ end

type StaticVarInfo
sp::Tuple
cenv::IdTable # types of closed vars
cenv::ObjectIdDict # types of closed vars
end

function a2t(a::AbstractVector)
Expand Down Expand Up @@ -679,7 +679,7 @@ abstract_eval(s::SymbolNode, vtypes, sv::StaticVarInfo) =

abstract_eval(x, vtypes, sv::StaticVarInfo) = abstract_eval_constant(x)

typealias VarTable IdTable
typealias VarTable ObjectIdDict

type StateUpdate
var::Symbol
Expand Down Expand Up @@ -778,12 +778,12 @@ end

function stupdate(state, changes::Union(StateUpdate,VarTable), vars)
if is(state,())
state = IdTable()
state = ObjectIdDict()
end
for i = 1:length(vars)
v = vars[i]
newtype = changes[v]
oldtype = get(state::IdTable,v,NF)
oldtype = get(state::ObjectIdDict,v,NF)
if tchanged(newtype, oldtype)
state[v] = tmerge(oldtype, newtype)
end
Expand Down Expand Up @@ -931,7 +931,7 @@ function typeinf(linfo::LambdaStaticData,atypes::Tuple,sparams::Tuple, def, cop)
# initial set of pc
add(W,1)
# initial types
s[1] = IdTable()
s[1] = ObjectIdDict()
for v in vars
s[1][v] = Undef
end
Expand All @@ -949,7 +949,7 @@ function typeinf(linfo::LambdaStaticData,atypes::Tuple,sparams::Tuple, def, cop)
s[1][args[i]] = atypes[i]
end
# types of closed vars
cenv = IdTable()
cenv = ObjectIdDict()
for vi = ((ast.args[2][3])::Array{Any,1})
vi::Array{Any,1}
vname = vi[1]
Expand Down Expand Up @@ -1108,7 +1108,7 @@ function typeinf(linfo::LambdaStaticData,atypes::Tuple,sparams::Tuple, def, cop)
end

function record_var_type(e::Symbol, t, decls)
otherTy = get(decls::IdTable, e, false)
otherTy = get(decls::ObjectIdDict, e, false)
# keep track of whether a variable is always the same type
if !is(otherTy,false)
if !is(otherTy, t)
Expand Down Expand Up @@ -1175,7 +1175,7 @@ end
# annotate types of all symbols in AST
function type_annotate(ast::Expr, states::Array{Any,1},
sv::ANY, rettype::ANY, vnames::ANY)
decls = IdTable()
decls = ObjectIdDict()
closures = LambdaStaticData[]
body = ast.args[3].args::Array{Any,1}
for i=1:length(body)
Expand Down
4 changes: 2 additions & 2 deletions base/intfuncs.jl
Expand Up @@ -276,7 +276,7 @@ bits(x::Union(Int64,Uint64,Float64)) = bin(reinterpret(Uint64,x), 64)

# TODO: maybe implement a proper Eratosthenes's sieve.

function factor{T<:Integer}(n::T, h::HashTable{T,Int})
function factor{T<:Integer}(n::T, h::Dict{T,Int})
if n <= 0
error("factor: number to be factored must be positive")
end
Expand All @@ -298,4 +298,4 @@ function factor{T<:Integer}(n::T, h::HashTable{T,Int})
h[n] = get(h,n,0)+1
return h
end
factor{T<:Integer}(n::T) = factor(n, HashTable{T,Int}())
factor{T<:Integer}(n::T) = factor(n, Dict{T,Int}())
12 changes: 6 additions & 6 deletions base/multi.jl
Expand Up @@ -179,10 +179,10 @@ type ProcessGroup
np::Int

# global references
refs::HashTable
refs::Dict

function ProcessGroup(myid::Integer, w::Array{Any,1}, locs::Array{Any,1})
return new(myid, w, locs, length(w), HashTable())
return new(myid, w, locs, length(w), Dict())
end
end

Expand All @@ -192,7 +192,7 @@ function add_workers(PGRP::ProcessGroup, w::Array{Any,1})
# NOTE: currently only node 1 can add new nodes, since nobody else
# has the full list of address:port
newlocs = append(PGRP.locs, locs)
sockets = HashTable()
sockets = Dict()
handler = fd->message_handler(fd, sockets)
for i=1:n
push(PGRP.workers, w[i])
Expand Down Expand Up @@ -269,7 +269,7 @@ end

## remote refs and core messages: do, call, fetch, wait, ref, put ##

const _jl_client_refs = WeakKeyHashTable()
const _jl_client_refs = WeakKeyDict()

type RemoteRef
where::Int
Expand Down Expand Up @@ -958,7 +958,7 @@ function start_worker(wrfd)

global const Scheduler = current_task()

worker_sockets = HashTable()
worker_sockets = Dict()
add_fd_handler(sockfd, fd->accept_handler(fd, worker_sockets))

try
Expand Down Expand Up @@ -1554,7 +1554,7 @@ end

yield() = yieldto(Scheduler)

const _jl_fd_handlers = HashTable()
const _jl_fd_handlers = Dict()

add_fd_handler(fd::Int32, H) = (_jl_fd_handlers[fd]=H)
del_fd_handler(fd::Int32) = del(_jl_fd_handlers, fd)
Expand Down
4 changes: 2 additions & 2 deletions base/process.jl
Expand Up @@ -160,7 +160,7 @@ end

type Cmd
exec::Executable
pipes::HashTable{FileDes,PipeEnd}
pipes::Dict{FileDes,PipeEnd}
pipeline::Set{Cmd}
pid::Int32
status::ProcessStatus
Expand All @@ -171,7 +171,7 @@ type Cmd
error("Cmd: too few words to exec")
end
this = new(exec,
HashTable{FileDes,PipeEnd}(),
Dict{FileDes,PipeEnd}(),
Set{Cmd}(),
0,
ProcessNotRun(),
Expand Down
6 changes: 3 additions & 3 deletions base/serialize.jl
Expand Up @@ -5,8 +5,8 @@ abstract LongSymbol
abstract LongTuple
abstract LongExpr

const _jl_ser_tag = IdTable()
const _jl_deser_tag = IdTable()
const _jl_ser_tag = ObjectIdDict()
const _jl_deser_tag = ObjectIdDict()
let i = 2
global _jl_ser_tag, _jl_deser_tag
for t = {Symbol, Int8, Uint8, Int16, Uint16, Int32, Uint32,
Expand Down Expand Up @@ -238,7 +238,7 @@ deserialize_tuple(s, len) = (a = ntuple(len, i->deserialize(s));
deserialize(s, ::Type{Symbol}) = symbol(read(s, Uint8, int32(read(s, Uint8))))
deserialize(s, ::Type{LongSymbol}) = symbol(read(s, Uint8, read(s, Int32)))

const _jl_known_lambda_data = HashTable()
const _jl_known_lambda_data = Dict()

function deserialize(s, ::Type{Function})
b = read(s, Uint8)
Expand Down
6 changes: 3 additions & 3 deletions base/set.jl
@@ -1,8 +1,8 @@
type Set{T}
hash::HashTable{T,Bool}
hash::Dict{T,Bool}

Set() = new(HashTable{T,Bool}())
Set(x...) = add_each(new(HashTable{T,Bool}(length(x))), x)
Set() = new(Dict{T,Bool}())
Set(x...) = add_each(new(Dict{T,Bool}(length(x))), x)
end
Set() = Set{Any}()
Set(x...) = Set{Any}(x...)
Expand Down
28 changes: 14 additions & 14 deletions base/sysimg.jl
Expand Up @@ -98,13 +98,13 @@ include("signal_fftw.jl")

# prime method cache with some things we know we'll need right after startup
length(1:2:3)
(HashTable(0)[1])=()->()
(Dict(0)[1])=()->()
numel(intset())
has(intset(),2)
del_all(FDSet())
start(HashTable(0))
done(HashTable(0),0)
get(HashTable(0), 0, ())
start(Dict(0))
done(Dict(0),0)
get(Dict(0), 0, ())
add(FDSet(),int32(0))
2==2.0
2.0==2.0
Expand All @@ -116,25 +116,25 @@ compile_hint(getcwd, ())
compile_hint(fdio, (Int32,))
compile_hint(ProcessGroup, (Int, Array{Any,1}, Array{Any,1}))
compile_hint(select_read, (FDSet, Float64))
compile_hint(next, (HashTable{Any,Any}, Int))
compile_hint(start, (HashTable{Any,Any},))
compile_hint(next, (Dict{Any,Any}, Int))
compile_hint(start, (Dict{Any,Any},))
compile_hint(perform_work, ())
compile_hint(isempty, (Array{Any,1},))
compile_hint(isempty, (Array{WorkItem,1},))
compile_hint(ref, (HashTable{Any,Any}, Int32))
compile_hint(ref, (Dict{Any,Any}, Int32))
compile_hint(event_loop, (Bool,))
compile_hint(_start, ())
compile_hint(process_options, (Array{Any,1},))
compile_hint(run_repl, ())
compile_hint(anyp, (Function, Array{Any,1}))
compile_hint(HashTable, (Int,))
compile_hint(HashTable{Any,Any}, (Int,))
compile_hint(Dict, (Int,))
compile_hint(Dict{Any,Any}, (Int,))
compile_hint(Set, ())
compile_hint(assign, (HashTable{Any,Any}, Bool, Cmd))
compile_hint(rehash, (HashTable{Any,Any}, Int))
compile_hint(assign, (Dict{Any,Any}, Bool, Cmd))
compile_hint(rehash, (Dict{Any,Any}, Int))
compile_hint(run, (Cmd,))
compile_hint(spawn, (Cmd,))
compile_hint(assign, (HashTable{Any,Any}, Bool, FileDes))
compile_hint(assign, (Dict{Any,Any}, Bool, FileDes))
compile_hint(wait, (Int32,))
compile_hint(system_error, (ASCIIString, Bool))
compile_hint(SystemError, (ASCIIString,))
Expand All @@ -150,7 +150,7 @@ compile_hint(open, (ASCIIString, Bool, Bool, Bool, Bool))
compile_hint(srand, (Uint64,))
compile_hint(done, (IntSet, Int64))
compile_hint(next, (IntSet, Int64))
compile_hint(ht_keyindex, (HashTable{Any,Any}, Int32))
compile_hint(ht_keyindex, (Dict{Any,Any}, Int32))
compile_hint(perform_work, (WorkItem,))
compile_hint(notify_done, (WorkItem,))
compile_hint(work_result, (WorkItem,))
Expand Down Expand Up @@ -197,7 +197,7 @@ compile_hint(_ieval, (Symbol,))
compile_hint(static_convert, (Any, Any))
compile_hint(assign, (Array{Any,1}, WeakRef, Int))
compile_hint(hash, (Tuple,))
compile_hint(assign, (HashTable{Any,Any}, WorkItem, (Int,Int)))
compile_hint(assign, (Dict{Any,Any}, WorkItem, (Int,Int)))
compile_hint(isequal, ((Int,Int),(Int,Int)))
compile_hint(RemoteRef, (Int, Int, Int))
compile_hint(inlining_pass, (LambdaStaticData, Array{Any,1}))
Expand Down

0 comments on commit 9296f4f

Please sign in to comment.