WrnExp = None\r
\r
if Operator not in {"==", "!=", ">=", "<=", ">", "<", "in", "not in"} and \\r
- (type(Oprand1) == type('') or type(Oprand2) == type('')):\r
+ (isinstance(Oprand1, type('')) or isinstance(Oprand2, type(''))):\r
raise BadExpression(ERR_STRING_EXPR % Operator)\r
if Operator in {'in', 'not in'}:\r
- if type(Oprand1) != type(''):\r
+ if not isinstance(Oprand1, type('')):\r
Oprand1 = IntToStr(Oprand1)\r
- if type(Oprand2) != type(''):\r
+ if not isinstance(Oprand2, type('')):\r
Oprand2 = IntToStr(Oprand2)\r
TypeDict = {\r
type(0) : 0,\r
\r
EvalStr = ''\r
if Operator in {"!", "NOT", "not"}:\r
- if type(Oprand1) == type(''):\r
+ if isinstance(Oprand1, type('')):\r
raise BadExpression(ERR_STRING_EXPR % Operator)\r
EvalStr = 'not Oprand1'\r
elif Operator in {"~"}:\r
- if type(Oprand1) == type(''):\r
+ if isinstance(Oprand1, type('')):\r
raise BadExpression(ERR_STRING_EXPR % Operator)\r
EvalStr = '~ Oprand1'\r
else:\r
if Operator in {"+", "-"} and (type(True) in {type(Oprand1), type(Oprand2)}):\r
# Boolean in '+'/'-' will be evaluated but raise warning\r
WrnExp = WrnExpression(WRN_BOOL_EXPR)\r
- elif type('') in {type(Oprand1), type(Oprand2)} and type(Oprand1)!= type(Oprand2):\r
+ elif type('') in {type(Oprand1), type(Oprand2)} and not isinstance(Oprand1, type(Oprand2)):\r
# == between string and number/boolean will always return False, != return True\r
if Operator == "==":\r
WrnExp = WrnExpression(WRN_EQCMP_STR_OTHERS)\r
pass\r
else:\r
raise BadExpression(ERR_EXPR_TYPE)\r
- if type(Oprand1) == type('') and type(Oprand2) == type(''):\r
+ if isinstance(Oprand1, type('')) and isinstance(Oprand2, type('')):\r
if (Oprand1.startswith('L"') and not Oprand2.startswith('L"')) or \\r
(not Oprand1.startswith('L"') and Oprand2.startswith('L"')):\r
raise BadExpression(ERR_STRING_CMP % (Oprand1, Operator, Oprand2))\r
- if 'in' in Operator and type(Oprand2) == type(''):\r
+ if 'in' in Operator and isinstance(Oprand2, type('')):\r
Oprand2 = Oprand2.split()\r
EvalStr = 'Oprand1 ' + Operator + ' Oprand2'\r
\r
def __init__(self, Expression, SymbolTable={}):\r
super(ValueExpression, self).__init__(self, Expression, SymbolTable)\r
self._NoProcess = False\r
- if type(Expression) != type(''):\r
+ if not isinstance(Expression, type('')):\r
self._Expr = Expression\r
self._NoProcess = True\r
return\r
Token = self._GetToken()\r
except BadExpression:\r
pass\r
- if type(Token) == type('') and Token.startswith('{') and Token.endswith('}') and self._Idx >= self._Len:\r
+ if isinstance(Token, type('')) and Token.startswith('{') and Token.endswith('}') and self._Idx >= self._Len:\r
return self._Expr\r
\r
self._Idx = 0\r
\r
Val = self._ConExpr()\r
RealVal = Val\r
- if type(Val) == type(''):\r
+ if isinstance(Val, type('')):\r
if Val == 'L""':\r
Val = False\r
elif not Val:\r
Ex.Pcd = self._Token\r
raise Ex\r
self._Token = ValueExpression(self._Symb[self._Token], self._Symb)(True, self._Depth+1)\r
- if type(self._Token) != type(''):\r
+ if not isinstance(self._Token, type('')):\r
self._LiteralToken = hex(self._Token)\r
return\r
\r
if Ch == ')':\r
TmpValue = self._Expr[Idx :self._Idx - 1]\r
TmpValue = ValueExpression(TmpValue)(True)\r
- TmpValue = '0x%x' % int(TmpValue) if type(TmpValue) != type('') else TmpValue\r
+ TmpValue = '0x%x' % int(TmpValue) if not isinstance(TmpValue, type('')) else TmpValue\r
break\r
self._Token, Size = ParseFieldValue(Prefix + '(' + TmpValue + ')')\r
return self._Token\r
PcdValue = PcdValue.strip()\r
if PcdValue.startswith('{') and PcdValue.endswith('}'):\r
PcdValue = SplitPcdValueString(PcdValue[1:-1])\r
- if type(PcdValue) == type([]):\r
+ if isinstance(PcdValue, type([])):\r
TmpValue = 0\r
Size = 0\r
ValueType = ''\r
else:\r
ItemValue = ParseFieldValue(Item)[0]\r
\r
- if type(ItemValue) == type(''):\r
+ if isinstance(ItemValue, type('')):\r
ItemValue = int(ItemValue, 0)\r
\r
TmpValue = (ItemValue << (Size * 8)) | TmpValue\r
TmpValue, Size = ParseFieldValue(PcdValue)\r
except BadExpression as Value:\r
raise BadExpression("Type: %s, Value: %s, %s" % (self.PcdType, PcdValue, Value))\r
- if type(TmpValue) == type(''):\r
+ if isinstance(TmpValue, type('')):\r
try:\r
TmpValue = int(TmpValue)\r
except:\r
TmpValue = ValueExpressionEx(Item, ValueType, self._Symb)(True)\r
else:\r
TmpValue = ValueExpressionEx(Item, self.PcdType, self._Symb)(True)\r
- Item = '0x%x' % TmpValue if type(TmpValue) != type('') else TmpValue\r
+ Item = '0x%x' % TmpValue if not isinstance(TmpValue, type('')) else TmpValue\r
if ItemSize == 0:\r
ItemValue, ItemSize = ParseFieldValue(Item)\r
if Item[0] not in {'"', 'L', '{'} and ItemSize > 1:\r