[fpc-devel] Adding procedures using nodes

Ryan Joseph ryan at thealchemistguild.com
Thu Aug 2 22:41:43 CEST 2018


So the way FreeInstance is called by adding it within a destructor isn’t exactly what I needed because it requires a destructor actually be present in the class.

The next thing I’d like to try is adding a procedure dynamically using nodes. I’ve seen how if statements are made doing things like:

                        addstatement(newstatement,cifnode.create(
                            caddnode.create(andn,
                                caddnode.create(unequaln,
                                    load_self_pointer_node,
                                    cnilnode.create),
                                caddnode.create(unequaln,
                                    ctypeconvnode.create(
                                        load_vmt_pointer_node,
                                        voidpointertype),
                                    cpointerconstnode.create(0,voidpointertype))),
                            ccallnode.create(nil,tprocsym(srsym),srsym.owner,load_self_node,[],nil),
                            nil));

but are there any examples of creating a procedural with nodes someone could point me to? I’d like to do something like:

procedure DoSomething(param);
begin
end;

so I could call the procedure with a parameter and have a block node (I think begin/end is a block node) so I could add some statements inside that. I’m having fun learning how the compiler works but it’s pretty complicated without any guidance.

Thanks.

Regards,
	Ryan Joseph




More information about the fpc-devel mailing list