英纳格手表什么档次| 吃什么能快速排便| 泪点低是什么意思| outdoor是什么意思| 2023年属什么| 南瓜子有什么功效| hsv1是什么病毒| 传媒公司是干什么的| 手抖是什么原因| 化名是什么意思| 合胞病毒是什么| 肺与什么相表里| 姓彭的女孩子取什么名字好| 枕头太低有什么影响| 脾大是什么原因| 吟诗作赋是什么意思| 一岁宝宝能吃什么水果| 麦芽糊精是什么东西| 癸水是什么| azul是什么颜色| 郑州有什么好吃的| 桃子是什么颜色| 尿多尿频是什么原因造成的| 瓜蒌根为什么叫天花粉| 力所能及什么意思| 怀孕小肚子疼是什么原因| 高育良什么级别| 骨质疏松症有什么症状| 胃食管反流什么症状| 8月14是什么星座| 卵巢过度刺激综合症是什么| 公历年份是什么意思| 吃什么增加免疫力| 农历3月12日是什么星座| 一般炒什么菜放蚝油| 光明会是什么组织| 什么叫压缩性骨折| 宫颈柱状上皮外移是什么意思| 非那根又叫什么| 谷子是什么| 左膝关节退行性变是什么意思| elite是什么意思| 穿刺和活检有什么区别| 吃什么最减肥| 老炮是什么意思| 李连杰是什么国籍| 黑芝麻不能和什么一起吃| 不务正业是什么意思| 隐翅虫长什么样| 苋菜与什么食物相克| 献血有什么要求| 上不下大是什么字| 尿酸高适合吃什么菜| 英语专八是什么水平| 粉底液是干什么用的| 去医院打耳洞挂什么科| 媱五行属什么| 疝气是什么症状| lining是什么意思| 蔻依属于什么档次| 梅菜是什么菜晒干的| 复方氨酚烷胺胶囊是什么药| 杭州灵隐寺求什么最灵| 白猫是什么品种| 哎是什么意思| mra是什么意思| 炖牛肉放什么调料| 娇韵诗属于什么档次| 硬性要求是什么意思| 口臭看什么科| 卵泡破裂是什么意思| 尿素氮偏高是什么意思| 6月8日是什么星座| 梦到牛是什么意思| 黄历冲生肖是什么意思| 辣木籽主治什么病| 世界上最深的湖是什么| 肌肉萎缩吃什么药| 鳄鱼吃什么食物| 大人退烧吃什么药| 什么是正骨| 西米是什么米| 产后腰疼是什么原因| 咽喉炎是什么原因引起的| 内火旺是什么原因| 卵巢过度刺激综合症是什么| 干涸是什么意思| 老人反复发烧是什么原因引起的| 一什么永什么成语| 周杰伦为什么喜欢昆凌| 雄性激素过高是什么原因| 通字五行属什么| 什么人不能喝豆浆| 眼睛疼吃什么药效果最好| 拔河是什么意思| nary是什么牌子的手表| 绒毛膜促性腺激素是什么意思| 菠萝蜜是什么季节的水果| 玉米是什么植物| 渗透压是什么| 六十岁叫什么之年| 心梗吃什么药| 奢靡是什么意思| 霜和乳有什么区别| 冠心病用什么药| 糖耐量受损是什么意思| 铁锭是什么意思| 看演唱会需要准备什么| 贫血要做什么检查| 院士是什么级别| 心肌梗塞是什么原因造成的| 喝隔夜茶有什么好处和坏处| 沙示汽水有什么功效| 胆五行属什么| ideal是什么意思| 脚掌疼是什么原因| 心梗是什么病| 和胃降逆是什么意思| 天王星是什么颜色| 区号是什么| 花生什么时候成熟| 为什么会拉稀| 一唱一和是什么生肖| 血糖高要注意什么| 做空是什么意思啊| 金鸡独立是什么意思| 脑子里嗡嗡响是什么原因| 郭富城属什么生肖| 1975年是什么命| 乙肝表面抗体高是什么意思| 鼻翼长痘是什么原因| 头响脑鸣是什么原因引起的| 乌灵胶囊有什么副作用| 果子狸是什么动物| 转述句是什么意思| 房性心律是什么意思| 胆囊炎不能吃什么食物| cba新赛季什么时候开始| 人工牛黄是什么| 腺样体肥大是什么症状| 香草是什么植物| 预热是什么意思| 天铁是什么| 限购是什么意思| 女人脸黄是什么原因该怎么调理| 打了狂犬疫苗不能吃什么| 双氢克尿噻又叫什么| 七月22号是什么星座| 间接胆红素偏高是什么原因| 容易早醒是什么原因| 为什么突然得了荨麻疹| 山珍海味是什么意思| 内衣34是什么码| 乾隆为什么不喜欢雍正| 黄体酮低吃什么补得快| 艾蒿是什么| 性张力是什么意思| 梦到下雪是什么征兆| 什么是敏感肌| 女性出汗多是什么原因| 惺惺相惜什么意思| 凤雏是什么意思| 硫黄和硫磺有什么区别| 舌头发硬是什么原因| 菠菜为什么要焯水| 催经吃什么药| 手指尖发麻是什么原因| 地委书记是什么级别| 灶性肠化是什么意思| 爱被蚊子咬是什么原因| 宫颈口出血是什么原因| 肾结石有什么症状哪里疼| 126是什么邮箱| 母螳螂为什么要吃公螳螂| 镜子是什么生肖| 运动员心率为什么慢| 人为什么会放屁| 北京朝阳医院擅长什么| 为什么大姨妈迟迟不来| 脚踝扭伤挂什么科| 开飞机是什么意思| 什么猫好看| 种植什么药材最赚钱| 粘鞋子用什么胶水最好| 腰间盘突出压迫神经什么症状| 网是什么结构的字| 老来得子是什么意思| 什么是职业道德| 眼力见是什么意思| 单侧耳鸣是什么原因引起的| 三个香读什么| 彩虹有什么颜色| 主动脉夹层什么意思| 甲功是什么意思| 3月6号是什么星座| 女生的小鸡鸡长什么样| 脚痒脱皮是什么原因| 一节黑一节白是什么蛇| 头孢是什么药| 声带白斑是什么病严重吗| 尿隐血挂什么科| 咳嗽是什么原因| 牙周炎吃什么药效果好| 但闻人语响的但是什么意思| 鸡宝是什么| 周边是什么| 大口什么字| 甲钴胺治疗什么病| 为什么左手会发麻| 日本为什么侵华| 阴茎不够硬吃什么药| 车顶放饮料是什么意思| 梦见打老虎是什么预兆| 桑榆未晚是什么意思| 金银花入什么经| 刮目相看是什么意思| 尿淀粉酶高是什么原因| 梦见老板是什么意思| 老学究什么意思| 胃火吃什么中成药| 蜱虫是什么虫| 一个口一个者念什么| 屁股眼痒是什么原因| 孕妇喝可乐对胎儿有什么影响| 今年28岁属什么| 7月15日是什么节| 藏青色是什么颜色| 纳囊是什么病| 中风是什么原因引起的| 宫外孕破裂有什么症状| 十二朵玫瑰花代表什么意思| 吃完羊肉不能吃什么水果| 19岁属什么的生肖| 梦见死蛇是什么预兆| 忆苦思甜下一句是什么| 黄皮肤适合什么颜色的衣服| 厦门有什么区| 氢什么意思| 风寒感冒和风热感冒有什么区别| 小肝癌是什么意思| 吃中药不能吃什么东西| 苏打水有什么好处| 长期失眠挂什么科| 11月是什么星座| 摩罗丹主要治什么胃病| 尿蛋白高吃什么食物好| 双龙戏珠是什么意思| 97年属牛的是什么命| ira是什么品牌| 红曲是什么| 逆向思维是什么意思| 积液是什么| 经常头晕是什么原因引起的| 尿比重1.030是什么意思| 螺旋体感染是什么意思| 小乌龟吃什么食物| 经期适合喝什么茶| 守活寡什么意思| 吗丁啉有什么功效| 3月17日是什么星座的| 梦见倒房子是什么预兆| 叶酸片什么时候吃| 营长是什么军衔| 脖子后面正中间有痣代表什么| 百度
Skip to content

