forked from JuliaLang/julia
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/JuliaLang/julia
- Loading branch information
Showing
28 changed files
with
2,029 additions
and
110 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# deep copying | ||
deepcopy(x) = _deepcopy(x, ObjectIdDict()) | ||
|
||
_deepcopy(x::Union(Symbol,Function,LambdaStaticData, | ||
TopNode,QuoteNode,BitsKind,CompositeKind,AbstractKind, | ||
UnionKind), stackdict::ObjectIdDict) = x | ||
_deepcopy(x::Tuple, stackdict::ObjectIdDict) = | ||
ntuple(length(x), i->_deepcopy(x[i], stackdict)) | ||
_deepcopy(x::Module, stackdict::ObjectIdDict) = error("deepcopy of Modules not supported") | ||
|
||
function _deepcopy(x, stackdict::ObjectIdDict) | ||
if has(stackdict, x) | ||
return stackdict[x] | ||
end | ||
_deepcopy_t(x, typeof(x), stackdict) | ||
end | ||
|
||
_deepcopy_t(x, T::BitsKind, stackdict::ObjectIdDict) = x | ||
function _deepcopy_t(x, T::CompositeKind, stackdict::ObjectIdDict) | ||
nf = length(T.names) | ||
|
||
ret = ccall(:jl_new_struct_uninit, Any, (Any,), T) | ||
stackdict[x] = ret | ||
for i=1:nf | ||
try | ||
ccall(:jl_set_nth_field, Any, (Any, Int, Any), | ||
ret, i-1, _deepcopy(x.(T.names[i]), stackdict)) | ||
catch err | ||
# we ignore undefined references errors | ||
if !isa(err, UndefRefError) | ||
throw(err) | ||
end | ||
end | ||
end | ||
return ret | ||
end | ||
_deepcopy_t(x, T, stackdict::ObjectIdDict) = | ||
error("deepcopy of objects of type ", T, " not supported") | ||
|
||
|
||
function _deepcopy(x::Array, stackdict::ObjectIdDict) | ||
if has(stackdict, x) | ||
return stackdict[x] | ||
end | ||
_deepcopy_array_t(x, eltype(x), stackdict) | ||
end | ||
|
||
_deepcopy_array_t(x, T::BitsKind, stackdict::ObjectIdDict) = copy(x) | ||
function _deepcopy_array_t(x, T, stackdict::ObjectIdDict) | ||
dest = similar(x) | ||
stackdict[x] = dest | ||
i0 = 1; local i | ||
while true | ||
try | ||
for i=i0:length(x) | ||
# NOTE: this works around the performance problem caused by all | ||
# the doubled definitions of assign() | ||
arrayset(dest, i, _deepcopy(x[i], stackdict)) | ||
end | ||
break | ||
catch err | ||
# we ignore undefined references errors | ||
if !isa(err, UndefRefError) | ||
throw(err) | ||
end | ||
i0 = i+1 | ||
end | ||
end | ||
return dest | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -897,6 +897,7 @@ export | |
|
||
# object identity and equality | ||
copy, | ||
deepcopy, | ||
isequal, | ||
isless, | ||
identity, | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include <stdlib.h> | ||
#include <tcl.h> | ||
#include "julia.h" | ||
|
||
int jl_tcl_callback(ClientData clientData, Tcl_Interp *interp, | ||
int argc, char *argv[]) | ||
{ | ||
jl_function_t *f = (jl_function_t*)clientData; | ||
jl_value_t **jlargs = alloca(argc * sizeof(void*)); | ||
memset(jlargs, 0, argc * sizeof(void*)); | ||
JL_GC_PUSHARGS(jlargs, argc); | ||
int i; | ||
for(i=0; i < argc; i++) { | ||
jlargs[i] = jl_cstr_to_string(argv[i]); | ||
} | ||
jl_value_t *result = NULL; | ||
JL_TRY { | ||
result = jl_apply(f, jlargs, argc); | ||
} | ||
JL_CATCH { | ||
JL_GC_POP(); | ||
return TCL_ERROR; | ||
} | ||
Tcl_SetResult(interp, jl_string_data(result), TCL_VOLATILE); | ||
JL_GC_POP(); | ||
return TCL_OK; | ||
} |
Oops, something went wrong.