File: ldcbindings.h

package info (click to toggle)
ldc 1:1.12.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 80,880 kB
  • sloc: ansic: 123,899; cpp: 84,038; sh: 1,402; makefile: 1,083; asm: 919; objc: 65; exp: 30; python: 22
file content (76 lines) | stat: -rw-r--r-- 3,105 bytes parent folder | download
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
65
66
67
68
69
70
71
72
73
74
75
76
//===-- ldcbindings.h -----------------------------------------------------===//
//
//                         LDC – the LLVM D compiler
//
// This file is distributed under the BSD-style LDC license. See the LICENSE
// file for details.
//
//===----------------------------------------------------------------------===//

#ifndef LDC_DDMD_LDCBINDINGS_H
#define LDC_DDMD_LDCBINDINGS_H

#include "expression.h"
#include <cstdint>

using uint = uint32_t;

// Classes
IntegerExp *createIntegerExp(const Loc &loc, dinteger_t value, Type *type);
IntegerExp *createIntegerExp(dinteger_t value);
EqualExp *createEqualExp(TOK, const Loc &, Expression *, Expression *);
CmpExp *createCmpExp(TOK, const Loc &, Expression *, Expression *);
ShlExp *createShlExp(const Loc &, Expression *, Expression *);
ShrExp *createShrExp(const Loc &, Expression *, Expression *);
UshrExp *createUshrExp(const Loc &, Expression *, Expression *);
LogicalExp *createLogicalExp(const Loc &, TOK op, Expression *, Expression *);
OrExp *createOrExp(const Loc &, Expression *, Expression *);
AndExp *createAndExp(const Loc &, Expression *, Expression *);
XorExp *createXorExp(const Loc &, Expression *, Expression *);
ModExp *createModExp(const Loc &, Expression *, Expression *);
MulExp *createMulExp(const Loc &, Expression *, Expression *);
DivExp *createDivExp(const Loc &, Expression *, Expression *);
AddExp *createAddExp(const Loc &, Expression *, Expression *);
MinExp *createMinExp(const Loc &, Expression *, Expression *);
RealExp *createRealExp(const Loc &, real_t, Type *);
NotExp *createNotExp(const Loc &, Expression *);
ComExp *createComExp(const Loc &, Expression *);
NegExp *createNegExp(const Loc &, Expression *);
AddrExp *createAddrExp(const Loc &, Expression *);
DsymbolExp *createDsymbolExp(const Loc &, Dsymbol *, bool = false);
Expression *createExpression(const Loc &loc, TOK op, int size);
TypeDelegate *createTypeDelegate(Type *t);
TypeIdentifier *createTypeIdentifier(const Loc &loc, Identifier *ident);

// Structs
//Loc createLoc(const char * filename, uint linnum, uint charnum);

/*
 * Define bindD<Type>::create(...) templated functions, to create D objects in templated code (class type is template parameter).
 * Used e.g. in toir.cpp
 */
template <class T> struct bindD {
  template <typename... Args> T *create(Args...) {
    assert(0 && "newD<> not implemented for this type");
  }
};
#define NEWD_TEMPLATE(T)                                                       \
  template <> struct bindD<T> {                                                \
    template <typename... Args> static T *create(Args... args) {               \
      return create##T(args...);                                               \
    }                                                                          \
  };
NEWD_TEMPLATE(ShlExp)
NEWD_TEMPLATE(ShrExp)
NEWD_TEMPLATE(UshrExp)
NEWD_TEMPLATE(LogicalExp)
NEWD_TEMPLATE(OrExp)
NEWD_TEMPLATE(AndExp)
NEWD_TEMPLATE(XorExp)
NEWD_TEMPLATE(ModExp)
NEWD_TEMPLATE(MulExp)
NEWD_TEMPLATE(DivExp)
NEWD_TEMPLATE(AddExp)
NEWD_TEMPLATE(MinExp)

#endif // LDC_DDMD_LDCBINDINGS_H