Skip to content

Commit

Permalink
Make for loops, while loops, and return w/o arg return Nothing.
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanKarpinski committed Jun 11, 2011
1 parent a002a01 commit 20e911d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ void jl_add_constructors(jl_struct_type_t *t)
}
jl_function_t *fnew=NULL;
JL_GC_PUSH(&fnew);
if (t->ctor_factory == (jl_value_t*)jl_null) {
if (t->ctor_factory == (jl_value_t*)jl_nothing) {
// no user-defined constructors
if (t->parameters->length>0 && (jl_value_t*)t==t->name->primary) {
jl_function_t *tf = (jl_function_t*)t;
Expand Down
24 changes: 12 additions & 12 deletions src/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,14 +613,14 @@ JL_CALLABLE(jl_f_print_array_uint8)
ios_t *s = jl_current_output_stream();
jl_array_t *b = (jl_array_t*)args[0];
ios_write(s, (char*)b->data, b->length);
return (jl_value_t*)jl_null;
return (jl_value_t*)jl_nothing;
}

JL_CALLABLE(jl_f_print_symbol)
{
ios_t *s = jl_current_output_stream();
ios_puts(((jl_sym_t*)args[0])->name, s);
return (jl_value_t*)jl_null;
return (jl_value_t*)jl_nothing;
}

// --- showing ---
Expand Down Expand Up @@ -788,7 +788,7 @@ JL_CALLABLE(jl_f_show_bool)
ios_puts("false", s);
else
ios_puts("true", s);
return (jl_value_t*)jl_null;
return (jl_value_t*)jl_nothing;
}

JL_CALLABLE(jl_f_show_char)
Expand All @@ -798,26 +798,26 @@ JL_CALLABLE(jl_f_show_char)
ios_putc('\'', s);
ios_pututf8(s, wc);
ios_putc('\'', s);
return (jl_value_t*)jl_null;
return (jl_value_t*)jl_nothing;
}

JL_CALLABLE(jl_f_show_float32)
{
show_float64((double)*(float*)jl_bits_data(args[0]), 1);
return (jl_value_t*)jl_null;
return (jl_value_t*)jl_nothing;
}

JL_CALLABLE(jl_f_show_float64)
{
show_float64(*(double*)jl_bits_data(args[0]), 0);
return (jl_value_t*)jl_null;
return (jl_value_t*)jl_nothing;
}

#define INT_SHOW_FUNC(sgn,nb) \
JL_CALLABLE(jl_f_show_##sgn##nb) \
{ \
show_##sgn(jl_bits_data(args[0]), nb); \
return (jl_value_t*)jl_null; \
return (jl_value_t*)jl_nothing; \
}

INT_SHOW_FUNC(int,8)
Expand All @@ -842,7 +842,7 @@ JL_CALLABLE(jl_f_show_pointer)
#else
ios_printf(s, " @0x%08x", (uptrint_t)ptr);
#endif
return (jl_value_t*)jl_null;
return (jl_value_t*)jl_nothing;
}

JL_CALLABLE(jl_f_show_typevar)
Expand All @@ -858,7 +858,7 @@ JL_CALLABLE(jl_f_show_typevar)
ios_puts("<:", s);
jl_show((jl_value_t*)tv->ub);
}
return (jl_value_t*)jl_null;
return (jl_value_t*)jl_nothing;
}

JL_CALLABLE(jl_f_show_linfo)
Expand All @@ -867,7 +867,7 @@ JL_CALLABLE(jl_f_show_linfo)
ios_puts("AST(", s);
jl_show(((jl_lambda_info_t*)args[0])->ast);
ios_putc(')', s);
return (jl_value_t*)jl_null;
return (jl_value_t*)jl_nothing;
}

JL_CALLABLE(jl_f_show_any)
Expand Down Expand Up @@ -911,7 +911,7 @@ JL_CALLABLE(jl_f_show_any)
ios_putc(')', s);
}
}
return (jl_value_t*)jl_null;
return (jl_value_t*)jl_nothing;
}

// --- RTS primitives ---
Expand Down Expand Up @@ -989,7 +989,7 @@ JL_CALLABLE(jl_f_new_struct_type)
JL_TYPECHK(new_struct_type, symbol, args[0]);
JL_TYPECHK(new_struct_type, tuple, args[1]);
JL_TYPECHK(new_struct_type, tuple, args[2]);
if (args[3] != (jl_value_t*)jl_null)
if (args[3] != (jl_value_t*)jl_nothing)
JL_TYPECHK(new_struct_type, function, args[3]);
jl_sym_t *name = (jl_sym_t*)args[0];
jl_tuple_t *params = (jl_tuple_t*)args[1];
Expand Down
2 changes: 1 addition & 1 deletion src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,7 @@ static Value *emit_expr(jl_value_t *expr, jl_codectx_t *ctx, bool value)
return literal_pointer_val(jv);
}
else if (ex->head == null_sym) {
return literal_pointer_val((jl_value_t*)jl_null);
return literal_pointer_val((jl_value_t*)jl_nothing); // jl_nothing
}
else if (ex->head == static_typeof_sym) {
jl_value_t *extype = expr_type((jl_value_t*)ex);
Expand Down
4 changes: 2 additions & 2 deletions src/interpreter.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ static jl_value_t *eval(jl_value_t *e, jl_value_t **locals, size_t nl)
else if (ex->head == assign_sym) {
jl_value_t *sym = args[0];
size_t i;
for(i=0; i < nl; i++) {
for (i=0; i < nl; i++) {
if (locals[i*2] == sym) {
locals[i*2+1] = eval(args[1], locals, nl);
return (jl_value_t*)jl_null;
Expand All @@ -105,7 +105,7 @@ static jl_value_t *eval(jl_value_t *e, jl_value_t **locals, size_t nl)
return args[0];
}
else if (ex->head == null_sym) {
return (jl_value_t*)jl_null;
return (jl_value_t*)jl_nothing; // jl_nothing
}
else if (ex->head == body_sym) {
return eval_body(ex->args, locals, nl, 0);
Expand Down
3 changes: 2 additions & 1 deletion src/jltypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1294,7 +1294,7 @@ static jl_type_t *inst_type_w_(jl_value_t *t, jl_value_t **env, size_t n,
nst->ctor_factory = st->ctor_factory;
nst->instance = NULL;
nst->uid = 0;
nst->types = jl_null;
nst->types = jl_null; // duplicate assignment?
nst->super = (jl_tag_type_t*)inst_type_w_((jl_value_t*)st->super, env,n,stack);
jl_tuple_t *ftypes = st->types;
if (ftypes != NULL) {
Expand Down Expand Up @@ -1943,6 +1943,7 @@ void jl_init_types()

jl_null = (jl_tuple_t*)newobj((jl_type_t*)jl_tuple_type, 1);
jl_null->length = 0;
jl_nothing = (jl_struct_type_t*)jl_null; // for bootstrapping

// initialize them. lots of cycles.
jl_struct_kind->name = jl_new_typename(jl_symbol("StructKind"));
Expand Down

0 comments on commit 20e911d

Please sign in to comment.