public override IAnalysisSet BinaryOperation(Node node, AnalysisUnit unit, PythonOperator operation, IAnalysisSet rhs) { switch (operation) { case PythonOperator.GreaterThan: case PythonOperator.LessThan: case PythonOperator.LessThanOrEqual: case PythonOperator.GreaterThanOrEqual: case PythonOperator.Equal: case PythonOperator.NotEqual: case PythonOperator.Is: case PythonOperator.IsNot: return(ProjectState.ClassInfos[BuiltinTypeId.Bool].Instance); case PythonOperator.TrueDivide: case PythonOperator.Add: case PythonOperator.Subtract: case PythonOperator.Multiply: case PythonOperator.MatMultiply: case PythonOperator.Divide: case PythonOperator.Mod: case PythonOperator.BitwiseAnd: case PythonOperator.BitwiseOr: case PythonOperator.Xor: case PythonOperator.LeftShift: case PythonOperator.RightShift: case PythonOperator.Power: case PythonOperator.FloorDivide: return(ConstantInfo.NumericOp(node, this, unit, operation, rhs) ?? CallReverseBinaryOp(node, unit, operation, rhs)); } return(CallReverseBinaryOp(node, unit, operation, rhs)); }
public override IAnalysisSet BinaryOperation(Node node, AnalysisUnit unit, Parsing.PythonOperator operation, IAnalysisSet rhs) { var res = AnalysisSet.Empty; switch (operation) { case PythonOperator.Add: foreach (var type in rhs) { if (type.IsOfType(ClassInfo)) { res = res.Union(ClassInfo.Instance); } else { res = res.Union(type.ReverseBinaryOperation(node, unit, operation, SelfSet)); } } break; case PythonOperator.Mod: if (_supportsMod) { res = SelfSet; } break; case PythonOperator.Multiply: foreach (var type in rhs) { if (type.IsOfType(ProjectState.ClassInfos[BuiltinTypeId.Int]) || type.IsOfType(ProjectState.ClassInfos[BuiltinTypeId.Long])) { res = res.Union(ClassInfo.Instance); } else { var partialRes = ConstantInfo.NumericOp(node, this, unit, operation, rhs); if (partialRes != null) { res = res.Union(partialRes); } } } break; } if (res.Count == 0) { return(CallReverseBinaryOp(node, unit, operation, rhs)); } return(res); }
public override bool UnionEquals(Namespace ns) { ConstantInfo ci = ns as ConstantInfo; if (ci == null) { return(false); } else if (ci._value == _value) { return(true); } else if (_value == null) { return(false); } return(_value.GetType() == ci._value.GetType()); }
public override IAnalysisSet BinaryOperation(Node node, AnalysisUnit unit, PythonOperator operation, IAnalysisSet rhs) { return(ConstantInfo.NumericOp(node, this, unit, operation, rhs) ?? NumericOp(node, unit, operation, rhs) ?? AnalysisSet.Empty); }