internal void emitStaticInit(FMethod m)
{
// make sure we add local defs
if (m != null && m.m_localCount > 0)
{
PERWAPI.Local[] locals = new PERWAPI.Local[m.m_vars.Length];
for (int i=0; i<locals.Length; i++)
{
string name = m.m_vars[i].name;
string type = nname(m.m_vars[i].type);
locals[i] = new PERWAPI.Local(name, emitter.findType(type));
}
cctor.AddLocals(locals, true);
}
hasStaticInit = true;
PERWAPI.CILInstructions code = cctor.CreateCodeBuffer();
// set $Type field with type (if we this is a closure,
// then the FuncType will be the type exposed)
if (!parent.isMixin())
{
Type t = parent;
if (parent.@base() is FuncType) t = parent.@base();
code.ldstr(t.signature());
PERWAPI.Method findType = emitter.findMethod("Fan.Sys.Type", "find",
new string[] { "System.String" }, "Fan.Sys.Type");
code.MethInst(PERWAPI.MethodOp.call, findType);
code.FieldInst(PERWAPI.FieldOp.stsfld, typeField);
}
if (m == null)
code.Inst(PERWAPI.Op.ret);
else
new FCodeEmit(this, m, code).emit();
}