Git Product home page Git Product logo

b-tap's Introduction

NAME

B::Tap - Inject tapping node to optree

SYNOPSIS

use B;
use B::Tap;
use B::Tools;

sub foo { 63 }

my $code = sub { foo() + 5900 };
my $cv = B::svref_2object($code);

my ($entersub) = op_grep { $_->name eq 'entersub' } $cv->ROOT;
tap($$entersub, ${$cv->ROOT}, \my @buf);

$code->();

DESCRIPTION

B::Tap is tapping library for B tree. tap function injects custom ops for fetching result of the node.

The implementation works, but it's not beautiful code. I'm newbie about the B world, Patches welcome.

WARNINGS: This module is in a alpha state. Any API will change without notice.

FUNCTIONS

  • tap($op, $root_op, \@buf)

    Tapping the result value of $op. You need pass the $root_op for rewriting tree structure. Tapped result value was stored to \@buf. \@buf must be arrayref.

    B::Tap push the current stack to \@buf. First element for each value is GIMME_V. Second element is the value of stacks.

  • G_SCALAR

  • G_ARRAY

  • G_VOID

    These functions are not exportable by default. If you want to use these functions, specify the import arguments like:

      use B::Tap ':all';
    

    Or

      use B::Tap qw(G_SCALAR G_ARRAY G_VOID);
    

FAQ

  • Why this module required 5.14+?

    Under 5.14, Perl5's custom op support is incomplete. B::Deparse can't deparse the code using custom ops.

    I seem this library without deparsing is useless.

    But if you want to use this with 5.8, it may works.

LICENSE

Copyright (C) tokuhirom.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR

tokuhirom [email protected]

b-tap's People

Contributors

hugmeir avatar tokuhirom avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

hugmeir gugod

b-tap's Issues

'OP' has no member named 'op_sibling'

The module does not compile anymore with perl 5.25.1:

Building B-Tap
cc -I/opt/perl-5.25.1/lib/5.25.1/x86_64-linux/CORE -DVERSION="0.15" -DXS_VERSION="0.15" -fPIC -c -fwrapv -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 -O2 -o lib/B/Tap.o lib/B/Tap.c
lib/B/Tap.xs: In function 'rewrite_op':
lib/B/Tap.xs:153:15: error: 'OP' has no member named 'op_sibling'
lib/B/Tap.xs:154:19: error: 'OP' has no member named 'op_sibling'
lib/B/Tap.xs:155:19: error: 'OP' has no member named 'op_sibling'
lib/B/Tap.xs:157:41: error: 'OP' has no member named 'op_sibling'
lib/B/Tap.xs: In function 'XS_B__Tap__tap':
lib/B/Tap.xs:196:30: error: 'OP' has no member named 'op_sibling'
lib/B/Tap.xs:229:10: error: 'BINOP' has no member named 'op_sibling'
error building lib/B/Tap.o from 'lib/B/Tap.c' at /opt/perl-5.25.1/lib/5.25.1/ExtUtils/CBuilder/Base.pm line 174.

Possibly related discussion:
https://rt.perl.org/rt3/Ticket/Display.html?id=128179

t/02_entersub.t is failed on Ubuntu 12.04 32bit

This test is passed on MacOSX 64bit and Ubuntu 13.04 64bit.

% prove -bv t/02_entersub.t
t/02_entersub.t .. 
ok 1
not ok 2

#   Failed test at t/02_entersub.t line 30.
#     Structures begin differing at:
#          $got->[1][1] = undef
#     $expected->[1][1] = '444'
# B::Concise::compile(CODE(0x8fe97e8))
# u  <1> leavesub[1 ref] K/REFC,1 ->(end)
# -     <@> lineseq KP ->u
#1        <;> nextstate(main -534 02_entersub.t:15) v:U,*,&,x*,x&,x$,$ ->2
# a        <2> sassign vKS/2 ->b
#8           <2> add[t5] sK/2 ->9
#4              <1> entersub[t4] sKS/TARG,2 ->5
# -                 <1> ex-list sK ->4
#2                    <0> pushmark s ->3
# -                    <1> ex-rv2cv sK/2 ->-
#3                       <#> gv[*foo] s ->4
#5              <$> b_tap_push_sv(IV \) l ->6
#9           <0> padsv[$x:-534,-531] sRM*/LVINTRO ->a
# b        <;> nextstate(main -533 02_entersub.t:16) v:U,*,&,x*,x&,x$,$ ->c
# k        <2> sassign vKS/2 ->l
# i           <2> add[t10] sK/2 ->j
# e              <1> entersub[t9] sKS/TARG,2 ->f
# -                 <1> ex-list sK ->e
# c                    <0> pushmark s ->d
# -                    <1> ex-rv2cv sK/2 ->-
# d                       <#> gv[*bar] s ->e
# f              <$> b_tap_push_sv(IV \) l ->g
# j           <0> padsv[$y:-533,-531] sRM*/LVINTRO ->k
# l        <;> nextstate(main -532 02_entersub.t:17) v:U,*,&,{,x*,x&,x$,$ ->m
# t        <2> aassign[t15] KS/COMMON ->u
# -           <1> ex-list lK ->s
# m              <0> pushmark s ->n
# p              <1> entersub[t14] lKS/TARG,2 ->q
# -                 <1> ex-list lK ->p
# n                    <0> pushmark s ->o
# -                    <1> ex-rv2cv sK/2 ->-
# o                       <#> gv[*baz] s ->p
# q              <$> b_tap_push_sv(IV \) l ->r
# -           <1> ex-list lK ->t
# s              <0> padrange[@a:-532,-531] l/LVINTRO,1 ->t
# -              <0> padav[@a:-532,-531] lRM*/LVINTRO ->-
# Looks like you failed 1 test of 2.
1..2
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/2 subtests 

Test Summary Report
-------------------
t/02_entersub.t (Wstat: 256 Tests: 2 Failed: 1)
  Failed test:  2
  Non-zero exit status: 1
Files=1, Tests=2,  0 wallclock secs ( 0.05 usr  0.03 sys +  0.10 cusr  0.03 csys =  0.21 CPU)
Result: FAIL

t/CallTrace/01_simple.t segfaults

On some systems, t/CallTrace/01_simple.t fails with a segmentation fault:

    # $VAR1 = [
    #           [
    #             'expect(\\@p)->to_be([\'a\'])',
    #             '0'
    #           ],
    #           [
    #             'expect(\\@p)',
    #             'bless( {}, \'E\' )'
    #           ]
    #         ];
t/CallTrace/01_simple.t .. 
All 2 subtests passed 

Test Summary Report
-------------------
t/CallTrace/01_simple.t (Wstat: 139 Tests: 2 Failed: 0)
  Non-zero wait status: 139
  Parse errors: No plan found in TAP output

This happens on all of my perl 5.32.0 smokers, but also some other systems.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.