
7XK(                 @   s  d  d l  m Z m Z m Z m Z d  d l  m Z d  d l m Z m Z d d l Z d d l	 Z	 Gd d   d e j
  Z Gd d	   d	 e j
  Z Gd
 d   d e j
  Z Gd d   d e j
  Z Gd d   d e j
  Z Gd d   d e j
  Z d Z d  Z Gd d   d e j  Z d S)   )interpreterbasemlogmparsermesonlib)environment)InterpreterExceptionInvalidArguments    Nc               @   s   e  Z d  Z d S)DontCareObjectN)__name__
__module____qualname__ r   r   U/mnt/raid6/a/bak/reczko/tools/protein/utils/meson-0.42.1/mesonbuild/astinterpreter.pyr
      s   r
   c               @   s   e  Z d  Z d S)MockExecutableN)r   r   r   r   r   r   r   r      s   r   c               @   s   e  Z d  Z d S)MockStaticLibraryN)r   r   r   r   r   r   r   r      s   r   c               @   s   e  Z d  Z d S)MockSharedLibraryN)r   r   r   r   r   r   r   r   "   s   r   c               @   s   e  Z d  Z d S)MockCustomTargetN)r   r   r   r   r   r   r   r   %   s   r   c               @   s   e  Z d  Z d S)MockRunTargetN)r   r   r   r   r   r   r   r   (   s   r   c                   s*  e  Z d  Z   f d d   Z d d   Z d d   Z d d   Z d	 d
   Z d d   Z d d   Z	 d d   Z
 d d   Z d d   Z d d   Z d d   Z d d   Z d d   Z d d   Z d d    Z d! d"   Z d# d$   Z d% d&   Z d' d(   Z d) d*   Z d+ d,   Z d- d.   Z   S)/AstInterpreterc                s  t    j | |  i  |  _ |  j j i) |  j d 6|  j d 6|  j d 6|  j d 6|  j d 6|  j d 6|  j d 6|  j d 6|  j d	 6|  j d
 6|  j d 6|  j d 6|  j d 6|  j d 6|  j d 6|  j d 6|  j d 6|  j d 6|  j d 6|  j d 6|  j d 6|  j d 6|  j d 6|  j d 6|  j d 6|  j d 6|  j d 6|  j d 6|  j d 6|  j d 6|  j d 6|  j d  6|  j	 d! 6|  j
 d" 6|  j d# 6|  j d$ 6|  j d% 6|  j d& 6|  j d' 6|  j d( 6|  j d) 6 d  S)*Nprojecttest	benchmarkinstall_headersinstall_maninstall_datainstall_subdirconfiguration_dataconfigure_filefind_programinclude_directoriesadd_global_argumentsadd_global_link_argumentsadd_project_argumentsadd_project_link_argumentsmessage	generatorerrorrun_commandassert
subproject
dependency
get_option
join_pathsr   importvcs_tagadd_languagesdeclare_dependencyfiles
executablestatic_libraryshared_librarylibrarybuild_targetcustom_target
run_targetsubdirset_variableget_variableis_variable)super__init__astsfuncsupdatefunc_do_nothing
func_filesfunc_executablefunc_static_libfunc_shared_libfunc_libraryfunc_build_targetfunc_custom_targetfunc_run_targetfunc_subdirfunc_set_variablefunc_get_variablefunc_is_variable)selfsource_rootr:   )	__class__r   r   r?   /   sV    	






































