void(entity) kill = #4;
$frame stand1 stand2 standX
-
+/*
.float frame;
.float nextthink;
.void() think;
void() stand2;
void() stand1 = [ 0, stand2 ] {
- /* expands to:
- self.frame = 0;
- self.nextthink = time + 0.1;
- self.think = stand2
- */
+ // expands to:
+ //self.frame = 0;
+ //self.nextthink = time + 0.1;
+ //self.think = stand2
print("In stand 1...\n");
print3("--> self.frame should be 0, is ", ftos(self.frame), "\n");
};
print3("--> self.frame should be 1, is ", ftos(self.frame), "\n");
};
+void() standm = {
+ print3("Foo ", ftos(self), "\n");
+ self.frame = 0;
+ self.nextthink = time + 0.1;
+ self.think = stand2;
+};
+
void() main = {
self = spawn();
self.think = stand1;
print("Running think\n");
+ standm();
+ print("Running from 'self'\n");
self.think();
self.think();
self.think();
};
+*/
+
+entity self;
+
+.float frame;
+.float nextthink;
+
+void(float a, float b) foo = {};
+
+void() main = {
+ self = spawn();
+ self.frame = 1;
+ self.nextthink = 2;
+ print2(ftos(self.frame), "\n");
+ print2(ftos(self.nextthink), "\n");
+ foo(self.frame, self.nextthink);
+ kill(self);
+};
+
in = ir_instr_new(self, INSTR_CALL0);
if (!in)
return NULL;
- out = ir_value_out(self->owner, label, store_return, func->outtype);
+ out = ir_value_out(self->owner, label, store_value, func->outtype);
if (!out) {
ir_instr_delete(in);
return NULL;
function_allocator alloc;
- if (!self->locals_count)
+ if (!self->locals_count && !self->values_count)
return true;
MEM_VECTOR_INIT(&alloc, locals);
self->allocated_locals = pos + alloc.sizes[alloc.sizes_count-1];
/* Take over the actual slot positions */
- for (i = 0; i < self->values_count; ++i)
+ for (i = 0; i < self->values_count; ++i) {
self->values[i]->code.local = alloc.positions[self->values[i]->code.local];
+ }
goto cleanup;
#endif
}
+ /* call params are read operands too */
+ for (p = 0; p < instr->params_count; ++p)
+ {
+ value = instr->params[p];
+#if ! defined(LIFE_RANGE_WITHOUT_LAST_READ)
+ if (!ir_block_living_find(self, value, NULL) &&
+ !ir_block_living_add(self, value))
+ {
+ goto on_error;
+ }
+#else
+ if (!new_reads_t_v_find(&new_reads, value, NULL))
+ {
+ if (!new_reads_t_v_add(&new_reads, value))
+ goto on_error;
+ }
+#endif
+ }
+
/* See which operands are read and write operands */
ir_op_read_write(instr->opcode, &read, &write);
ir_value *v = irfun->values[i];
ir_value_code_setaddr(v, local_var_end + v->code.local);
}
- for (i = 0; i < irfun->locals_count; ++i) {
+ for (i = 0; i < irfun->allocated_locals; ++i) {
/* fill the locals with zeros */
code_globals_add(0);
}