[erlang-questions] marco definition in beam_emu.c

Robert Raschke <>
Wed Sep 7 11:25:27 CEST 2011


On Tue, Sep 6, 2011 at 4:50 PM, caox <> wrote:

> Hi
>
> When reading the source code of beam_emu.c, I found the following marcos:
>
> #if defined(NO_JUMP_TABLE)
> #  define OpCase(OpCode)    case op_##OpCode: lb_##OpCode
> #  define CountCase(OpCode) case op_count_##OpCode
> #  define OpCode(OpCode)    ((Uint*)op_##OpCode)
> #  define Goto(Rel) {Go = (int)(Rel); goto emulator_loop;}
> #  define LabelAddr(Addr) &&##Addr
> #else
> #  define OpCase(OpCode)    lb_##OpCode
> #  define CountCase(OpCode) lb_count_##OpCode
> #  define Goto(Rel) goto *(Rel)
> #  define LabelAddr(Label) &&Label
> #  define OpCode(OpCode)  (&&lb_##OpCode)
> #endif
>
> which I couldn't understand. What is the meaning of 'op_##' and 'lb_##'?
>
> BR
>
>
It allows you to glue together a literal piece of text and a passed in
argument of the macro. For example, OpCase(FooBar) becomes case op_FooBar:
lb_FooBar .

Robby
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20110907/655da5b7/attachment.html>


More information about the erlang-questions mailing list