aboutsummaryrefslogtreecommitdiff
path: root/gcc/d/dmd/ctfe.h
blob: ab022ff505e76ae31cff2e3ff92c0c98d8ca1c07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64

/* Compiler implementation of the D programming language
 * Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
 * written by Walter Bright
 * https://www.digitalmars.com
 * Distributed under the Boost Software License, Version 1.0.
 * https://www.boost.org/LICENSE_1_0.txt
 * https://github.com/dlang/dmd/blob/master/src/dmd/ctfe.h
 */

#pragma once

#include "tokens.h"
#include "expression.h"

/**
  A reference to a class, or an interface. We need this when we
  point to a base class (we must record what the type is).
 */
class ClassReferenceExp final : public Expression
{
public:
    StructLiteralExp *value;
    ClassDeclaration *originalClass();

    /// Return index of the field, or -1 if not found
    /// Same as getFieldIndex, but checks for a direct match with the VarDeclaration
    int findFieldIndexByName(VarDeclaration *v);
    void accept(Visitor *v) override { v->visit(this); }
};

/**
  An uninitialized value
 */
class VoidInitExp final : public Expression
{
public:
    VarDeclaration *var;

    const char *toChars() const override;
    void accept(Visitor *v) override { v->visit(this); }
};

/**
  Fake class which holds the thrown exception.
  Used for implementing exception handling.
*/
class ThrownExceptionExp final : public Expression
{
public:
    ClassReferenceExp *thrown; // the thing being tossed
    const char *toChars() const override;
    void accept(Visitor *v) override { v->visit(this); }
};

/****************************************************************/

// This type is only used by the interpreter.

class CTFEExp final : public Expression
{
public:
    const char *toChars() const override;
};