Annotation of parser3/src/types/pa_junction.h, revision 1.15

1.2       paf         1: /** @file
                      2:        Parser: Junction class decl.
                      3: 
1.15    ! moko        4:        Copyright (c) 2001-2020 Art. Lebedev Studio (http://www.artlebedev.com)
1.2       paf         5:        Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
                      6: */
                      7: 
                      8: #ifndef PA_JUNCTION_H
                      9: #define PA_JUNCTION_H
                     10: 
1.15    ! moko       11: #define IDENT_PA_JUNCTION_H "$Id: pa_junction.h,v 1.14 2017/02/07 22:00:46 moko Exp $"
1.2       paf        12: 
                     13: 
                     14: #include "pa_string.h"
                     15: #include "pa_array.h"
                     16: #include "pa_exception.h"
                     17: #include "pa_operation.h"
                     18: #include "pa_value.h"
                     19: 
                     20: /** \b junction is some code joined with context of it's evaluation.
                     21: 
                     22:        there are code-junctions and method-junctions
                     23:        - code-junctions are used when some parameter passed in cury brackets
                     24:        - method-junctions used in ^method[] calls or $method references
                     25: 
                     26:        Junctions register themselves in method_frame [if any] for consequent invalidation.
                     27:        This prevents evaluation of junctions in outdated context
                     28: 
                     29:        To stop situations like this:
                     30: @code
                     31:        @main[]
                     32:        ^method1[]
                     33:        ^method2[]
                     34: 
                     35:        @method1[]
                     36:        $junction{
                     37:                some code
                     38:        }
                     39: 
                     40:        @method2[]
                     41:        ^junction[]
                     42: @endcode
                     43: 
                     44:        On wcontext[most dynamic context of all] scope exit (WContext::~WContext()) got cleaned - 
                     45:        Junction::wcontext becomes WContext.fparent (if any), 
                     46:        or Junction::method_frame becomes 0 (if no parent), which later in Request::process triggers exception
                     47: 
                     48:        parent changing helps ^switch implementation to remain simple
                     49: */
1.6       paf        50: class Junction {
1.2       paf        51: public:
                     52: 
1.5       paf        53:        /// Code-Junction constructor
                     54:        Junction(Value& aself,
1.2       paf        55:                const Method* amethod,
                     56:                VMethodFrame* amethod_frame,
                     57:                Value* arcontext,
                     58:                WContext* awcontext,
1.9       misha      59:                ArrayOperation* acode
                     60:        ): self(aself),
                     61:                method(amethod),
                     62:                method_frame(amethod_frame),
                     63:                rcontext(arcontext),
                     64:                wcontext(awcontext),
                     65:                code(acode)
                     66:                {}
1.2       paf        67: 
1.5       paf        68:        /// Method-Junction or Getter-Junction constructor
                     69:        Junction(Value& aself,
                     70:                const Method* amethod,
1.8       misha      71:                bool ais_getter=false,
                     72:                String* aauto_name=0
                     73:        ): self(aself),
1.5       paf        74:                method(amethod),
1.13      moko       75:                auto_name(aauto_name),
                     76:                is_getter(ais_getter)
1.8       misha      77:                {}
1.5       paf        78: 
                     79: 
1.2       paf        80:        void reattach(WContext *new_wcontext);
                     81: 
                     82:        /// always present
                     83:        Value& self;
                     84:        //@{
                     85:        /// @name either these // so called 'method-junction'
                     86:        const Method* method;
                     87:        //@}
                     88:        //@{
                     89:        /// @name or these are present // so called 'code-junction'
                     90:        VMethodFrame* method_frame;
                     91:        Value* rcontext;
                     92:        WContext* wcontext;
                     93:        ArrayOperation* code;
1.5       paf        94:        //@}
                     95:        //@{
1.9       misha      96:        String* auto_name;
1.2       paf        97:        //@}
1.8       misha      98:        //@{
1.9       misha      99:        bool is_getter;
1.8       misha     100:        //@{
1.2       paf       101: };
                    102: 
                    103: #endif

E-mail: