mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
analysis for patterns. Major changes: 1. We no longer try to compute the types of functions in the parser. 2. The type of a function always matches the type of the argument patterns. 3. Every FuncDecl now has a corresponding FuncExpr; that FuncExpr might not have a body, though. 4. We now use a new class "ExprHandle" so that both a pattern and a type can hold a reference to the same expression. Hopefully this will be a more reasonable foundation for further changes to how we compute the types of FuncDecls in generics and for the implementation of type location information. Swift SVN r2370
53 lines
1.4 KiB
C++
53 lines
1.4 KiB
C++
//===--- ExprHandle.h - Swift Expression Handle -----------------*- C++ -*-===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See http://swift.org/LICENSE.txt for license information
|
|
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file defines the ExprHandle class.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef SWIFT_EXPRHANDLE_H
|
|
#define SWIFT_EXPRHANDLE_H
|
|
|
|
#include "llvm/Support/DataTypes.h"
|
|
|
|
namespace swift {
|
|
class ASTContext;
|
|
class Expr;
|
|
|
|
/// ExprHandle - Provides an indirection for expressions, so both a type and a
|
|
/// pattern can point at the same expression during type-checking.
|
|
class ExprHandle {
|
|
Expr *E;
|
|
private:
|
|
ExprHandle(Expr *E) : E(E) {}
|
|
|
|
void *operator new(size_t Bytes) throw() = delete;
|
|
void operator delete(void *Data) throw() = delete;
|
|
void *operator new(size_t Bytes, void *Mem) throw() = delete;
|
|
void *operator new(size_t Bytes, ASTContext &C,
|
|
unsigned Alignment = 8);
|
|
public:
|
|
Expr *getExpr() {
|
|
return E;
|
|
}
|
|
|
|
void setExpr(Expr *newE) {
|
|
E = newE;
|
|
}
|
|
|
|
static ExprHandle *get(ASTContext &Context, Expr *E);
|
|
};
|
|
|
|
} // end namespace swift
|
|
|
|
#endif
|