Skip to content

Commit

Permalink
error on out-of-range sparams to fix compile=all
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Feb 23, 2016
1 parent f5c8254 commit 1269902
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ jl_sym_t *copyast_sym; jl_sym_t *fastmath_sym;
jl_sym_t *pure_sym; jl_sym_t *simdloop_sym;
jl_sym_t *meta_sym;
jl_sym_t *inert_sym; jl_sym_t *vararg_sym;
jl_sym_t *unused_sym;
jl_sym_t *unused_sym; jl_sym_t *static_parameter_sym;

typedef struct {
int64_t a;
Expand Down
2 changes: 1 addition & 1 deletion src/cgutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1471,7 +1471,7 @@ static jl_value_t *expr_type(jl_value_t *e, jl_codectx_t *ctx)
return typ;
}
if (jl_is_expr(e)) {
if (((jl_expr_t*)e)->head == jl_symbol("static_parameter")) {
if (((jl_expr_t*)e)->head == static_parameter_sym) {
size_t idx = jl_unbox_long(jl_exprarg(e,0))-1;
if (idx >= jl_svec_len(ctx->linfo->sparam_vals))
return (jl_value_t*)jl_any_type;
Expand Down
2 changes: 1 addition & 1 deletion src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3369,7 +3369,7 @@ static jl_cgval_t emit_expr(jl_value_t *expr, jl_codectx_t *ctx)
emit_assignment(args[0], args[1], ctx);
return ghostValue(jl_void_type);
}
else if (head == jl_symbol("static_parameter")) {
else if (head == static_parameter_sym) {
return emit_sparam(jl_unbox_long(args[0])-1, ctx);
}
else if (head == method_sym) {
Expand Down
7 changes: 5 additions & 2 deletions src/interpreter.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,12 @@ static jl_value_t *eval(jl_value_t *e, jl_value_t **locals, jl_lambda_info_t *la
else if (ex->head == body_sym) {
return eval_body(ex->args, locals, lam, 0, 0);
}
else if (ex->head == jl_symbol("static_parameter")) { // TODO
else if (ex->head == static_parameter_sym) {
ssize_t n = jl_unbox_long(args[0]);
assert(n <= jl_svec_len(lam->sparam_vals) && n > 0);
assert(n > 0);
// static parameter val unknown needs to be an error for ccall
if (n > jl_svec_len(lam->sparam_vals))
jl_error("could not determine static parameter value");
return jl_svecref(lam->sparam_vals, n-1);
}
else if (ex->head == exc_sym) {
Expand Down
1 change: 1 addition & 0 deletions src/jltypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -3625,6 +3625,7 @@ void jl_init_types(void)
list_sym = jl_symbol("list");
unused_sym = jl_symbol("#unused#");
slot_sym = jl_symbol("slot");
static_parameter_sym = jl_symbol("static_parameter");
}

#ifdef __cplusplus
Expand Down
2 changes: 1 addition & 1 deletion src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ extern jl_sym_t *boundscheck_sym; extern jl_sym_t *inbounds_sym;
extern jl_sym_t *copyast_sym; extern jl_sym_t *fastmath_sym;
extern jl_sym_t *pure_sym; extern jl_sym_t *simdloop_sym;
extern jl_sym_t *meta_sym; extern jl_sym_t *list_sym;
extern jl_sym_t *inert_sym;
extern jl_sym_t *inert_sym; extern jl_sym_t *static_parameter_sym;

// gc -------------------------------------------------------------------------

Expand Down

0 comments on commit 1269902

Please sign in to comment.