Skip to content

Commit

Permalink
Un-ifdef object literals
Browse files Browse the repository at this point in the history
Swift SVN r32880
  • Loading branch information
gribozavr committed Oct 25, 2015
1 parent 9383927 commit 2e51d23
Show file tree
Hide file tree
Showing 35 changed files with 0 additions and 104 deletions.
4 changes: 0 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ option(SWIFT_ENABLE_TARGET_TVOS
"Enable compiler support for targeting tvOS"
TRUE)

option(SWIFT_ENABLE_OBJECT_LITERALS
"Enable compiler support for object literals"
TRUE)

set(SWIFT_VERSION "2.1" CACHE STRING
"The user-visible version of the Swift compiler")
set(SWIFT_VENDOR "" CACHE STRING
Expand Down
4 changes: 0 additions & 4 deletions cmake/modules/AddSwift.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,6 @@ function(_add_variant_swift_compile_flags
list(APPEND result "-D" "INTERNAL_CHECKS_ENABLED")
endif()

if(SWIFT_ENABLE_OBJECT_LITERALS)
list(APPEND result "-D" "SWIFT_ENABLE_OBJECT_LITERALS")
endif()

set("${result_var_name}" "${result}" PARENT_SCOPE)
endfunction()

Expand Down
2 changes: 0 additions & 2 deletions include/swift/AST/DiagnosticsParse.def
Original file line number Diff line number Diff line change
Expand Up @@ -992,15 +992,13 @@ ERROR(expected_rsquare_expr_list,expr_parsing,none,
ERROR(expected_rsquare_array_expr,expr_parsing,PointsToFirstBadToken,
"expected ']' in container literal expression", ())

#ifdef SWIFT_ENABLE_OBJECT_LITERALS
// Object literal expressions
ERROR(expected_identifier_after_l_square_lit,expr_parsing,none,
"expected identifier after '[#' in object literal expression", ())
ERROR(expected_arg_list_in_object_literal,expr_parsing,none,
"expected argument list in object literal", ())
ERROR(expected_r_square_lit_after_object_literal,expr_parsing,none,
"expected '#]' at end of object literal expression", ())
#endif // SWIFT_ENABLE_OBJECT_LITERALS

// If expressions
ERROR(expected_expr_after_if_question,expr_parsing,none,
Expand Down
4 changes: 0 additions & 4 deletions include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -435,10 +435,8 @@ ERROR(pattern_used_in_type,sema_nb,none,
NOTE(note_module_as_type,sema_nb,none,
"cannot use module %0 as a type", (Identifier))

#ifdef SWIFT_ENABLE_OBJECT_LITERALS
ERROR(use_unknown_object_literal,sema_nb,none,
"use of unknown object literal name %0", (Identifier))
#endif // SWIFT_ENABLE_OBJECT_LITERALS

ERROR(use_non_type_value,sema_nb,none,
"%0 is not a type", (Identifier))
Expand Down Expand Up @@ -1744,10 +1742,8 @@ ERROR(interpolation_broken_proto,sema_tce,none,
"protocol 'StringInterpolationConvertible' is broken",
())

#ifdef SWIFT_ENABLE_OBJECT_LITERALS
ERROR(object_literal_broken_proto,sema_tce,none,
"object literal protocol is broken", ())
#endif // SWIFT_ENABLE_OBJECT_LITERALS

ERROR(discard_expr_outside_of_assignment,sema_tce,none,
"'_' can only appear in a pattern or on the left side of an assignment",
Expand Down
2 changes: 0 additions & 2 deletions include/swift/AST/Expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,6 @@ class MagicIdentifierLiteralExpr : public LiteralExpr {
}
};

#ifdef SWIFT_ENABLE_OBJECT_LITERALS
// ObjectLiteralExpr - An expression of the form
// '[#Color(red: 1, blue: 0, green: 0, alpha: 1)#]' with a name and a list
// argument. The components of the list argument are meant to be themselves
Expand Down Expand Up @@ -870,7 +869,6 @@ class ObjectLiteralExpr : public LiteralExpr {
return E->getKind() == ExprKind::ObjectLiteral;
}
};
#endif // SWIFT_ENABLE_OBJECT_LITERALS

/// DiscardAssignmentExpr - A '_' in the left-hand side of an assignment, which
/// discards the corresponding tuple element on the right-hand side.
Expand Down
2 changes: 0 additions & 2 deletions include/swift/AST/ExprNodes.def
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ ABSTRACT_EXPR(Literal, Expr)
EXPR(BooleanLiteral, LiteralExpr)
EXPR(StringLiteral, LiteralExpr)
EXPR(InterpolatedStringLiteral, LiteralExpr)
#ifdef SWIFT_ENABLE_OBJECT_LITERALS
EXPR(ObjectLiteral, LiteralExpr)
#endif // SWIFT_ENABLE_OBJECT_LITERALS
EXPR(MagicIdentifierLiteral, LiteralExpr)
EXPR_RANGE(Literal, NilLiteral, MagicIdentifierLiteral)
EXPR(DiscardAssignment, Expr)
Expand Down
2 changes: 0 additions & 2 deletions include/swift/AST/KnownProtocols.def
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,9 @@ LITERAL_CONVERTIBLE_PROTOCOL(StringLiteralConvertible, string)
LITERAL_CONVERTIBLE_PROTOCOL(NilLiteralConvertible, nil)
LITERAL_CONVERTIBLE_PROTOCOL(UnicodeScalarLiteralConvertible, character)

#ifdef SWIFT_ENABLE_OBJECT_LITERALS
LITERAL_CONVERTIBLE_PROTOCOL(_ColorLiteralConvertible, color)
LITERAL_CONVERTIBLE_PROTOCOL(_ImageLiteralConvertible, image)
LITERAL_CONVERTIBLE_PROTOCOL(_FileReferenceLiteralConvertible, file-reference)
#endif // SWIFT_ENABLE_OBJECT_LITERALS

BUILTIN_LITERAL_CONVERTIBLE_PROTOCOL(_BuiltinBooleanLiteralConvertible)
BUILTIN_LITERAL_CONVERTIBLE_PROTOCOL(_BuiltinExtendedGraphemeClusterLiteralConvertible)
Expand Down
1 change: 0 additions & 1 deletion include/swift/Config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#ifndef SWIFT_CONFIG_H
#define SWIFT_CONFIG_H

#cmakedefine SWIFT_ENABLE_OBJECT_LITERALS 1
#cmakedefine SWIFT_ENABLE_TARGET_TVOS 1
#cmakedefine SWIFT_HAVE_WORKING_STD_REGEX 1

Expand Down
4 changes: 0 additions & 4 deletions include/swift/IDE/SyntaxModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,8 @@ enum class SyntaxNodeKind : uint8_t {
AttributeBuiltin,
/// An editor placeholder string <#like this#>.
EditorPlaceholder,
#ifdef SWIFT_ENABLE_OBJECT_LITERALS
/// An editor object literal [#like(this)#]
ObjectLiteral
#endif // SWIFT_ENABLE_OBJECT_LITERALS
};

struct SyntaxNode {
Expand Down Expand Up @@ -108,9 +106,7 @@ enum class SyntaxStructureKind : uint8_t {
CallExpression,
ArrayExpression,
DictionaryExpression,
#ifdef SWIFT_ENABLE_OBJECT_LITERALS
ObjectLiteralExpression,
#endif // SWIFT_ENABLE_OBJECT_LITERALS
};

enum class SyntaxStructureElementKind : uint8_t {
Expand Down
2 changes: 0 additions & 2 deletions include/swift/Parse/Parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -1145,9 +1145,7 @@ class Parser {

Expr *parseExprAnonClosureArg();
ParserResult<Expr> parseExprList(tok LeftTok, tok RightTok);
#ifdef SWIFT_ENABLE_OBJECT_LITERALS
ParserResult<Expr> parseExprObjectLiteral();
#endif // SWIFT_ENABLE_OBJECT_LITERALS
ParserResult<Expr> parseExprCallSuffix(ParserResult<Expr> fn,
Identifier firstSelectorPiece
= Identifier(),
Expand Down
2 changes: 0 additions & 2 deletions include/swift/Parse/Tokens.def
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,8 @@ PUNCTUATOR(r_brace, "}")
PUNCTUATOR(l_square, "[")
PUNCTUATOR(r_square, "]")

#ifdef SWIFT_ENABLE_OBJECT_LITERALS
PUNCTUATOR(l_square_lit, "[#")
PUNCTUATOR(r_square_lit, "#]")
#endif // SWIFT_ENABLE_OBJECT_LITERALS

PUNCTUATOR(period, ".")
PUNCTUATOR(period_prefix, ".")
Expand Down
2 changes: 0 additions & 2 deletions lib/AST/ASTDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1473,14 +1473,12 @@ class PrintExpr : public ExprVisitor<PrintExpr> {
OS << ')';
}

#ifdef SWIFT_ENABLE_OBJECT_LITERALS
void visitObjectLiteralExpr(ObjectLiteralExpr *E) {
printCommon(E, "object_literal")
<< " name=" << E->getName().str();
OS << '\n';
printRec(E->getArg());
}
#endif // SWIFT_ENABLE_OBJECT_LITERALS

void visitDiscardAssignmentExpr(DiscardAssignmentExpr *E) {
printCommon(E, "discard_assignment_expr") << ')';
Expand Down
2 changes: 0 additions & 2 deletions lib/AST/ASTWalker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,6 @@ class Traversal : public ASTVisitor<Traversal, Expr*, Stmt*,
return E;
}

#ifdef SWIFT_ENABLE_OBJECT_LITERALS
Expr *visitObjectLiteralExpr(ObjectLiteralExpr *E) {
HANDLE_SEMANTIC_EXPR(E);

Expand All @@ -401,7 +400,6 @@ class Traversal : public ASTVisitor<Traversal, Expr*, Stmt*,
}
return E;
}
#endif // SWIFT_ENABLE_OBJECT_LITERALS

Expr *visitCollectionExpr(CollectionExpr *E) {
HANDLE_SEMANTIC_EXPR(E);
Expand Down
6 changes: 0 additions & 6 deletions lib/AST/Expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,10 +488,8 @@ bool Expr::canAppendCallParentheses() const {
case ExprKind::MagicIdentifierLiteral:
return true;

#ifdef SWIFT_ENABLE_OBJECT_LITERALS
case ExprKind::ObjectLiteral:
return true;
#endif // SWIFT_ENABLE_OBJECT_LITERALS

case ExprKind::DiscardAssignment:
// Legal but pointless.
Expand Down Expand Up @@ -738,7 +736,6 @@ shallowCloneImpl(const MagicIdentifierLiteralExpr *E, ASTContext &Ctx) {
return res;
}

#ifdef SWIFT_ENABLE_OBJECT_LITERALS
static LiteralExpr *
shallowCloneImpl(const ObjectLiteralExpr *E, ASTContext &Ctx) {
auto res = new (Ctx) ObjectLiteralExpr(E->getStartLoc(), E->getName(),
Expand All @@ -747,7 +744,6 @@ shallowCloneImpl(const ObjectLiteralExpr *E, ASTContext &Ctx) {
res->setSemanticExpr(E->getSemanticExpr());
return res;
}
#endif

// Make an exact copy of this AST node.
LiteralExpr *LiteralExpr::shallowClone(ASTContext &Ctx) const {
Expand All @@ -765,9 +761,7 @@ LiteralExpr *LiteralExpr::shallowClone(ASTContext &Ctx) const {
DISPATCH_CLONE(BooleanLiteral)
DISPATCH_CLONE(StringLiteral)
DISPATCH_CLONE(InterpolatedStringLiteral)
#ifdef SWIFT_ENABLE_OBJECT_LITERALS
DISPATCH_CLONE(ObjectLiteral)
#endif // SWIFT_ENABLE_OBJECT_LITERALS
DISPATCH_CLONE(MagicIdentifierLiteral)
#undef DISPATCH_CLONE
}
Expand Down
8 changes: 0 additions & 8 deletions lib/IDE/SyntaxModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ SyntaxModelContext::SyntaxModelContext(SourceFile &SrcFile)
Loc = Tok.getLoc();
Length = Tok.getLength();

#ifdef SWIFT_ENABLE_OBJECT_LITERALS
if (LiteralStartLoc.hasValue() && Length.hasValue()) {
// We are still inside an object literal until we hit a r_square_lit.
if (Tok.getKind() != tok::r_square_lit) {
Expand All @@ -93,7 +92,6 @@ SyntaxModelContext::SyntaxModelContext(SourceFile &SrcFile)
LiteralStartLoc = Optional<SourceLoc>();
continue;
}
#endif // SWIFT_ENABLE_OBJECT_LITERALS

switch(Tok.getKind()) {
#define KEYWORD(X) case tok::kw_##X: Kind = SyntaxNodeKind::Keyword; break;
Expand Down Expand Up @@ -156,12 +154,10 @@ SyntaxModelContext::SyntaxModelContext(SourceFile &SrcFile)
break;
}

#ifdef SWIFT_ENABLE_OBJECT_LITERALS
case tok::l_square_lit: {
LiteralStartLoc = Loc;
continue;
}
#endif // SWIFT_ENABLE_OBJECT_LITERALS

default:
continue;
Expand Down Expand Up @@ -454,7 +450,6 @@ std::pair<bool, Expr *> ModelASTWalker::walkToExprPre(Expr *E) {
CE->getArg()->getSourceRange());
pushStructureNode(SN, CE);

#ifdef SWIFT_ENABLE_OBJECT_LITERALS
} else if (auto *ObjectE = dyn_cast<ObjectLiteralExpr>(E)) {
SyntaxStructureNode SN;
SN.Kind = SyntaxStructureKind::ObjectLiteralExpression;
Expand All @@ -464,7 +459,6 @@ std::pair<bool, Expr *> ModelASTWalker::walkToExprPre(Expr *E) {
SN.NameRange = CharSourceRange(SM, NRStart, NREnd);
SN.BodyRange = innerCharSourceRangeFromSourceRange(SM, E->getSourceRange());
pushStructureNode(SN, E);
#endif // SWIFT_ENABLE_OBJECT_LITERALS

} else if (auto *ArrayE = dyn_cast<ArrayExpr>(E)) {
SyntaxStructureNode SN;
Expand Down Expand Up @@ -1247,12 +1241,10 @@ bool ModelASTWalker::isCurrentCallArgExpr(const Expr *E) {
return false;
auto Current = SubStructureStack.back();

#ifdef SWIFT_ENABLE_OBJECT_LITERALS
if (Current.StructureNode.Kind ==
SyntaxStructureKind::ObjectLiteralExpression &&
cast<ObjectLiteralExpr>(Current.ASTNode.getAsExpr())->getArg() == E)
return true;
#endif // SWIFT_ENABLE_OBJECT_LITERALS

return Current.StructureNode.Kind == SyntaxStructureKind::CallExpression &&
cast<CallExpr>(Current.ASTNode.getAsExpr())->getArg() == E;
Expand Down
2 changes: 0 additions & 2 deletions lib/IRGen/GenMeta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4793,11 +4793,9 @@ SpecialProtocol irgen::getSpecialProtocolID(ProtocolDecl *P) {
case KnownProtocolKind::StringLiteralConvertible:
case KnownProtocolKind::NilLiteralConvertible:
case KnownProtocolKind::UnicodeScalarLiteralConvertible:
#ifdef SWIFT_ENABLE_OBJECT_LITERALS
case KnownProtocolKind::_ColorLiteralConvertible:
case KnownProtocolKind::_ImageLiteralConvertible:
case KnownProtocolKind::_FileReferenceLiteralConvertible:
#endif // SWIFT_ENABLE_OBJECT_LITERALS
case KnownProtocolKind::_BuiltinBooleanLiteralConvertible:
case KnownProtocolKind::_BuiltinExtendedGraphemeClusterLiteralConvertible:
case KnownProtocolKind::_BuiltinFloatLiteralConvertible:
Expand Down
4 changes: 0 additions & 4 deletions lib/Parse/Lexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1495,12 +1495,10 @@ void Lexer::lexImpl() {
case '@': return formToken(tok::at_sign, TokStart);
case '{': return formToken(tok::l_brace, TokStart);
case '[': {
#ifdef SWIFT_ENABLE_OBJECT_LITERALS
if (*CurPtr == '#') { // [#
CurPtr++;
return formToken(tok::l_square_lit, TokStart);
}
#endif // SWIFT_ENABLE_OBJECT_LITERALS
return formToken(tok::l_square, TokStart);
}
case '(': return formToken(tok::l_paren, TokStart);
Expand All @@ -1514,12 +1512,10 @@ void Lexer::lexImpl() {
case ':': return formToken(tok::colon, TokStart);

case '#': {
#ifdef SWIFT_ENABLE_OBJECT_LITERALS
if (*CurPtr == ']') { // #]
CurPtr++;
return formToken(tok::r_square_lit, TokStart);
}
#endif // SWIFT_ENABLE_OBJECT_LITERALS

if (getSubstring(TokStart + 1, 2).equals("if") &&
isWhitespace(CurPtr[2])) {
Expand Down
4 changes: 0 additions & 4 deletions lib/Parse/ParseExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -949,11 +949,9 @@ ParserResult<Expr> Parser::parseExprPostfix(Diag<> ID, bool isExprBasic) {
Result = parseExprCollection();
break;

#ifdef SWIFT_ENABLE_OBJECT_LITERALS
case tok::l_square_lit: // [#Color(...)#], [#Image(...)#]
Result = parseExprObjectLiteral();
break;
#endif // SWIFT_ENABLE_OBJECT_LITERALS

case tok::pound_available: {
// For better error recovery, parse but reject #available in an expr
Expand Down Expand Up @@ -2077,7 +2075,6 @@ ParserResult<Expr> Parser::parseExprList(tok LeftTok, tok RightTok) {
/*Implicit=*/false));
}

#ifdef SWIFT_ENABLE_OBJECT_LITERALS
/// \brief Parse an object literal expression.
///
/// expr-literal:
Expand Down Expand Up @@ -2113,7 +2110,6 @@ Parser::parseExprObjectLiteral() {
new (Context) ObjectLiteralExpr(LLitLoc, Name, NameLoc, Arg.get(), RLitLoc,
/*implicit=*/false));
}
#endif // SWIFT_ENABLE_OBJECT_LITERALS

/// \brief Parse an expression call suffix.
///
Expand Down
4 changes: 0 additions & 4 deletions lib/SILGen/SILGenExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,7 @@ namespace {
RValue visitAbstractClosureExpr(AbstractClosureExpr *E, SGFContext C);
RValue visitInterpolatedStringLiteralExpr(InterpolatedStringLiteralExpr *E,
SGFContext C);
#ifdef SWIFT_ENABLE_OBJECT_LITERALS
RValue visitObjectLiteralExpr(ObjectLiteralExpr *E, SGFContext C);
#endif // SWIFT_ENABLE_OBJECT_LITERALS
RValue visitMagicIdentifierLiteralExpr(MagicIdentifierLiteralExpr *E,
SGFContext C);
RValue visitCollectionExpr(CollectionExpr *E, SGFContext C);
Expand Down Expand Up @@ -1973,12 +1971,10 @@ visitInterpolatedStringLiteralExpr(InterpolatedStringLiteralExpr *E,
return visit(E->getSemanticExpr(), C);
}

#ifdef SWIFT_ENABLE_OBJECT_LITERALS
RValue RValueEmitter::
visitObjectLiteralExpr(ObjectLiteralExpr *E, SGFContext C) {
return visit(E->getSemanticExpr(), C);
}
#endif // SWIFT_ENABLE_OBJECT_LITERALS

static StringRef
getMagicFunctionString(SILGenFunction &gen) {
Expand Down
2 changes: 0 additions & 2 deletions lib/Sema/CSApply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2006,7 +2006,6 @@ namespace {
}
}

#ifdef SWIFT_ENABLE_OBJECT_LITERALS
Expr *visitObjectLiteralExpr(ObjectLiteralExpr *expr) {
if (expr->getType() && !expr->getType()->hasTypeVariable())
return expr;
Expand Down Expand Up @@ -2046,7 +2045,6 @@ namespace {
expr->setSemanticExpr(semanticExpr);
return expr;
}
#endif // SWIFT_ENABLE_OBJECT_LITERALS

/// \brief Retrieve the type of a reference to the given declaration.
Type getTypeOfDeclReference(ValueDecl *decl, bool isSpecialized) {
Expand Down
2 changes: 0 additions & 2 deletions lib/Sema/CSDiag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ void constraints::simplifyLocator(Expr *&anchor,
continue;
}

#ifdef SWIFT_ENABLE_OBJECT_LITERALS
if (auto objectLiteralExpr = dyn_cast<ObjectLiteralExpr>(anchor)) {
targetAnchor = nullptr;
targetPath.clear();
Expand All @@ -149,7 +148,6 @@ void constraints::simplifyLocator(Expr *&anchor,
path = path.slice(1);
continue;
}
#endif // SWIFT_ENABLE_OBJECT_LITERALS
break;

case ConstraintLocator::ApplyFunction:
Expand Down
Loading

0 comments on commit 2e51d23

Please sign in to comment.