- if (left.Type == TypeManager.uint64_type)
- return new ULongConstant (((ULongConstant)left).Value << lshift_val, left.Location);
- if (left.Type == TypeManager.int64_type)
- return new LongConstant (((LongConstant)left).Value << lshift_val, left.Location);
- if (left.Type == TypeManager.uint32_type)
- return new UIntConstant (((UIntConstant)left).Value << lshift_val, left.Location);
-
- left = left.ConvertImplicitly (TypeManager.int32_type);
- if (left.Type == TypeManager.int32_type)
- return new IntConstant (((IntConstant)left).Value << lshift_val, left.Location);
-
- Binary.Error_OperatorCannotBeApplied (left, right, oper, loc);
+ switch (left.Type.BuiltinType) {
+ case BuiltinTypeSpec.Type.ULong:
+ return new ULongConstant (ec.BuiltinTypes, ((ULongConstant) left).Value << lshift_val, left.Location);
+ case BuiltinTypeSpec.Type.Long:
+ return new LongConstant (ec.BuiltinTypes, ((LongConstant) left).Value << lshift_val, left.Location);
+ case BuiltinTypeSpec.Type.UInt:
+ return new UIntConstant (ec.BuiltinTypes, ((UIntConstant) left).Value << lshift_val, left.Location);
+ }
+
+ // null << value => null
+ if (left is NullLiteral)
+ return (Constant) new Binary (oper, left, right).ResolveOperator (ec);
+
+ left = left.ConvertImplicitly (ec.BuiltinTypes.Int);
+ if (left.Type.BuiltinType == BuiltinTypeSpec.Type.Int)
+ return new IntConstant (ec.BuiltinTypes, ((IntConstant) left).Value << lshift_val, left.Location);
+
+ Binary.Error_OperatorCannotBeApplied (ec, left, right, oper, loc);