public void method(FMethod m) { Write(" " + typeRef(m.m_ret) + " " + m.m_name + "("); FMethodVar[] pars = m.pars(); for (int i = 0; i < pars.Length; ++i) { FMethodVar p = pars[i]; if (i > 0) { Write(", "); } Write(typeRef(p.type) + " " + p.name); } WriteLine(") [" + StrUtil.flagsToString(m.m_flags).Trim() + "]"); for (int i = 0; i < m.m_vars.Length; i++) { FMethodVar v = m.m_vars[i]; string role = v.IsParam() ? "Param" : "Local"; int reg = i + ((m.m_flags & FConst.Static) != 0 ? 0 : 1); WriteLine(" [" + role + " " + reg + "] " + v.name + ": " + typeRef(v.type)); if (v.def != null) { code(v.def); } } if (m.m_code != null) { WriteLine(" [Code]"); code(m.m_code); } attrs(m.m_attrs); WriteLine(); }
public FMethod read(FStore.Input input) { base.readCommon(input); m_ret = input.u2(); m_inheritedRet = input.u2(); m_maxStack = input.u1(); m_paramCount = input.u1(); m_localCount = input.u1(); m_vars = new FMethodVar[m_paramCount+m_localCount]; for (int i=0; i<m_vars.Length; i++) m_vars[i] = new FMethodVar().read(input); m_code = FBuf.read(input); base.readAttrs(input); return this; }
public FMethod read(FStore.Input input) { base.readCommon(input); m_ret = input.u2(); m_inheritedRet = input.u2(); m_maxStack = input.u1(); m_paramCount = input.u1(); m_localCount = input.u1(); m_vars = new FMethodVar[m_paramCount + m_localCount]; for (int i = 0; i < m_vars.Length; i++) { m_vars[i] = new FMethodVar().read(input); } m_code = FBuf.read(input); base.readAttrs(input); return(this); }
public FMethodVar[] pars() { FMethodVar[] temp = new FMethodVar[m_paramCount]; Array.Copy(m_vars, temp, m_paramCount); return(temp); }
/// <summary> /// Map to .NET register info for the given Fantom local variables. /// </summary> internal static Reg[] initRegs(FPod pod, bool isStatic, FMethodVar[] vars) { Reg[] regs = new Reg[isStatic ? vars.Length : vars.Length+1]; int nindex = 0; for (int i=0; i<regs.Length; ++i) { Reg r = new Reg(); if (i == 0 && !isStatic) { // this pointer r.stackType = FTypeRef.OBJ; r.nindex = nindex; ++nindex; } else { FTypeRef typeRef = pod.typeRef(vars[isStatic ? i : i - 1].type); r.stackType = typeRef.stackType; r.nindex = nindex; nindex += 1; //nindex += typeRef.isWide() ? 2 : 1; } regs[i] = r; } return regs; }
public FMethodVar[] pars() { FMethodVar[] temp = new FMethodVar[m_paramCount]; Array.Copy(m_vars, temp, m_paramCount); return temp; }