Persper/js-callgraph

Repository files navigation

Field-based Call Graph Construction for JavaScript

Build Status NPM version License

This project implements a field-based call graph construction algorithm for JavaScript as described in

A. Feldthaus, M. Sch?fer, M. Sridharan, J. Dolby, F. Tip. Efficient Construction of Approximate Call Graphs for JavaScript IDE Services. In ICSE, 2013.

This repo builds upon Max Schaefer's original acg.js and adds

  • ES6 Support
    • Arrow functions
    • Destructuring assignments
    • Classes
    • Enhanced object literals
    • Rest/Spread operator
  • Module Support
    • ES6/CommonJS/AMD
  • More sophisticated scoping
  • Partial update to a large call graph
  • Unified JSON format representing a call graph
  • More flexible CLI
    • Take directory parameter
    • Support filtering files by regex
  • Vue.js support (.vue files)
  • More tests

Get Started (CLI)

npm install -g @persper/js-callgraph
js-callgraph -h # for a list of command line arguments

# Running on simple input scripts
js-callgraph --cg input-scripts/simple-scripts/functioncall-arithmetic.js

# Running on a whole directory
js-callgraph --cg input-scripts/fullcalendar/

# Running on mixed input
js-callgraph --cg input-scripts/fullcalendar/fullcalendar/ input-scripts/fullcalendar/lib/jquery-2.1.0.js

