NL idZddlmZddlmZmZddlmZddlm Z m Z m Z m Z ddl mZmZmZmZmZmZddlmZmZddlmZdd lmZmZdd lmZdd Z dd Zdd Z ddZ!y)zGenerate a class that represents a nested function. The class defines __call__ for calling the function and allows access to non-local variables defined in outer scopes. ) annotations) ENV_ATTR_NAME SELF_NAME)ClassIR)FuncDeclFuncIR FuncSignature RuntimeArg) BasicBlockCallRegisterReturnSetAttrValue) RInstanceobject_rprimitive) IRBuilder)FuncInfo ImplicitClass) method_new_opc"|jjdx}}d}||jvr%|dzt|z}|dz }||jvr%|jj |t ||j dd}d|_|jjrd|_ |jdjr3t|jdj|jt<|g|_t#||j_|j&j)||j+|}|j-||jj.j0|jj$_y) aGenerate an (incomplete) callable class representing a function. This can be a nested function or a function within a non-extension class. Also set up the 'self' variable for that class. This takes the most recently visited function and returns a ClassIR to represent that function. Each callable class contains an environment attribute which points to another ClassIR representing the environment class where some of its variables can be accessed. Note that some methods, such as '__call__', are not yet created here. Use additional functions, such as add_call_to_callable_class(), to add them. Return a newly constructed ClassIR representing the callable class for the nested function. _objr_T) is_generatedis_final_classN)fn_infonamespaced_namecallable_class_namesstraddr module_namereuse_freed_instance is_nestedhas_dictfn_infoscontains_nestedr env_class attributesrmrorcallable_classclassesappendadd_self_to_envreadfitemlineself_reg)buildername base_namecountcallable_class_ir self_targets b/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/mypyc/irbuild/callable_class.pysetup_callable_classr;sa:"//99;(>(A(A(F(FH[H[]`aLdFGMM$6$6w}}GYGYJ5?G%%j19EG**:6 r<c |jj}|j|jjdt |t 5|j dt }|j dt tt}}|j|j||jd|}|j||||j||jt|j|j||jt|j!t"|j|j|g|dddy#1swYyxYw)z3Generate the '__get__' method for a callable class.__get__) self_typeinstanceownerisN)r1r2 enter_methodr,rDr add_argumentr translate_is_opr0 none_objectadd_bool_branchactivate_blockr"rselfcall_cr)r4rr2rPinstance_block class_block comparisons r:add_get_to_callable_classr^ms1 ==  D   !!#   '' 4EFW&78 '1lJL ,, LL "G$7$7$94   KH{+ F7<<>*+~. 7>>-',,.',,xBX1Y[_` a /   s DE//E8c8|j}|jt|jjj g|j }d}|jjr!|jjj}nc|jjr!|jjj}n,|jjr|jj}|r+|jt|t||j |S)a,Create an instance of a callable class for a function. Calls to the function will actually call this instance. Note that fn_info refers to the function being assigned, whereas builder.fn_info refers to the function encapsulating the function being turned into a callable class. N)r1r"r r,rDctorr2r is_generatorgenerator_class curr_env_regr%r(rr)r4rr1func_regrcs r:instantiate_callable_classres MME{{4 6 6 9 9 > >EJJOPHL##66CC  " "55BB  ( (33  GHm\5::NO Or<N)r4rreturnNone) r4rrAzlist[Register]rGzlist[BasicBlock]rHr rrrfr)r4rrrrfrg)r4rrrrfr)"__doc__ __future__r mypyc.commonrrmypyc.ir.class_irrmypyc.ir.func_irrrr r mypyc.ir.opsr r r rrrmypyc.ir.rtypesrrmypyc.irbuild.builderrmypyc.irbuild.contextrrmypyc.primitives.misc_opsrr;rLr^rer<r:rss{ #1%HHKK8+93<d~         6 >"r<