コード例 #1
0
        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.EmitLoadStringSpan(pos, start); // v
                    emit.LoadLocal(pos);                    // v, pos
                    emit.Branch(success);
                }

            emit.MarkLabel(end);
            return(canFail);
        }
コード例 #2
0
 protected override void EmitSuccessObjectLogic <TDelegate>(CompilerContext <TDelegate> context, Local pos)
 {
     context.EmitLoadStringSpan(pos);
 }
コード例 #3
0
 protected override void EmitLoadSuccess <TDelegate>(CompilerContext <TDelegate> context, Local pos, Local originalPos)
 {
     context.EmitLoadStringSpan(pos, originalPos);
 }