protected static ArgumentBuilder CreateArgumentBuilder(Type type, ParameterInfo parameterInfo, ParserEntryData flatEntryData) { var parserEntry = flatEntryData.ParserEntry; return(parserEntry switch { IParserPredicate parserPredicateEntry => CreatePredicateArgumentBuilder(type, parserPredicateEntry), ParserSetMatchEntry parserSetMatchEntry => CreateLexerArgumentBuilder(type, null, parserSetMatchEntry), ParserSingleMatchEntry parserSingleMatchEntry => CreateLexerArgumentBuilder(type, null, parserSingleMatchEntry), ParserStateEntry parserStateEntry => CreateParserArgumentBuilder(type), _ => throw new ArgumentOutOfRangeException(nameof(parserEntry)) });
protected override void BuildInvoke(ILBuilderContext ilBuilderContext, MatchEntry matchEntry, bool main) { if (main == false) { return; } var parserEntry = matchEntry switch { ParserSingleMatchEntry s => s.ParserEntryData, ParserSetMatchEntry s => s.ParserEntryData, _ => throw new ArgumentOutOfRangeException() }; if (parserEntry.FlatIndex == -1) { return; } var parserProduction = parserEntry.ParserProduction; if (parserProduction == null) { return; } if (parserProduction.IsInline) { return; } var entryBuilder = parserProduction.Binder.Template[parserEntry.FlatIndex]; if (entryBuilder == null) { return; } if (!(entryBuilder is LexerArgumentBuilder lexerArgumentBuilder)) { throw new InvalidOperationException(); } ilBuilderContext.EmitLdContext(); ilBuilderContext.IL.Emit(OpCodes.Call, PeekStateEntryMethodInfo); ilBuilderContext.IL.Emit(OpCodes.Ldfld, ProductionInstanceBuilderArgumentsFieldInfo); ilBuilderContext.IL.Emit(OpCodes.Ldc_I4, parserEntry.FlatIndex); ilBuilderContext.IL.Emit(OpCodes.Ldelem_Ref); lexerArgumentBuilder.EmitConsumeValue(this, ilBuilderContext); if (parserProduction.Binder.TryReturn) { ilBuilderContext.EmitLdContext(); ilBuilderContext.IL.Emit(OpCodes.Ldc_I4, parserEntry.FlatIndex); ilBuilderContext.IL.Emit(OpCodes.Call, OnAfterConsumeValueMethodInfo); } //ilBuilderContext.EmitLdContext(); //ilBuilderContext.IL.Emit(OpCodes.Ldc_I4, parserStateEntry.FlatIndex); //ilBuilderContext.IL.Emit(OpCodes.Call, ConsumeLexerEntryMethodInfo); }