All Downloads are FREE. Search and download functionalities are using the official Maven repository.

Lib.Krakatau.java.javamethod.pyc Maven / Gradle / Ivy

There is a newer version: 1.1
Show newest version
?
?HRc@sfddlZddlZddlmZddlmZddlmZddlm	Z	m
Z
ddlmZdd	lm
Z
mZmZdd
lmZmZmZdefd??YZd
?Zd?Zd?Zd?Zd?Zedg?Zd?Zd?Zd?Zd?Z d?Z!d?Z"d?Z#idd6dd6dd6dd6dd 6d!d"6Z$d#?e$j%?D?Z&d$?e$j%?D?Z'd%?Z(d&?Z)d'?Z*d(?Z+d)?Z,d*?Z-e
j.e
j/e
j0e
j1e
j2e
j3e
j4fZ5d+?Z6d,?Z7d-?Z8d.?Z9d/?Z:d0?Z;d1?Z<ej=?ee>d2?Z?d3?Z@d4?ZAdS(5i????N(tpartiali(tobjtypes(t
graph_util(tNameGentLabelGen(tparseMethodDescriptori(tasttast2tboolize(t
graphproxytstructuringtastgentDeclInfocBseZdj?Zd?ZRS(sdeclScope scope defscCsd|_|_g|_dS(N(tNonet	declScopetscopetdefs(tself((s?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pyt__init__s(t__name__t
__module__tsplitt	__slots__R(((s?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pyR
scs0tj????fd???fd?}x|D]}|||?q4W||fg}x?|r+|j?\}?t?tj?r?|j?fd??jD??q]|jd??j?D???j	dk	r??|?j	?nt?tj?r]x*?jD]\}}|||j
?qWq]q]W?S(Ncs?x|jD]}?||?q
W|j?rS|j\}}?|jj|?nTt|tjtjf?r??j|t	??tj
j?|j|??|_ndS(N(
tparamst
isLocalAssignRtappendt
isinstanceRtLocaltLiteralt
setdefaultRtStatementBlocktjoinR(Rtexprtparamtlefttright(tinfotvisit(s?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pyR%scsI?j|t??|dk	r2?|jdks8t?|?|_dS(N(RRR
RtAssertionError(RR (R$(s?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pyt
visitDeclExpr!s%c3s|]}?|fVqdS(N((t.0tsub(tstmt(s?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pys	-scss|]}||fVqdS(N((R(tsubscope((s?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pys	/s(tcollectionstOrderedDicttpopRRRtextendt
statementst	getScopesR R
tTryStatementtpairstlocal(troottpredeclaredR'R tstackRt	catchdecltbody((R$R*R%s?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pytfindVarDeclInfos"
	#cCs|jtjkst?t|tj?r?dj?}tjtj	f}|j
|kr?||j|j
?dA}|j\}}|j
|d ks?|j|kr?|j|kr?tj|||ftj?Sq?n,t|tj
?r?|j
dkr?|jdStj
d|?S(Ns== != < >= > <=iit!i(tdtypeRtBoolTTR&RRtBinaryInfixRtFloatTTtDoubleTTtopstrtindexRtUnaryPrefix(R tsymbolstfloattstsym2R"R#((s?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pytreverseBoolExpr8s1"!ccsc|g}xS|r^|j?}t|tj?rH|j|j?|Vq|j|j??qWdS(N(R.RRRR/R0R1(R5R7R((s?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pytgetSubscopeIterGs		cCsZd|kst?xAt|?D]3}|j|kr|jsAtS|jd}|j?s|t|tj	tj
f?sOtSqRt|tj?r?t|j??dkr?tSt|tj
?r?|j?r?tSt|tj?r?|jtjjkr?tSt|tj?sRxB|j?D]1}|j|jko=|jknst?qWqRqqWtS(Ni????i(R
R&RHtjumpKeyR0tTrueR1RRtReturnStatementtThrowStatementtIfStatementtlentSwitchStatementt
hasDefaulttWhileStatementR RtTRUEtbreakKeytFalse(R5t	forbiddenRtlastR)((s?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pyt
mayBreakToQs&	
*'9csd?kst??fd?}|j?r?t|tj?r|||j?dkr|||j?dks||js|t?n||j?|_t|tj?r?||j?|_xE|j	D]}t
|??q?Wq?x$|j?D]}t
|??q?WndS(Ncs?j||?S(N(tget(tk(treplace(s?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pytrs(R
R&R1RRRRSRIt	labelableR0treplaceKeys(ttopRZRXtitemR((RZs?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pyR]ps'(cCs?g}xxt|j?D]g\}}x!|j?D]}t||?q/W|||?}|dkrj|gn|}|j|?qW||_dS(N(t	enumerateR0R1t	_preorderR
R/(RtfunctnewitemstiR_R)tvaltvals((s?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pyRa?scCs?|j}t|tj?rL|j\}}t|tj?r?|jr?gSnut|tj?r?|jdkr?|jd}tj	tj
|j?|jd|jd?}tj||?|_ndS(s9Combines new/invokeinit pairs into Java constructor callssiiN(
R RRt
AssignmentRtDummytisNewtMethodInvocationtnametClassInstanceCreationtTypeNameR<ttts(RR_R R"R#tnewexpr((s?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pyt_fixObjectCreations?s	!
/cCs?x?|jr?|jd\}}|j|j}}t|?dkr?|d}t|tj?r?|j|kr?|jd |_qq?nPqW|js?|j}|j	|j	ks?t
?|j|jks?t
?|js?t
?t
|_|S|S(s+Convert try{A} catch(T e) {throw t;} to {A}i????ii(R3R4R0RNRRRLR ttrybRSR&tcontinueKeyR\RJ(R_tdeclR9tcaughttlinestlinetnew((s?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pyt_pruneRethrow_cb?s"
!				c
Cs?t|j?dkr?|j\}}|jrk|j?rkt|j?|_||}}||f|_n|jr?|j?r?|f|_q?t|jtj?r?|jj	dkr?t|j?|_||f|_q?n|jd}t|j?dkr?t|j?dkr?|j?r?|jd}t|tj
?r?t|j?dkr?tjd|j|jgtj
?|_|j|_q?n|S(s&Convert if(A) {B} else {} to if(A) {B}iR;is&&(RNtscopesR0tdoesFallthroughRGR RRRCRARMR>RR=(R_ttblocktfblocktfirst((s?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pyt_pruneIfElse_cb?s$
'
6
''c
s?g|f}|j?d}|js@t|jdtj?rD|S|jd}|j}|j?dd \}}t|j|j	g?t
}t||?r?|dk	r?t||?r?t|?}||}}q?|Snt||?s?t
?|jo
|j|jk}|r0|jtjjkr0|St|jg?t
?|s?|dk	ra|gng}	|	|jd7}	|j|jks?t?fd?|	D??r?|Snttjd|jt|?g??|_|dkr?|jjd?n||jd?ss&&N(N(R1R0RRRMR R
t	frozensetRSRrtNONE_SETRWRGR&RIRRRtanyt_simplifyExpressionsR>R.RJR\RzR](
R_tfailureR9theadtcondttruebtfalsebt	badjumps1ttrivialtrestloop((R?s?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pyt_whileCondition_cb?sL$
	.*
		'c
Cs?g}t|tj?r't|?}nHt|tj?rHt|?}n't|tj?rot|?\}}nt|tj?r?|j	dk	s?|jdks?t?|j	}|dks?||j	kr?|j
r?||jg}|_nxb|jD]V}|j?r4|j	|kr4t|t|g??r4Pn|j|jjd??q?W|js?|j|kr?|sut?|j|_|j	dk	s?|jdks?t?n|Sn||gS(Ni(RRR2RxRMR~RQR?RRSR
RIR&R\R0R1RWR?RR.(RR_tisLasttresttbkeyR)((s?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pyt_simplifyBlocksSubs.$	$3	'cCs?g}x?t|j?D]?}|}|rg|j?rg|j|jkrgt|i|j|j6?qgnx$t|j??D]}t|?qzWt|||?}|t|?7}qW|ddd?|_dS(Ni????(treversedR0R1RSRIR]t_simplifyBlocksR?(RRcR_R?R)Rf((s?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pyR?)s s==i
s!=tis>=cCsi|]\}}||?qS(((R(RYtv((s?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pys
9s	cCs#i|]\}}||d@?qS(i((R(RYR?((s?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pys
:s	cCs t|tj?r?|jdkrWtd?|jD??r?t|jt|j?fSq|jdkrt|jd?\}}t|jd
?\}}||kr?d|jkr?||@n||B}||fSqnEt|tj	?r|jdkrt|jd?\}}||fSdS(Ns==s!=R?s<=R?s>=css*|] }t|tjtjf?VqdS(N(RRRR(R(tp((s?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pys	Ast&s&&t|s||iiR;(s==s!=R?s<=R?s>=(R?s&&R?s||(iN(RRR>RAtallRt_op2bitsttuplet_getBitfieldRCR
(R tbits1targs1tbits2targs2tbitstargs((s?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pyR?<s#!cCs#t|?\}}|dkr"|St|d?rDt|d?sJt?|djtjtjfkrydt}}n
dt	}}||M}||@}|dkr?t
jjS|dkr?t
jj
S||kr?t
j|||tj?S||krt
jdt
j|||tj??S|S(NiiiiR;(R?R
thasSideEffectsR&R<RR?R@t_bit2ops_floatt_bit2opsRRRRtFALSER>R=RC(R R?R?tmasktdtnotbits((s?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pyt_mergeComparisonsNs$(



&cCstjjtjj}}i|t6|t6}itjd6tjd6tj	d6tj
d6}t}t||j
?|_
t|tj?r?|j
\}}|j}|dkr?t|tj?r?t|tj?r5|dkr?||k|dkk}	n1|j|jkst?|||j|j?}	||	}q?t|tj?r?t|j
dtj?r?|tj||j
d|g|j??|j
d<|tj||j
d|g|j??|j
d<|}q?q?nt|tj?r?|jtjkr?|j
\}
}}t|tj?s8t|
?||}
}}n||kretjd	|
|gtj?}q?||kr?tjd
t|
?|gtj?}q?nt|tj?r?|jdkr?|j
\}}|jd
kr,||ks?||krt|?r|}q{||ks ||kr{|}q{nO||ksD||krM|}n.||ksr||kr{t|?r{|}nt|?}nt|tj?r@|jdkr@|j
djtjkr@|j
\}}t|tj?s?||}}nt|tj?r@||k|jdkk}
|
r4t|?n|}q@nt|tj?r?t|j
dtj?r?|j
\}
}}|
jd
kr?t|
?||g|_
q?nt|tj?r|jdkr|j
dtjjkrtjd|j
d?}qn|S(NR?s<=R?s>=s==s!=iis||s&&s==, !=iR;t-(s==s!=R?s<=R?s>=(s==s!=(s&&s||(RRRRR?RJRTtoperatortlttletgttgeR?tmapRRR>RAR<R&RetTernaryt_dtypeRR=RGR?R?RCtLZERO(R RRR?tboolstopfuncstsimplifyR"R#toptresR?tval1tval2tflip((s?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pyR?gsl.	
+22$!*!%		%	:+!cCsLxE|jD]:}x1|j?D]#}|j|f|_t|?qWq
WdS(N(R0R1tbasest_setScopeParents(RR_R)((s?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pyR??scCs?|jdk	r'|jj|?|_nt|jtj?ryt|tj?sTt?|jj\}}||krygSn|gS(N(	R R
treplaceSubExprsRRRgtExpressionStatementR&R(RR_trdictR"R#((s?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pyt_replaceExpressions?scs?t|?t||??g?D]}t|tj?r |^q }t??x^|D]V}td??|jD??s??j|?qT?|j	dk	rT?j|?qTqTWtj|??fd??}i}x?|D]?}?j
|?r,g}xF|D]>}x5?|jD]&}	|	|kr|j||	?qqWq?Wtt|??dkr,|d?t?fd?|D??r)tjj?fd?|D??}
tjj|
??j	?}
??j	dks???j	|
kr&x|D]}?||?scs|?krgS?|jS(N(R(tvar(RUR$(s?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pyR[?siic3s!|]}|j?jkVqdS(N(R<(R(R?(ttarget(s?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pys	?sc3s|]}?|jVqdS(N(R(R(R?(R$(s?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pys	?sR?(R?R:RRRtsetR?RtaddRR
Rt	tarjanSCCt
isdisjointRRNRRRRaRR?(R5R6R tlvarsR?tsccstvarmaptscctalldefstdef_R((RUR$R?s?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pyt_mergeVariables?sB
+	



"&
#

cCs?t|t?stSt|tj?r?|jdkr?|jtjtj	fkr?|j
d}t|tj?s~|jdkr?tSq?nt
S(Nt/t%i????i(R?R?(Rt_oktypesRJRR>RAR<RR?R@RRReRT(R tdivisor((s?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pyR??s!
"
cs?tjt??tjt????fd???fd?}t||??fd??j?D??d?????fd???|?dS(NcsP|j?r'?|jdj|?n%t|tj?rL?|cd7s	c	Ss?|jj\}}t|tj?r6|j|jks<t?gt|?D]-\}}|dk	rIt	t	||ff^qI}xG|r?|j
?\}}|r?|\}	}
}|jt|f?t|tj
?s?t|tj?rR|jdkrRx7t|jd?D]"}|jt	t||ff?qW|jt	|	||jdff?n?t|tj?r?|j\}}
|jt	|	||
ff?t|tjtjf?r?xNt|j?D]"}|jt	|	||ff?q?Wq4t|tj?s4t?n6x3t|j?D]"}|jt	|	||ff?qW||kr?|	r?t|
tj?r?t|
j?}|
_|||j|?RARgtArrayAccesstFieldAccesstJavaExpressiontlistRBR?(R_R3toldRwtitem2R R7trecurseR?t
canReplacetparentR!R"R#R((s?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pyt
doReplacementsB*@	3 &# cs?g}x?t|j?D]?}x|j?D]}?|?q)Wt|jtj?r?|jjd?kr?g}xI|D]A}t|tj?s?|j	||jf?n|j?ruPququW?||?}|r?qq?n|j
d|?qW||_dS(Ni(R?R0R1RR RRgRRQRtinsert(Rt
newstatementsR_R)t
expr_rootsR?tsuccess(R?treplacevarstvisitReplace(s?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pyR?As +
	(R,tdefaultdictR?tintRatitems(R5R?((RR?R?R?R?R?s?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pyt_inlineVariables?s
	0csBt|?t||??tjt??g?D]1}t|tj?r/?|jdkr/|^q/}t
|??itjjt
j6tjjt
j6tjjt
j6tjjt
j6?????fd??????fd???|??s?t?d?kst?x*?j?D]\}}||j|_qWdS(Ncsntjtj|j?|?}?j|jtjj?}??|jjtj	||???j
|?dS(N(RtVariableDeclaratorRmR<RXRtNULLRRtLocalDeclarationStatementtremove(R?RsR#(t_init_dR$t	localdefst	remaining(s?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pyt
mdVisitVarUsees$c
sPt|tj?rLx7t|j?D]#\}}t|tj?r?t|jtj?r?|jj\}}|?kr?|?|j	kr?tj
tj|j?|?}tj
||?}||j|

c
CsFt|tj?rt|j??dkr|j?\}}t|j?t|j?koedknr|j|jkr|jd|jd}}|j|j}}t|tj?rt|tj?r|dkr?dntj
|j||?}tj||j?}nt|tj?rt|tj?rt|tj
?rt|tj
?r|jd|jdkrtj
|j|jd|jd?}tjtj
|jd|??}	|j?s|j?s?t?tj|j|j|j|	g|j?}q|	}qqqqn|jdk	r?t|j?|_n|gS(Niii(RRRMRNR1R0RIR RKR
R?tttR?RgRRzR&RRbRrRSR?(
RR_tblock1tblock2ts1ts2te1te2R ttemp((s?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pyt_createTernaries?s(*@$*$$&"-cs?t|tj?r?t|jtjtjtjtjf?s?|j}tj|j	?fd??}tj
tj|j	?|?}tj||?}q?n|gS(Ncs
?jd?S(Ntdummy(t	getPrefix(R (tnamegen(s?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pyR[?s(
RRR?R RgRlRjRhRR<R?RmR?(RR_RR#R"Rs((Rs?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pyt_fixExprStatements?s*	cCs|j|?dS(N(taddCastsAndParens(RR_tenv((s?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pyt_addCastsAndParens?scCsex*|D]"\}}|dkr||fSqWx-|D]%\}}|jdk	r4||fSq4W|dS(Ni(R
tlabel(tchoicestbtt((s?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pyt_chooseJump?scCsfd|kst?|jdk	s@|jdks@|js@t?|j|kr?|js?t|jdtjtj	f?s?t?g|j
?D]!\}}||jkr?|^q?}|s?t?t|?}|s?|jjtj
|??q?nxlt|j?D][}|j?s!t}qnt|tj?rKtd|jg?}n|t|jg?O}|j?}	t|tj?r?|j|	dtf<|j|	|tfiRRRcs
?jd?S(Ntarg(R(R (R(s?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pyR[stBRIDGEt	SYNTHETICtVARARGSstABSTRACTtSTATICtFINALtNATIVEtSTRICTFPtSYNCHRONIZEDt s.void(s.voidi(4tclass_RRRt
descriptorRTRtverifierToSynthetic_seqR
R	tcreateGraphProxytstatictinvarsRkR
t	structureRt	createASTR?tzipR<RR?RmR?RRJR&RaRpRtboolizeVarsR?R?RR?R?RR	RRRtflagsR?RR?tstrtlowertsortedtverifierToSyntheticRt	MethodDef(tmethodtgraphtforbidden_identifiersRR(t
inputTypesRnt	entryNodetnodestsetreetast_roottvarinfoR?t
argsourcest	disp_argsR R?tdeclsR2tflagstrtreturnTypestret_tt((Rs?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pytgenerateAST?sX		(
1











.1%!(BR,R?t	functoolsRtssaRtRRRRtverifier.descriptorsRRRRR	R
RtobjectRR:RGRHRWR]R?R
R?RaRpRxR~R?R?R?R?R?R?R?R?R?R?R?R?R?R>RRtParenthesisR?RmRCR?R?R?R?RR	RRR-RTRRRG(((s?/home/alex/projects/github/krakatau/Krakatau/java/javamethod.pytsT	%		
							;		0			N			(0		[	/						%	




© 2015 - 2025 Weber Informatics LLC | Privacy Policy