惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

B
Blog RSS Feed
量子位
Y
Y Combinator Blog
大猫的无限游戏
大猫的无限游戏
B
Blog
U
Unit 42
C
Check Point Blog
I
InfoQ
aimingoo的专栏
aimingoo的专栏
雷峰网
雷峰网
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 【当耐特】
人人都是产品经理
人人都是产品经理
The Cloudflare Blog
H
Help Net Security
MongoDB | Blog
MongoDB | Blog
博客园 - Franky
H
Hackread – Cybersecurity News, Data Breaches, AI and More
J
Java Code Geeks
Microsoft Azure Blog
Microsoft Azure Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
云风的 BLOG
云风的 BLOG
宝玉的分享
宝玉的分享
爱范儿
爱范儿

SumSec's Blog

AI Agent 工程的必然演进:CLI、Skills、Harne… 从安全角度谈Java反射机制--前章 · SUMSEC 从安全角度谈Java反射机制--终章 · SUMSEC 逆向学习fastjson反序列化始 · SUMSEC 2020年研究回顾总结 · SUMSEC Abstract syntax tree classes for … Analyzing data flow in Java · SUM… Annotations in Java · SUMSEC Basic query for Java code · SUMSEC BypassSuper使用介绍说明 · SUMSEC CodeQL Create OpenJdk/Jdk8 Databa… CodeQL library for Java · SUMSEC Navigating the call graph · SUMSEC Overflow-prone comparisons in Jav… Types in Java · SUMSEC Working with source locations · S… Expression · SUMSEC Formulas · SUMSEC Javadoc · SUMSEC Modules · SUMSEC Predicates · SUMSEC Queries · SUMSEC Type · SUMSEC Variables · SUMSEC 一道shiro反序列化题目引发的思考 · SUMSEC 修改ysoserial使其支持任意代码执行 · SUMSEC 自定义 ClassLoader 隔离运行不同版本jar包的方式 ·… 2020网鼎杯---Java文件上传wp · SUMSEC CNVD-2020-10487(CVE-2020-1938)tom… JDSRC安全课笔记 · SUMSEC
Aliases · SUMSEC
2026-07-17 · via SumSec's Blog

Aliases

Aliases

An alias is an alternative name for an existing QL entity.

别名是现有QL实体的替代名称。

Once you’ve defined an alias, you can use that new name to refer to the entity in the current module’s namespace.

一旦你定义了一个别名,你就可以使用这个新名字来引用当前模块命名空间中的实体。


Defining an alias定义别名

You can define an alias in the body of any module. To do this, you should specify:

您可以在任何模块的主体中定义别名。要做到这一点,您应该指定:

  1. The keyword module, class, or predicate to define an alias for a module, type, or non-member predicate respectively.

    关键字,或分别定义模块类型非成员谓词的别名。module``class``predicate

  2. The name of the alias. This should be a valid name for that kind of entity. For example, a valid predicate alias starts with a lowercase letter.

    别名的名字。这应该是此类实体的有效名称。例如,有效的谓词别名以小写字母开头。

  3. A reference to the QL entity. This includes the original name of the entity and, for predicates, the arity of the predicate.

    对QL实体的引用。这包括实体的原始名称,对于谓词,包括谓词的原名。

You can also annotate an alias. See the list of annotations available for aliases.

您还可以注释别名。请参阅可用于别名的注释列表。

Note that these annotations apply to the name introduced by the alias (and not the underlying QL entity itself). For example, an alias can have different visibility to the name that it aliases.

请注意,这些注释适用于别名引入的名称(而不是基础 QL 实体本身)。例如,别名可以与它所别名的名称具有不同的可见性。


Module aliases模块别名

Use the following syntax to define an alias for a module:

使用以下语法定义模块的别名:

module ModAlias = ModuleName;

For example, if you create a new module NewVersion that is an updated version of OldVersion, you could deprecate the name OldVersion as follows:

例如,如果您创建了更新版本的新模块,则可以将名称弃用如下:NewVersion``OldVersion``OldVersion

deprecated module OldVersion = NewVersion;

That way both names resolve to the same module, but if you use the name OldVersion, a deprecation warning is displayed.

这样,两个名称都会解决到同一模块,但如果您使用该名称,将显示弃用警告。OldVersion


Type aliases类型别名

Use the following syntax to define an alias for a type:

使用以下语法定义一种类型的别名:

class TypeAlias = TypeName;

Note that class is just a keyword. You can define an alias for any type—namely, primitive types, database types and user-defined classes.

请注意,这只是一个关键字。您可以为任何类型定义别名,即原始类型数据库类型和用户定义的类class

For example, you can use an alias to abbreviate the name of the primitive type boolean to bool:

例如,可以使用别名将基元类型boolean的名称缩写为bool

class bool = boolean;

Or, to use a class OneTwo defined in a module M in OneTwoThreeLib.qll, you could create an alias to use the shorter name OT instead:

或者,如果要使用OneTwoThreeLib.qll中M模块中定义的OneTwo类,你可以创建一个别名,使用更短的名字OT来代替。

import OneTwoThreeLib

class OT = M::OneTwo;

...

from OT ot
select ot

image-20210316160600475


Predicate aliases谓词别名

Use the following syntax to define an alias for a non-member predicate:

使用以下语法来定义非成员谓词的别名:

predicate PredAlias = PredicateName/Arity;

This works for predicates with or without result.

这适用于有结果或无结果的谓词。

For example, suppose you frequently use the following predicate, which calculates the successor of a positive integer less than ten:

例如,假设你经常使用下面的谓词,它计算一个小于10的正整数getSuccessor:

int getSuccessor(int i) {
  result = i + 1 and
  i in [1 .. 9]
}

You can use an alias to abbreviate the name to succ:

你可以用别名来缩写名字succ

predicate succ = getSuccessor/1;

示例:

int getSuccessor(int i) {
    result = i + 1 and
    i in [1 .. 9]
}

predicate succ = getSuccessor/1;

from int i
select succ(i)

image-20210316161029513

As an example of a predicate without result, suppose you have a predicate that holds for any positive integer less than ten:

另一个没有结果的谓词的例子,假设你有一个对任何小于10的正整数都成立的谓词。

predicate isSmall(int i) {
  i in [1 .. 9]
}

You could give the predicate a more descriptive name as follows:

您可以给谓词一个更描述性的名称如下:

predicate lessThanTen = isSmall/1;

示例:

predicate isSmall(int i) {
    i in [1 .. 9]
}

predicate lessThanTen = isSmall/1;

from int i
where lessThanTen(i)
select i

image-20210316162008023