zAstInterpreter.__init__c             C   s   d S)NTr   )rP   nodeargskwargsr   r   r   rC   ]   s    zAstInterpreter.func_do_nothingc             C   s   d S)NTr   )rP   rS   r   r   r   method_call`   s    zAstInterpreter.method_callc             C   ss   | d |  j  k rl |  j t k r8 |  j | | |  ql |  j t k r] |  j | | |  ql t d   n  t   S)Nr	   zBleep bloop)
targetname	operation
ADD_SOURCEadd_source_to_targetREMOVE_SOURCEremove_source_from_targetNotImplementedErrorr   )rP   rS   rT   rU   r   r   r   rE   c   s    zAstInterpreter.func_executablec             C   s   t    S)N)r   )rP   rS   rT   rU   r   r   r   rF   m   s    zAstInterpreter.func_static_libc             C   s   t    S)N)r   )rP   rS   rT   rU   r   r   r   rG   p   s    zAstInterpreter.func_shared_libc             C   s   |  j  | | |  S)N)rG   )rP   rS   rT   rU   r   r   r   rH   s   s    zAstInterpreter.func_libraryc             C   s   t    S)N)r   )rP   rS   rT   rU   r   r   r   rJ   v   s    z!AstInterpreter.func_custom_targetc             C   s   t    S)N)r   )rP   rS   rT   rU   r   r   r   rK   y   s    zAstInterpreter.func_run_targetc             C   sH  |  j  } t j j | | d  } | |  _  t j j |  j  t j  } t j j |  j |  } t j j |  s | |  _  t d |   n  t	 | d d  } | j
   }	 Wd  QXt |	 t  s t  y, t j |	 |  j   j   }
 |
 |  j | <Wn7 t j k
 r-} z | | _ |  WYd  d  } ~ Xn X|  j |
  | |  _  d  S)Nr	   zNonexistent build def file %s.encodingutf8)r:   ospathjoinr   build_filenamerQ   isfiler   openread
isinstancestrAssertionErrorr   Parserparser@   r   MesonExceptionfileevaluate_codeblock)rP   rS   rT   rU   prev_subdirr:   buildfilenameabsnamefcode	codeblockmer   r   r   rL   |   s&    				zAstInterpreter.func_subdirc             C   s   t  | t  s | g S| S)N)rg   list)rP   rS   rT   rU   r   r   r   rD      s    zAstInterpreter.func_filesc             C   s   d S)Nr	   r   )rP   curr   r   r   evaluate_arithmeticstatement   s    z+AstInterpreter.evaluate_arithmeticstatementc             C   s   d S)Nr	   r   )rP   rS   r   r   r   evaluate_plusassign   s    z"AstInterpreter.evaluate_plusassignc             C   s   d S)Nr	   r   )rP   rS   r   r   r   evaluate_indexing   s    z AstInterpreter.evaluate_indexingc             C   sC   t  | t j  s t  | j   r3 t d   n  | j | j f S)Nz9All keyword arguments must be after positional arguments.)rg   r   ArgumentNoderi   incorrect_orderr   	argumentsrU   )rP   rT   r   r   r   reduce_arguments   s    zAstInterpreter.reduce_argumentsc             C   s<   |  j    |  j |  j d <|  j   |  j   |  j   d  S)N )load_root_meson_fileastr@   sanity_check_astparse_projectrun)rP   r   r   r   	transform   s
    


zAstInterpreter.transformc             C   s)   t  |  _ | |  _ | |  _ |  j   d  S)N)rY   rX   rW   filenamer   )rP   rW   r   r   r   r   
add_source   s    			zAstInterpreter.add_sourcec             C   s)   t  |  _ | |  _ | |  _ |  j   d  S)N)r[   rX   rW   r   r   )rP   rW   r   r   r   r   remove_source   s    			zAstInterpreter.remove_sourcec             C   s   t  j d |  d  S)NzUnknown function called: )r   warning)rP   	func_namer   r   r   unknown_function_called   s    z&AstInterpreter.unknown_function_calledc             C   s   | j  j d j } t j j |  j |  j t j	  } t
 | d  j   } | d | d  d |  j | | d d   } t
 | d  j |  t j d  d  S)Nr	   rr   z, '%s'w)rT   r}   bytespanr`   ra   rb   rQ   r:   r   rc   re   rf   r   writesysexit)rP   rS   rT   rU   namespanrp   raw_dataupdatedr   r   r   rZ      s    !1z#AstInterpreter.add_source_to_targetc       	      C   s<  t  | t j  s t  | j | j } | t | j  k rJ | d 8} n  | d k  r_ d } n | j | j } | d | d k  r | | } } n  t j	 j
 |  j | j t j  } t | d  j   } | d | d  | | d d   } | d | d  | | d d   } t | d  j |  t j d  d  S)Nr   r	   r   r   )r	   r	   )rg   r   r{   ri   r}   r   lencommasr`   ra   rb   rQ   r:   r   rc   re   rf   r   r   r   )	rP   rT   ir   Z	commaspanrp   r   Zintermediaryr   r   r   r   remove_argument_item   s    	!&&z#AstInterpreter.remove_argument_itemc             C   s   x |  j  | j j D] } | j | j k r t | t j  r | j } t | t j  sh t	 d   n  | j
 } xe t t | j   D]K } t | j | t j  r |  j | j | j k r |  j | |  q q Wn  t	 d   q q Wd  S)NzNot supported yet, bro.ZSukkess)r@   r:   lineslinenorg   r   AssignmentNodevalue	ArrayNoder]   rT   ranger   r}   
StringNoder   r   )rP   Znode_to_removeavrT   r   r   r   r   hacky_find_and_remove   s    		2z$AstInterpreter.hacky_find_and_removec             C   s1  xt  d t | j   D] } t | j j | t j  rm |  j | j j | j k rm |  j	 | j |  n  t | j j | t j
  r |  j | j j | j  } t | t  s t d   n  xE | D]: } t | t j  r | j |  j k r |  j |  q q Wq q Wt j d |  j | d f  d  S)Nr   z$Non-arrays not supported yet, sorry.z&Could not find source %s in target %s.r	   )r   r   rT   rg   r}   r   r   r   r   r   IdNoder<   rv   r]   r   r   r   )rP   rS   rT   rU   r   Zavarentryr   r   r   r\      s    8$z(AstInterpreter.remove_source_from_target)r   r   r   r?   rC   rV   rE   rF   rG   rH   rJ   rK   rL   rD   rx   ry   rz   r~   r   r   r   r   rZ   r   r   r\   r   r   )rR   r   r   .   s.   .
r   )r   r   r   r   r   r   r   r   r`   r   InterpreterObjectr
   r   r   r   r   r   rY   r[   InterpreterBaser   r   r   r   r   <module>   s   "