# Saving the result into a file
js-callgraph --cg input-scripts/simple-scripts/functioncall-arithmetic.js --output filename.json

# Running on a whole directory with filtering
js-callgraph --cg input-scripts/fullcalendar/ --filter filename.filter

For an example of the output json, please see here. For an example of filtering file, please see here.

Programming Interface

const JCG = require("./src/runner");
args = { ... };
JCG.setArgs(args);                                # Optional, specify a list of arguments
JCG.setFiles(['file.js', 'directory/']);          # List of files or directories to analyze
JCG.setFilter(['-test[^\.]*.js', '+test576.js']); # Optional, please see "Filter file format" section for details
JCG.setConsoleOutput(true);                       # Optional, the console output can be turned off.
JCG.build();                                      # build returns the call graph as a JSON object, please see "Unified JSON Format" section

Running Tests

To run the testing framework run:

npm test

To install the git hooks to run tests automatically pre-commit run:

scripts/install-hooks

Structure

The call graph constructor can be run in two basic modes (selected using the --strategy flag to javascript-call-graph), pessimistic and optimistic, which differ in how interprocedural flows are handled. In the basic pessimistic approach (strategy NONE), interprocedural flow is not tracked at all; a slight refinement is strategy ONESHOT, where interprocedural flow is tracked only for one-shot closures that are invoked immediatel. The optimistic approach (strategy DEMAND) performs interprocedural propagation along edges that may ultimately end at a call site (and are thus interesting for call graph construction). Full interprocedural propagation (strategy FULL) is not implemented yet.

All strategies use the same intraprocedural flow graph, in which properties are only identified by name; thus, like-named properties of different objects are conflated; this can lead to imprecise call graphs. Dynamic property reads and writes are ignored, as are reflective calls using call and apply; thus, the call graphs are intrinsically incomplete.

Module flowgraph.js contains the code for extracting an intraprocedural flow graph from an Esprima AST annotated with name bindings for local variables (see bindings.js, which uses symtab.js and astutil.js).

Modules pessimistic.js and semioptimistic.js implement the pessimistic and optimistic call graph builders, respectively. They both use flowgraph.js to build an intraprocedural flow graph, and then add some edges corresponding to interprocedural flow. Both use module callgraph.js for extracting a call graph from a given flow graph, by collecting, for every call site, all functions that can flow into the callee position. Both use module natives.js to add flow edges modelling well-known standard library functions.

The remaining modules define key data structures, in several variants.

Module graph.js implements graphs using adjacency sets, using sets of numbers as implemented by numset.js. The latter includes either olist.js to implement sets as ordered lists of numbers, or bitset.js to use bitsets (with disappointing performance, so we use ordered lists by default).

Modules dftc.js, heuristictc.js and nuutila.js implement several transitive closure algorithms used by callgraph.js. By default, we use dftc.js which uses a simple, depth first-search based algorithm. heuristictc.js does something even simpler, which is very fast but unsound. Finally, nuutila.js implements Nuutila's algorithm for transitive closure, which for our graphs is usually slower than the depth first-based ones.

