Added spec:commit task to commit changes to spec/ruby sources.
[rbx.git] / shotgun / lib / methctx.h
blob89fd237ee5c00bf3146b2c26d8addc14407ba98d
1 #ifndef RBS_METHCTX_H
2 #define RBS_METHCTX_H
4 OBJECT blokctx_s_under_context(STATE, OBJECT ctx);
5 OBJECT blokenv_s_under_context2(STATE, OBJECT cmethod, OBJECT ctx, OBJECT ctx_block);
6 void blokenv_call(STATE, cpu c, OBJECT self, int num_args);
8 OBJECT methctx_dup(STATE, OBJECT self);
9 OBJECT methctx_dup_chain(STATE, OBJECT ctx, OBJECT *also);
11 #define context_p(st, ctx) (ctx->obj_type == MContextType || ctx->obj_type == BContextType)
12 #define block_context_p(state, ctx) (FASTCTX(ctx)->type == FASTCTX_BLOCK)
14 #define methctx_is_fast_p(st, ctx) (ctx->obj_type == MContextType)
16 #define blokctx_home(state, obj) (blokenv_get_home(FASTCTX(obj)->name))
17 #define blokctx_env(state, self) (FASTCTX(self)->name)
18 #define blokctx_locals(state, self) (FASTCTX(self)->locals)
20 void methctx_reference(STATE, OBJECT ctx);
23 #if 0
24 static inline void methctx_reference(STATE, OBJECT ctx) {
25 struct fast_context *fc;
26 /* Don't do it again. */
27 if(!stack_context_p(ctx)) return;
29 /* Has to be done first because this uses informated we're about
30 to overwrite. */
31 object_memory_context_referenced(state->om, ctx);
33 CLEAR_FLAGS(ctx);
34 ctx->gc_zone = YoungObjectZone;
35 switch(FASTCTX(ctx)->type) {
36 case FASTCTX_NORMAL:
37 ctx->klass = BASIC_CLASS(fastctx);
38 ctx->obj_type = MContextType;
39 ctx->CTXFast = TRUE;
40 break;
41 case FASTCTX_BLOCK:
42 ctx->klass = BASIC_CLASS(blokctx);
43 ctx->obj_type = BContextType;
44 break;
45 case FASTCTX_NMC:
46 ctx->klass = BASIC_CLASS(nmc);
47 ctx->obj_type = MContextType;
48 break;
50 SET_NUM_FIELDS(ctx, FASTCTX_FIELDS);
51 ctx->StoresBytes = TRUE;
52 ctx->ForeverYoung = TRUE;
54 fc = FASTCTX(ctx);
56 /* Fixup the locals tuple. */
57 if(!NIL_P(fc->locals)) {
58 CLEAR_FLAGS(fc->locals);
59 fc->locals->gc_zone = YoungObjectZone;
60 fc->locals->klass = BASIC_CLASS(tuple);
64 #endif
66 #endif