public void Emit(ILEmitter context) { switch (IoType) { case IoType.Arg: context.Generator.EmitLdarg(Index); break; case IoType.Fields: { long intInputs = context.LocalAlloc.GetIntInputs(context.GetIlBlock(Index)); long vecInputs = context.LocalAlloc.GetVecInputs(context.GetIlBlock(Index)); LoadLocals(context, intInputs, RegisterType.Int); LoadLocals(context, vecInputs, RegisterType.Vector); break; } case IoType.Flag: EmitLdloc(context, Index, RegisterType.Flag); break; case IoType.Int: EmitLdloc(context, Index, RegisterType.Int); break; case IoType.Vector: EmitLdloc(context, Index, RegisterType.Vector); break; } }
public bool AdvanceOpCode() { if (_opcIndex + 1 == CurrBlock.OpCodes.Count && _blkIndex + 1 == _graph.Length) { return(false); } while (++_opcIndex >= (CurrBlock?.OpCodes.Count ?? 0)) { _blkIndex++; _opcIndex = -1; _optOpLastFlagSet = null; _optOpLastCompare = null; _ilBlock = _emitter.GetIlBlock(_blkIndex); } return(true); }
public ILEmitterCtx( TranslatorCache cache, Block[] graph, Block root, string subName) { _cache = cache ?? throw new ArgumentNullException(nameof(cache)); _graph = graph ?? throw new ArgumentNullException(nameof(graph)); _root = root ?? throw new ArgumentNullException(nameof(root)); _labels = new Dictionary <long, ILLabel>(); _emitter = new ILEmitter(graph, root, subName); _ilBlock = _emitter.GetIlBlock(0); _opcIndex = -1; if (graph.Length == 0 || !AdvanceOpCode()) { throw new ArgumentException(nameof(graph)); } }