Skip to content

源码一瞥

Yang Feng edited this page Aug 3, 2019 · 2 revisions

QuickJs源码一览

下载源码后,进入quickjs目录

  • 先用 cloc 工具统计一下代码行数情况,所有文件60个不到,其中代码文件45个含7万5千行代码,6千空行,4千注释。C头文件和实现文件分别是6千行和6万行左右。
      57 text files.
      55 unique files.                              
      14 files ignored.

github.com/AlDanial/cloc v 1.72  T=1.00 s (45.0 files/s, 85067.5 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
C                               13           5051           3242          59838
C/C++ Header                    12            385            377           6396
JavaScript                      15            634            234           6196
HTML                             2            212             54           1824
make                             1            100             49            319
Bourne Shell                     2             32              7             65
-------------------------------------------------------------------------------
SUM:                            45           6414           3963          74638
-------------------------------------------------------------------------------
  • 再用 tree 命令查看到项目根上录只有一级子目录,所有子目录里全是文件,不再含有下一级子目录,层级扁平极了。(截图就贴了)

  • 执行 ls */,除了文档目录doc/,示例 examples/和测试tests/目录少许文件外,大部分都在根目录下。12个.h头文件和13个.c代码

Changelog		libregexp-opcode.h	quickjs-atom.h		test262.conf
Makefile		libregexp.c		quickjs-libc.c		test262_errors.txt
TODO			libregexp.h		quickjs-libc.h		test262bn.conf
VERSION			libunicode-table.h	quickjs-opcode.h	test262bn_errors.txt
bjson.c			libunicode.c		quickjs.c		test262o.conf
cutils.c		libunicode.h		quickjs.h		test262o_errors.txt
cutils.h		list.h			readme.txt		unicode_download.sh
jscompress.c		qjs.c			release.sh		unicode_gen.c
libbf.c			qjsc.c			repl.js			unicode_gen_def.h
libbf.h			qjscalc.js		run-test262.c

doc:
jsbignum.html	jsbignum.pdf	jsbignum.texi	quickjs.html	quickjs.pdf	quickjs.texi

examples:
c_module.js	fib.c		fib_module.js	hello.js	hello_module.js	pi.js

tests:
microbench.js	test_bignum.js	test_builtin.js	test_loop.js	test_std.js
test262.patch	test_bjson.js	test_closure.js	test_op.js
  • 执行wc *.h查看所有头文件信息
     292    1074    7286 cutils.h
     350    1807   12543 libbf.h
      58     355    2236 libregexp-opcode.h
      91     435    3129 libregexp.h
    4313   27929  209625 libunicode-table.h
     124     491    3751 libunicode.h
     100     472    3119 list.h
     276     749    8203 quickjs-atom.h
      44     261    1922 quickjs-libc.h
     352    2421   14344 quickjs-opcode.h
     878    3622   34805 quickjs.h
     280     579    6712 unicode_gen_def.h
    7158   40195  307675 total
  • 执行 wc *.c查看所有.c 文件信息
      88     363    2918 bjson.c
     621    2472   16954 cutils.c
     918    2778   25033 jscompress.c
    5806   21564  164385 libbf.c
    2541    8231   81986 libregexp.c
    1538    5281   46412 libunicode.c
     465    1441   13081 qjs.c
     637    1869   17721 qjsc.c
    1830    5041   53226 quickjs-libc.c
   48538  145839 1585836 quickjs.c
    2021    6008   60333 run-test262.c
    3056    9633   83221 unicode_gen.c
   68059  210520 2151106 total
Clone this wiki locally