资源描述:
《Type Analysis for JavaScriptJavaScript的类型分析》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、TypeAnalysisforJavaScriptSimonHolmJensen1,⋆,AndersMøller1,⋆,†,andPeterThiemann21AarhusUniversity,Denmark{simonhj,amoeller}@cs.au.dk2Universit¨atFreiburg,Germanythiemann@informatik.uni-freiburg.deAbstract.JavaScriptisthemainscriptinglanguageforWebbrowse
2、rs,anditisessentialtomodernWebapplications.Programmershavestartedusingitforwritingcomplexapplications,butthereisstilllittletoolsupportavailableduringdevelopment.Wepresentastaticprogramanalysisinfrastructurethatcaninferde-tailedandsoundtypeinformationfo
3、rJavaScriptprogramsusingabstractinterpretation.TheanalysisisdesignedtosupportthefulllanguageasdefinedintheECMAScriptstandard,includingitspeculiarobjectmodelandallbuilt-infunctions.Theanalysisresultscanbeusedtodetectcommonprogrammingerrors–orrather,prove
4、theirabsence,andforproducingtypeinformationforprogramcomprehension.Preliminaryexperimentsconductedonreal-lifeJavaScriptcodeindicatethattheapproachispromisingregardinganalysisprecisiononsmallandmediumsizeprograms,whichconstitutethemajorityofJavaScriptap
5、pli-cations.Withpotentialforfurtherimprovement,weproposetheanalysisasafoundationforbuildingtoolsthatcanaidJavaScriptprogrammers.1IntroductionIn1995,NetscapeannouncedJavaScriptasan“easy-to-useobjectscriptinglan-guagedesignedforcreatingliveonlineapplicat
6、ionsthatlinktogetherobjectsandresourcesonbothclientsandservers”[25].Sincethen,ithasbecomethedefactostandardforclient-sidescriptinginWebbrowsersbutmanyotherappli-cationsalsoincludeaJavaScriptengine.Thisprevalencehasleaddeveloperstowritelargeprogramsinal
7、anguagewhichhasbeenconceivedforscripting,butnotforprogramminginthelarge.Hence,toolsupportisbadlyneededtohelpdebugandmaintaintheseprograms.Thedevelopmentofsoundprogrammingtoolsthatgobeyondcheckingmeresyntacticpropertiesrequiressomesortofprogramanalysis.
8、Inparticular,typeanalysisiscrucialtocatchrepresentationerrors,whiche.g.confusenumberswithstringsorbooleanswithfunctions,earlyinthedevelopmentprocess.Typeanalysisisavaluabletooltoaprogrammerbecauseitrulesoutthisclassofprogrammingerrorsen