Unified JSON Format

[ # The calls are represented with a list of objects. Each call is an object in this list.
  {
    "source": { # The source object represents the start point of a call (the caller node)
      "label": "global",
      "file": "...\\input-scripts\\simple-scripts\\functioncall-arithmetic.js",
      "start": { # The start point of the source with row-column based position.
        "row": 7,
        "column": 4
      },
      "end": { # The end point of the source node with row-column based position.
        "row": 7,
        "column": 8
      },
      "range": { # The position of the source node in index-based representation.
        "start": 59,
        "end": 63
      }
    },
    "target": { # The target object represents the end point of a call (this node is called by the source)
      "label": "f",
      "file": "...\\input-scripts\\simple-scripts\\functioncall-arithmetic.js",
      "start": { # The start point of the target node with row-column based position..
        "row": 3,
        "column": 0
      },
      "end": { # The end point of the target node with row-column based position.
        "row": 5,
        "column": 1
      },
      "range": { # The position of the target node in index-based representation.
        "start": 14,
        "end": 51
      }
    }
  }
]

Filter file format

Any valid regular expression can be specified in the filter file. The order of the including and excluding lines are important since they are processed sequentially.

The first character of each line represents the type of the filtering:

# Comment line
- Exclude
+ Include

An example for filtering:

# Filter out all source files starting with "test":
-test[^\.]*.js
# But test576.js is needed:
+test576.js
# Furthermore, files beginning with "test1742" are also needed:
+test1742[^\.]*.js
# Finally, test1742_b.js is not needed:
-test1742_b.js

List of arguments

-h         : List of command line arguments
--fg       : print flow graph
--cg       : print call graph
--time     : print timings
--strategy : interprocedural propagation strategy; one of NONE, ONESHOT (default), DEMAND, and FULL (not yet implemented)
--countCB  : Counts the number of callbacks.
--reqJs    : Make a RequireJS dependency graph.
--output   : The output file name into which the result JSON should be saved. (extension: .json)
--filter   : Path to the filter file.

Contributing

Looking to contribute something? Here's how you can help.

License

This code is licensed under the Eclipse Public License (v2.0), a copy of which is included in this repository in file LICENSE.

About

Construct approximate static call graph for JavaScript & Typescript

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 9

星期三左眼皮跳是什么预兆 农历五月十八是什么日子 胃痛吃什么药效果好 炒牛肉用什么配菜 月蚀是什么意思
bae什么意思 hpv感染什么症状 第二学士学位是什么意思 办护照需要带什么 头发竖起来是什么原因
米索前列醇片是什么药 手抖是什么毛病 move什么意思 芈月和秦始皇什么关系 吃什么可以缓解焦虑
袍哥什么意思 石墨烯属于什么材料 牛肉和什么蔬菜搭配好 郭字五行属什么 胎盘位于子宫前壁是什么意思
金瓜和南瓜有什么区别hcv9jop0ns8r.cn 木瓜是什么季节的bjcbxg.com ooc什么意思hcv8jop7ns1r.cn 出圈是什么意思hcv9jop6ns7r.cn 皮肤暗黄是什么原因造成的hcv9jop7ns5r.cn
浅表性胃炎伴糜烂吃什么药效果好hcv9jop0ns1r.cn 梦见屎是什么预兆hcv9jop0ns1r.cn 一月20号是什么星座bjhyzcsm.com 龟头炎看什么科hcv9jop4ns1r.cn 全身发抖是什么原因hcv8jop5ns8r.cn
巧克力囊肿有什么症状表现hcv7jop5ns3r.cn 得宫颈癌的前兆是什么hcv9jop4ns6r.cn 水煮肉片用什么肉baiqunet.com 头晕是为什么creativexi.com 青霉素过敏不能吃什么药hcv7jop5ns3r.cn
津液亏虚是什么意思hcv8jop9ns9r.cn 地三鲜是什么zhongyiyatai.com 滚去掉三点水念什么hcv9jop4ns1r.cn 什么叫同人文jinxinzhichuang.com 拉屎擦屁股纸上有血什么原因hcv9jop5ns0r.cn
百度