public bool Emit <TDelegate>(CompilerContext <TDelegate> context, Label success)
        {
            var emit         = context.Emit;
            var localSuccess = emit.DefineLabel();
            var end          = emit.DefineLabel();

            bool canFail = rule.Emit(context, localSuccess); // pos

            if (canFail)
            {
                emit.Branch(end); // pos
            }

            emit.MarkLabel(localSuccess);
            // start, pos
            using (var pos = emit.DeclareLocal <int>())
                using (var start = emit.DeclareLocal <int>())
                {
                    emit.StoreLocal(pos);               // start
                    emit.StoreLocal(start);             // ...
                    context.EmitLoadString(pos, start); // v
                    emit.LoadLocal(pos);                // v, pos
                    emit.Branch(success);
                }

            emit.MarkLabel(end);
            return(canFail);
        }
 protected override void EmitLoadSuccess <TDelegate>(CompilerContext <TDelegate> context, Local pos, Local originalPos, string textToMatch)
 {
     if (keepTextToMatch)
     {
         context.Emit.LoadConstant(textToMatch);
     }
     else
     {
         context.EmitLoadString(pos, originalPos);
     }
 }
Exemple #3
0
 protected override void EmitSuccessLogic <TDelegate>(CompilerContext <TDelegate> context, Local pos, Local originalPosition)
 {
     context.EmitLoadString(pos, originalPosition);
 }