public void Emit(NativeEmitContext nec, Report ec, bool isfirst = false) { if (Resolve(ec)) { if (!isfirst) { nec.EmitInLine(", " + NativeTypeBridge.GenerateParameter(CType, ParameterName)); } else { nec.EmitInLine(NativeTypeBridge.GenerateParameter(CType, ParameterName)); } } }
public void Emit(NativeEmitContext nec, Report ec) { nec.EmitInLine(NativeBridge.GenerateMethodHeader(MethodName)); byte i = 0; foreach (AsmParameter param in Parameters) { param.Emit(nec, ec, i == 0); i++; } nec.EmitInLine(")"); nec.EmitCode("{"); string inop = "", outop = ""; // IO Operands foreach (Operand ninst in InputOperands) { inop += ", " + NativeBridge.AssignRegister(ninst.Reg, ninst.Parameter.ParameterName, OutputVars, OverrideVars); } foreach (Operand ninst in OutputOperands) { outop += ", " + NativeBridge.GetRegister(ninst.Reg, ninst.Parameter.ParameterName, OutputVars, OverrideVars); } // Remove , if (!string.IsNullOrEmpty(inop)) { inop = inop.Remove(0, 1); } if (!string.IsNullOrEmpty(outop)) { outop = outop.Remove(0, 1); } // Normalize Asm Code StringBuilder sb = new StringBuilder(); AsmCode = AsmCode.Trim().Replace("\r\n", ""); foreach (string inst in AsmCode.Split(';')) { if (!string.IsNullOrEmpty(inst)) { sb.AppendLine("\"" + inst.Trim() + ";\""); } } StartLine = nec.CurrentLine; nec.EmitCode(""); nec.EmitInLine("asm("); nec.EmitInLine(sb.ToString()); nec.EmitInLine(" "); // only input if (!string.IsNullOrEmpty(inop) && string.IsNullOrEmpty(outop)) { nec.EmitInLine(": :" + inop); } else if (string.IsNullOrEmpty(inop) && !string.IsNullOrEmpty(outop)) // only output { nec.EmitInLine(": " + outop); } else if (!string.IsNullOrEmpty(inop) && !string.IsNullOrEmpty(outop)) // both { nec.EmitInLine(": " + outop + " :" + inop); } nec.EmitInLine(");"); nec.EmitCode(""); EndLine = nec.CurrentLine; nec.EmitCode("}"); nec.EmitCode(" "); }