资讯专栏INFORMATION COLUMN

执行上下文(执行环境)-Chapter1

elisa.yang / 453人阅读

摘要:堆栈结构的底部是全局执行上下文,顶部是当前执行上下文。不同的执行上下文切换时堆栈会发生改变译论及代码类型时,在某些时候可能也意味着执行上下文。函数体中代码执行完后,只剩全局上下文直到程序结束译代码更有意思。

第一次翻译,希望各位多多包涵,有错误处还望指出,欢迎提出建议。

Chapter 1.Execution Contexts

Introduction (介绍)

Definitions (定义)

Types of excutable code (可执行代码的类型)

Global code(全局代码)

Funcion code(函数代码)

Eval code(eval代码)

Conclusion(结论)

Additional literature (文献参考)

Introduction

In this note we will metion execution contexts of ECMAScript and types of executable code related with them.

译:在这篇笔记中,我们将讨论执行环境和相关的可执行代码类型。

Definitions

Every time when control is transferred to ECMAScript executable code, control is entered an execution context.

译:当控制流即将执行代码时,总是先进入执行上下文

Execution context( abbreviated from - EC) is the abstract concept used by ECMA-262 specification for typification and differentation of an executable code.

译:执行上下文(缩写为EC)是ECMA-262使用的抽象概念,通常用来表示可执行代码的类型和区别。

The standard does not define accurate structure and kind of EC from the technical implementation viewpoint; it is a question of the ECMAScript-engines implementing the standard.

译:官方标准没有定义EC的确切结构和技术实现,按照规范来实现依然ECMAScript引擎的问题

Logically, set of active execution contexts forms a stack. The bottom of this stack is always a global context, the top - a current (active) execution context. The stack is modified (pushed/popped) during the entering and exiting various kinds of EC.

译:从逻辑上来看,许多激活的执行上下文会形成一个堆栈结构。堆栈结构的底部是全局执行上下文,顶部是当前执行上下文。不同的执行上下文切换时堆栈会发生改变

Types of executable code

With abstract concept of an execution context, the concept of type of an executable code is related. Speaking about code type, it is possible in the certain moments to mean an execution context.

译:论及代码类型时,在某些时候可能也意味着执行上下文。可执行上下文的抽象概念和其类型是分不开的

For examples, we define the stack of execution contexts as an array:

译:例如,我们将执行上下文的堆栈定义为数组

ECStack = [];

The stack is pushed every time on entering a function (even if the function is called recursively or as the constructor), and also at built-in eval function work.

译:控制流每次进入函数(即使该函数是递归调用或作为构造器)时,入栈就会发生,同样内嵌在该函数中的eval函数也会引发入栈行为。

Global code

This type of code is processed at level Program: i.e. the loaded external .js -file or the local inline-code (inside the tags). The global code does not include any parts of a code which are in bodies of functions.

译:这种类型的代码是以程序级别处理的:比如说额外的js文件或者局部的内连代码(在

阅读需要支付1元查看
<