public static Func <IExtractContext, string[]> ApplyFalse( ICodeInformation operand, string oper, DecodeContext decodeContext) { var si = decodeContext.PopStack(); var labelName = decodeContext.EnqueueNewPath(operand.Offset); if (si.TargetType.IsBooleanType) { return(extractContext => new[] { string.Format( "if ({0} {1} false) goto {2}", extractContext.GetSymbolName(si), oper, labelName) }); } else if (si.TargetType.IsNumericPrimitive || si.TargetType.IsEnum) { return(extractContext => new[] { string.Format( "if ({0} {1} 0) goto {2}", extractContext.GetSymbolName(si), oper, labelName) }); } else { return(extractContext => new[] { string.Format( "if ({0} {1} NULL) goto {2}", extractContext.GetSymbolName(si), oper, labelName) }); } }
public override ExpressionEmitter Prepare( ICodeInformation operand, DecodeContext decodeContext) { var labelName = decodeContext.EnqueueNewPath(operand.Offset); return((_, __) => new[] { string.Format("goto {0}", labelName) }); }
public override Func <IExtractContext, string[]> Apply( ICodeInformation operand, DecodeContext decodeContext) { var labelName = decodeContext.EnqueueNewPath(operand.Offset); return(_ => new[] { string.Format("goto {0}", labelName) }); }
public override Func <IExtractContext, string[]> Apply( ICodeInformation operand, DecodeContext decodeContext) { var si = decodeContext.PopStack(); var labelName = decodeContext.EnqueueNewPath(operand.Offset); if (si.TargetType.IsBooleanType) { return(extractContext => new[] { string.Format( "if (!({0})) goto {1}", extractContext.GetSymbolName(si), labelName) }); } else if (si.TargetType.IsNumericPrimitive) { return(extractContext => new[] { string.Format( "if ({0} == 0) goto {1}", extractContext.GetSymbolName(si), labelName) }); } else { return(extractContext => new[] { string.Format( "if ({0} == NULL) goto {1}", extractContext.GetSymbolName(si), labelName) }); } }
public override Func <IExtractContext, string[]> Apply( Instruction operand, DecodeContext decodeContext) { var si1 = decodeContext.PopStack(); var si0 = decodeContext.PopStack(); var labelName = decodeContext.EnqueueNewPath(operand.Offset); return(_ => new[] { string.Format( "if ({0} != {1}) goto {2}", si0.SymbolName, si1.SymbolName, labelName) }); }
public override Func <IExtractContext, string[]> Apply( ICodeInformation operand, DecodeContext decodeContext) { var si1 = decodeContext.PopStack(); var si0 = decodeContext.PopStack(); var labelName = decodeContext.EnqueueNewPath(operand.Offset); return(extractContext => new[] { string.Format( "if ({0} != {1}) goto {2}", extractContext.GetSymbolName(si0), extractContext.GetSymbolName(si1), labelName) }); }
public static ExpressionEmitter ApplyBinary( ICodeInformation operand, string oper, DecodeContext decodeContext) { var si1 = decodeContext.PopStack(); var si0 = decodeContext.PopStack(); var labelName = decodeContext.EnqueueNewPath(operand.Offset); return((extractContext, _) => new[] { string.Format( "if ({0} {1} {2}) goto {3}", extractContext.GetSymbolName(si0), oper, extractContext.GetSymbolName(si1), labelName) }); }
public override Func <IExtractContext, string[]> Apply( Instruction operand, DecodeContext decodeContext) { var si = decodeContext.PopStack(); var labelName = decodeContext.EnqueueNewPath(operand.Offset); if (si.TargetType.IsNumericPrimitive()) { return(_ => new[] { string.Format( "if ({0} != 0) goto {1}", si.SymbolName, labelName) }); } else { return(_ => new[] { string.Format( "if ({0} != NULL) goto {1}", si.SymbolName, labelName) }); } }
public override Func <IExtractContext, string[]> Apply( ICodeInformation operand, DecodeContext decodeContext) { // Strategy: // The exception handlers have to use "leave" opcode to exit. // It will be transition to finally block if declared. // AND, continue to operand label (therefore it delayed evaluation.) // The AssemblyWriter will write these fragments by labelName side-by-side declared continuationIndex. decodeContext.EnqueueNewPath(operand.Offset); var continuationIndex = decodeContext.RegisterLeaveContinuation( decodeContext.CurrentCode.Offset, operand.Offset); return(extractContext => { var nestedIndexName = extractContext.GetExceptionNestedFrameIndexName(); return new[] { string.Format( "il2c_leave({0}, {1})", nestedIndexName, continuationIndex) }; }); }