/// <summary> /// Process error table (if specified). We handle catches of Err using /// a catch any (0 class index). We also need to add extra entries into /// the exception table for special exceptions - for example NullErr get's /// mapped as fan.sys.NullErr+Val and java.lang.NullPointerException. /// </summary> private void makeErrTable() { if (fmethod == null) { return; } FBuf ferrs = fmethod.m_attrs.m_errTable; if (ferrs == null) { return; } int len = ferrs.m_len; byte[] buf = ferrs.m_buf; int count = (len - 2) / 8; tryStart = new int[count]; tryEnd = new int[count]; tryJump = new int[count]; tryErr = new int[count]; for (int i = 2, j = 0; i < len; i += 8) { tryStart[j] = (buf[i + 0] & 0xFF) << 8 | (buf[i + 1] & 0xFF); tryEnd[j] = (buf[i + 2] & 0xFF) << 8 | (buf[i + 3] & 0xFF); tryJump[j] = (buf[i + 4] & 0xFF) << 8 | (buf[i + 5] & 0xFF); tryErr[j] = (buf[i + 6] & 0xFF) << 8 | (buf[i + 7] & 0xFF); j++; } }
/// <summary> /// Read out the line numbers and stick them in a hashmap. /// </summary> private void makeLineNumbers() { // source file string srcFile = parent.type.m_attrs.m_sourceFile; if (srcFile != null) { code.DefaultSourceFile = SourceFile.GetSourceFile( srcFile, // source file System.Guid.Empty, // lang System.Guid.Empty, // vend System.Guid.Empty); // docu } // line numbers if (fmethod == null) { return; } FBuf flines = fmethod.m_attrs.m_lineNums; if (flines != null) { int len = flines.m_len; byte[] buf = flines.m_buf; for (int i = 2; i < len; i += 4) { int pc = (buf[i] & 0xFF) << 8 | (buf[i + 1] & 0xFF); int line = (buf[i + 2] & 0xFF) << 8 | (buf[i + 3] & 0xFF); lineNums[pc] = line; } } }
public FCodeEmit(FTypeEmit parent, FBuf fcode, CILInstructions code, Reg[] regs, FTypeRef ret) { this.pod = parent.pod; this.emitter = parent.emitter; this.parent = parent; this.buf = fcode.m_buf; this.len = fcode.m_len; this.code = code; this.podClass = FanUtil.toDotnetTypeName(pod.m_podName, "$Pod", false); this.jumps = new Jumps(code); this.regs = regs; this.ret = ret; }