public void EmitDataWithConv(string name, object value, MemberSpec v, bool constant = false, bool verbatim = false, bool isglobal = false) { DataMember dm; if (value is string) { if (constant) { dm = new DataMember(name, value.ToString(), true, verbatim) { IsGlobal = isglobal } } ; else { dm = new DataMember(name, value.ToString(), false, verbatim) { IsGlobal = isglobal } }; } else if (value is float) { dm = new DataMember(name, BitConverter.GetBytes((float)value)) { IsGlobal = isglobal } } ; else if (value is byte[]) { dm = new DataMember(name, (byte[])value) { IsGlobal = isglobal } } ; else if (value is bool) { dm = new DataMember(name, ((bool)value) ? (new byte[1] { EmitContext.TRUE }) : (new byte[1] { 0 })) { IsGlobal = isglobal } } ; else if (value is byte) { dm = new DataMember(name, new byte[1] { (byte)value }) { IsGlobal = isglobal } } ; else if (value is ushort) { dm = new DataMember(name, new ushort[1] { (ushort)value }) { IsGlobal = isglobal } } ; else { dm = new DataMember(name, new object[1] { value }) { IsGlobal = isglobal } }; EmitData(dm, v, constant); } EmitContext() { _names = new List <string>(); }
public void EmitCall(EmitContext ec, List <Expression> exp, MemberSpec method, CallingConventions ccv, bool will_return) { EmitLongReturnRoutine(ec, will_return); int size = 0; if (ccv == CallingConventions.Pascal || ccv == CallingConventions.Default) { foreach (Expression e in exp) { e.EmitToStack(ec); } } else if (ccv == CallingConventions.StdCall || ccv == CallingConventions.Cdecl) { for (int i = exp.Count - 1; i >= 0; i--) { exp[i].EmitToStack(ec); size += GetParameterSize(false); } } else if (ccv == CallingConventions.FastCall) { for (int i = exp.Count - 1; i >= 0; i--) { exp[i].EmitToStack(ec); size += GetParameterSize(false); } if (exp.Count >= 2) { ec.EmitPop(EmitContext.C); ec.EmitPop(EmitContext.D); } else if (exp.Count == 1) { ec.EmitPop(EmitContext.C); } } // call method.EmitToStack(ec); ec.EmitPop(RegistersEnum.AX); ec.EmitInstruction(new Call() { DestinationReg = RegistersEnum.AX }); if (ccv == CallingConventions.Cdecl && size > 0) { ec.EmitInstruction(new Add() { DestinationReg = EmitContext.SP, SourceValue = (ushort)size, Size = 80 }); } if (!will_return) { EmitNoReturnPop(ec); } }