一句话:提出 RefiNym,通过名称流无监督挖掘概念类型并具体化为名义类型,以精化程序类型。
源代码兼具形式化算法通道与标识符/注释的自然语言通道。逻辑上不同的概念类型(如 Password 与 URL)常共享同一程序类型(如 string),使类型系统无法阻止跨概念误用。本文提出 name flows——扩展赋值流图以跟踪标识符名称;RefiNym 从中无监督地挖掘概念类型格,并将其具体化为不同名义类型。在 string 类型上,RefiNym 拆分原本合并的概念类型,把每个作用域的同类型变量数从 8.7 降至 2.2,并消除 21.9% 含多个同类型变量的作用域,使代码更自文档化,也让类型系统能阻止开发者的跨概念赋值。
Source code is bimodal: it combines a formal, algorithmic channel and a natural language channel of identifiers and comments. In this work, we model the bimodality of code with name flows, an assignment flow graph augmented to track identifier names. Conceptual types are logically distinct types that do not always coincide with program types. Passwords and URLs are example conceptual types that can share the program type string. Our tool, RefiNym, is an unsupervised method that mines a lattice of conceptual types from name flows and reifies them into distinct nominal types. For string, RefiNym finds and splits conceptual types originally merged into a single type, reducing the number of same-type variables per scope from 8.7 to 2.2 while eliminating 21.9% of scopes that have more than one same-type variable in scope. This makes the code more self-documenting and frees the type system to prevent a developer from inadvertently assigning data across conceptual types.