Mercurial > hg > octave-nkf
diff src/jit-ir.cc @ 15056:bc32288f4a42
Support the end keyword for one dimentional indexing in JIT.
* src/jit-ir.cc (jit_magic_end): New class.
* src/jit-ir.h (jit_magic_end): New class.
(jit_instruction::jit_instruction): New overload.
* src/jit-typeinfo.cc (jit_function::call): Throw jit_fail_exception if invalid.
(jit_typeinfo::jit_typeinfo): Initialize end_fn.
* src/jit-typeinfo.h (jit_typeinfo::end): New function.
* src/pt-jit.cc (jit_convert::visit_identifier): Handle magic_end.
(jit_convert::resolve): Keep track of end context.
(jit_convert::convert_llvm::visit): New overload.
* src/pt-jit.h (jit_convert): Add end_context.
author | Max Brister <max@2bass.com> |
---|---|
date | Mon, 30 Jul 2012 13:05:29 -0500 |
parents | 005cb78e1dd1 |
children | df4538e3b50b |
line wrap: on
line diff
--- a/src/jit-ir.cc +++ b/src/jit-ir.cc @@ -598,4 +598,36 @@ return false; } +// -------------------- jit_magic_end -------------------- +const jit_function& +jit_magic_end::overload () const +{ + jit_value *ctx = resolve_context (); + if (ctx) + return jit_typeinfo::end (ctx->type ()); + + static jit_function null_ret; + return null_ret; +} + +jit_value * +jit_magic_end::resolve_context (void) const +{ + // FIXME: We need to have a way of marking functions so we can skip them here + return argument_count () ? argument (0) : 0; +} + +bool +jit_magic_end::infer (void) +{ + jit_type *new_type = overload ().result (); + if (new_type != type ()) + { + stash_type (new_type); + return true; + } + + return false; +} + #endif