首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 开源软件 >

hiphop 原理分析四 原创-胡志广

2013-10-28 
hiphop 原理分析4 原创--胡志广??1.3.? preOptimize 实例例:$a1+2*3+4语法树:???(1)优化2*3 返回结果Scal

hiphop 原理分析4 原创--胡志广

?

?

1.3.? preOptimize 实例

例:$a=1+2*3+4

语法树:

?

?
hiphop 原理分析四 原创-胡志广
?

(1)优化2*3 返回结果ScalarExpression(6),封装到上一级的BinaryOpExpression上


hiphop 原理分析四 原创-胡志广
?

?

(2)优化1+6返回结果ScalarExpression(7),封装到上一级的BinaryOpExpression上


hiphop 原理分析四 原创-胡志广
?

?

(3)优化1+6返回结果ScalarExpression(11),封装到上一级的AssignmentExpression上,最终把一颗大树优化为了一个赋值表达式


hiphop 原理分析四 原创-胡志广
?

?

?

1.4.? preOptimize代码分析

这里抽取一个一元表达式的作为例子进行分析(unary_op_expression.cpp):

?

2.3.3.??? Type::IsLegalCast

?

2.3.4.??? Type::isStandardObject()

?

2.3.11.5.?????? Type::outputCPPCast
类型在type.h中,有如下的类型: static const KindOf KindOfVoid       = 0x0001;  static const KindOf KindOfBoolean    = 0x0002;  static const KindOf KindOfInt32      = 0x0010;  static const KindOf KindOfInt64      = 0x0020;  static const KindOf KindOfDouble     = 0x0040;  static const KindOf KindOfString     = 0x0080;  static const KindOf KindOfArray      = 0x0100;  static const KindOf KindOfObject     = 0x0200;   // with classname  static const KindOf KindOfVariant    = 0xFFFF;  /* This bit tells coerce that if the other type     is already one of the specified types, it wont     be modified.     eg $a['foo'] = <whatever>     If $a is already known to be string or array, it stays that way.     If we coerce to Sequence, however, it would become Sequence, and     hence Variant  */  static const KindOf KindOfAuto       = 0x0400;  static const KindOf KindOfInteger = (KindOf)(KindOfInt64 | KindOfInt32);  static const KindOf KindOfNumeric = (KindOf)(KindOfDouble | KindOfInteger);  static const KindOf KindOfPrimitive = (KindOf)(KindOfNumeric | KindOfString);  static const KindOf KindOfPlusOperand = (KindOf)(KindOfNumeric | KindOfArray);  static const KindOf KindOfSequence = (KindOf)(KindOfString | KindOfArray);  static const KindOf KindOfAutoSequence = (KindOf)(KindOfAuto |KindOfSequence);  static const KindOf KindOfAutoObject = (KindOf)(KindOfAuto | KindOfObject);  static const KindOf KindOfSome = (KindOf)0x7FFE;  static const KindOf KindOfAny = (KindOf)0x7FFF;  /**   * Inferred types: types that a variable or a constant is sure to be.   */  static TypePtr Null;  static TypePtr Boolean;  static TypePtr Int32;  static TypePtr Int64;  static TypePtr Double;  static TypePtr String;  static TypePtr Array;  static TypePtr Object;  static TypePtr Variant;  static TypePtr Numeric;  static TypePtr PlusOperand;  static TypePtr Primitive;  static TypePtr Sequence;  static TypePtr AutoSequence;  static TypePtr AutoObject;  static TypePtr Any;  static TypePtr Some;

?

热点排行