Introduction
Also known as pre-pre-compiled, the code is the replacement text of work to do. It is the entire compilation of the first to do the job.
- Processing of instructions beginning with #, for example, copy the file that contains the code #include, replacing the # define macros, conditional compilation, etc., it is the stage for the compiler to do the preparatory work.
Precompiled main processing instruction # started, the operation instruction indicates pre-compiled by the compiler proceeds before the officially compiled, you can be placed anywhere in the program.
C compilation system prior to a normal program compilation, first preprocessed
Preprocessing functions
C preprocessing function mainly provides the following three:
- Macro definition.
- File contains.
- Conditional compilation.
Pre-compiled (function before execution)
- AO create objects (Active Object)
- Parameter lookup function and the function declaration variables, parameter names and variable names as AO object attribute value is undefined
- Unity parameter arguments, argument value assigned to parameter
- Find function declarations, function name as an attribute of an object AO, is a function reference
Precompiled (script code block before execution script)
- Finding a global variable declaration (including implicit global variable declarations, statements var omitted), the global variable masterpiece object attribute value is undefined
- Find function declarations, function name as a property of the global object, function reference value
Let me give you a few examples of small pre-compiled:
var a = 123;
console.log(a);
At this time, he would return the value of 123;
But if we exchange places:
console.log(a);
var a = 123;
我们得到的结果便会是undefined。
Listed as
= 10 A;
----> window.a = 10;
all the declared global variables, all of the properties window
that window is doing?
window is the global domain
var a = 123;
global variables for the first time into the computer disk inside window is
a defined before if you want to visit when he will go inside to find a window
is actually
var a = 123;
console.log (a) -> window.a is actually accessible window.a
window there is a global variable no local variables!
Precompiled function occurs before the moment of execution
function fn(a){
console.log(a);
var a = 123;
console.log(a);
function a(){}
console.log(a);
var b = function () {};
console.log(b);
}
fn(1)
- Creating AO object (the context of the implementation period) Activation Object
AO{ }
- Get and variables declared parameter, the variable parameter name and the attribute name as AO, is
undefined
AO{
a:undefined,
b:undefined,
}
- The arguments and parameters unity
AO{
a:1,
b:undefined,
}
4. In the function body, to find a function declaration , given the value of the function thereof ;
AO{
a:function a(){},
// 把形参覆盖了 注意:**function a(){} 是函数声明
只有它能提升; var b = function(){}这种是表达式**
b:undefined,
}
AO over this object is created
and then immediately execute the function of the target computer from the inside AO take things
so that the first print function a () {},
A 123 is assigned, the second printing is 123,
and since the function a ( )} {has been elevated up, so do third time, printing is 123, fourth print function ({is lifted, so is the last print function () {}}
// }
function test(a,b){
console.log(a); //function a(){};
console.log(b); //undefined
var b = 234;
console.log(b) //234
a = 123;
console.log(a); //123
function a(){};
var a ;
b = 234;
var b = function(){};
console.log(a); //123
console.log(b); //function(){};
}
test(1)
1. AO:{
//过程
}
2. AO:{
a:undefined;
b:undefined;
}
3. AO:{
a:1;
b:undefined;
}
4. AO:{
a:function a(){};
b:undefined;
}
所以第一次输出的a是 function a(){};b 是undefined
b=234
AO:{
a:function a(){};
b:234;
}
下个b输出就是234
a = 123
AO:{
a:123;
b:234;
}
下个a输出就是123
The declaration does not produce the middle of the AO object affects the output unchanged
var b = function(){};
AO:{
a:123;
b:function(){};
}