Skip to content

Commit

Permalink
create apply
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Jan 2, 2012
1 parent 3912454 commit 7fbceaa
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 12 deletions.
17 changes: 16 additions & 1 deletion src/expression.h
Expand Up @@ -62,6 +62,8 @@ struct elem;

void initPrecedence();

typedef int (*apply_fp_t)(Expression *, void *);

Expression *resolveProperties(Scope *sc, Expression *e);
void accessCheck(Loc loc, Scope *sc, Expression *e, Declaration *d);
Expression *build_overload(Loc loc, Scope *sc, Expression *ethis, Expression *earg, Dsymbol *d);
Expand Down Expand Up @@ -100,6 +102,7 @@ struct Expression : Object
Expression(Loc loc, enum TOK op, int size);
Expression *copy();
virtual Expression *syntaxCopy();
virtual int apply(apply_fp_t fp, void *param);
virtual Expression *semantic(Scope *sc);
Expression *trySemantic(Scope *sc);

Expand Down Expand Up @@ -399,6 +402,7 @@ struct TupleExp : Expression
TupleExp(Loc loc, Expressions *exps);
TupleExp(Loc loc, TupleDeclaration *tup);
Expression *syntaxCopy();
int apply(apply_fp_t fp, void *param);
int equals(Object *o);
Expression *semantic(Scope *sc);
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
Expand All @@ -425,6 +429,7 @@ struct ArrayLiteralExp : Expression
ArrayLiteralExp(Loc loc, Expression *e);

Expression *syntaxCopy();
int apply(apply_fp_t fp, void *param);
Expression *semantic(Scope *sc);
int isBool(int result);
elem *toElem(IRState *irs);
Expand Down Expand Up @@ -454,6 +459,7 @@ struct AssocArrayLiteralExp : Expression
AssocArrayLiteralExp(Loc loc, Expressions *keys, Expressions *values);

Expression *syntaxCopy();
int apply(apply_fp_t fp, void *param);
Expression *semantic(Scope *sc);
int isBool(int result);
elem *toElem(IRState *irs);
Expand Down Expand Up @@ -487,6 +493,7 @@ struct StructLiteralExp : Expression
StructLiteralExp(Loc loc, StructDeclaration *sd, Expressions *elements, Type *stype = NULL);

Expression *syntaxCopy();
int apply(apply_fp_t fp, void *param);
Expression *semantic(Scope *sc);
Expression *getField(Type *type, unsigned offset);
int getFieldIndex(Type *type, unsigned offset);
Expand Down Expand Up @@ -557,6 +564,7 @@ struct NewExp : Expression
NewExp(Loc loc, Expression *thisexp, Expressions *newargs,
Type *newtype, Expressions *arguments);
Expression *syntaxCopy();
int apply(apply_fp_t fp, void *param);
Expression *semantic(Scope *sc);
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
Expression *optimize(int result);
Expand All @@ -583,6 +591,7 @@ struct NewAnonClassExp : Expression
NewAnonClassExp(Loc loc, Expression *thisexp, Expressions *newargs,
ClassDeclaration *cd, Expressions *arguments);
Expression *syntaxCopy();
int apply(apply_fp_t fp, void *param);
Expression *semantic(Scope *sc);
int checkSideEffect(int flag);
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
Expand Down Expand Up @@ -771,6 +780,7 @@ struct UnaExp : Expression

UnaExp(Loc loc, enum TOK op, int size, Expression *e1);
Expression *syntaxCopy();
int apply(apply_fp_t fp, void *param);
Expression *semantic(Scope *sc);
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
Expression *optimize(int result);
Expand All @@ -795,6 +805,7 @@ struct BinExp : Expression

BinExp(Loc loc, enum TOK op, int size, Expression *e1, Expression *e2);
Expression *syntaxCopy();
int apply(apply_fp_t fp, void *param);
Expression *semantic(Scope *sc);
Expression *semanticp(Scope *sc);
int checkSideEffect(int flag);
Expand Down Expand Up @@ -965,6 +976,7 @@ struct CallExp : UnaExp
CallExp(Loc loc, Expression *e, Expression *earg1, Expression *earg2);

Expression *syntaxCopy();
int apply(apply_fp_t fp, void *param);
Expression *resolveUFCS(Scope *sc);
Expression *semantic(Scope *sc);
Expression *optimize(int result);
Expand Down Expand Up @@ -1121,6 +1133,7 @@ struct SliceExp : UnaExp

SliceExp(Loc loc, Expression *e1, Expression *lwr, Expression *upr);
Expression *syntaxCopy();
int apply(apply_fp_t fp, void *param);
Expression *semantic(Scope *sc);
void checkEscape();
void checkEscapeRef();
Expand Down Expand Up @@ -1165,6 +1178,7 @@ struct ArrayExp : UnaExp

ArrayExp(Loc loc, Expression *e1, Expressions *arguments);
Expression *syntaxCopy();
int apply(apply_fp_t fp, void *param);
Expression *semantic(Scope *sc);
int isLvalue();
Expression *toLvalue(Scope *sc, Expression *e);
Expand Down Expand Up @@ -1419,7 +1433,7 @@ struct PowExp : BinExp
// For operator overloading
Identifier *opId();
Identifier *opId_r();

elem *toElem(IRState *irs);
};
#endif
Expand Down Expand Up @@ -1625,6 +1639,7 @@ struct CondExp : BinExp

CondExp(Loc loc, Expression *econd, Expression *e1, Expression *e2);
Expression *syntaxCopy();
int apply(apply_fp_t fp, void *param);
Expression *semantic(Scope *sc);
Expression *optimize(int result);
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
Expand Down
8 changes: 6 additions & 2 deletions src/posix.mak
Expand Up @@ -83,7 +83,7 @@ DMD_OBJS = \
hdrgen.o delegatize.o aa.o ti_achar.o toir.o interpret.o traits.o \
builtin.o clone.o aliasthis.o intrange.o \
man.o arrayop.o port.o response.o async.o json.o speller.o aav.o unittests.o \
imphint.o argtypes.o ti_pvoid.o
imphint.o argtypes.o ti_pvoid.o apply.o

ifeq (OSX,$(TARGET))
DMD_OBJS += libmach.o machobj.o
Expand All @@ -108,7 +108,7 @@ SRC = win32.mak posix.mak \
delegatize.c toir.h toir.c interpret.c traits.c cppmangle.c \
builtin.c clone.c lib.h libomf.c libelf.c libmach.c arrayop.c \
aliasthis.h aliasthis.c json.h json.c unittests.c imphint.c \
argtypes.c intrange.c \
argtypes.c intrange.c apply.c \
$C/cdef.h $C/cc.h $C/oper.h $C/ty.h $C/optabgen.c \
$C/global.h $C/code.h $C/type.h $C/dt.h $C/cgcv.h \
$C/el.h $C/iasm.h $C/rtlsym.h $C/html.h \
Expand Down Expand Up @@ -192,6 +192,9 @@ access.o: access.c
aliasthis.o: aliasthis.c
$(CC) -c $(CFLAGS) $<

apply.o: apply.c
$(CC) -c $(CFLAGS) $<

argtypes.o: argtypes.c
$(CC) -c $(CFLAGS) $<

Expand Down Expand Up @@ -584,6 +587,7 @@ version.o: version.c
gcov:
gcov access.c
gcov aliasthis.c
gcov apply.c
gcov arrayop.c
gcov attrib.c
gcov builtin.c
Expand Down
6 changes: 4 additions & 2 deletions src/win32.mak
Expand Up @@ -85,7 +85,7 @@ OBJ1= mars.obj enum.obj struct.obj dsymbol.obj import.obj id.obj \
builtin.obj clone.obj libomf.obj arrayop.obj irstate.obj \
glue.obj msc.obj ph.obj tk.obj s2ir.obj todt.obj e2ir.obj tocsym.obj \
util.obj eh.obj toobj.obj toctype.obj tocvdebug.obj toir.obj \
json.obj unittests.obj imphint.obj argtypes.obj
json.obj unittests.obj imphint.obj argtypes.obj apply.obj

# from C/C++ compiler optimizer and back end

Expand Down Expand Up @@ -124,7 +124,8 @@ SRCS= mars.c enum.c struct.c dsymbol.c import.c idgen.c impcnvgen.c utf.h \
macro.h macro.c hdrgen.h hdrgen.c arraytypes.h \
delegatize.c toir.h toir.c interpret.c traits.c builtin.c \
clone.c lib.h libomf.c libelf.c libmach.c arrayop.c intrange.c \
aliasthis.h aliasthis.c json.h json.c unittests.c imphint.c argtypes.c
aliasthis.h aliasthis.c json.h json.c unittests.c imphint.c argtypes.c \
apply.c

# From C++ compiler

Expand Down Expand Up @@ -472,6 +473,7 @@ win32.obj : $(ROOT)\gc\os.h $(ROOT)\gc\win32.c

access.obj : $(TOTALH) enum.h aggregate.h init.h attrib.h access.c
aliasthis.obj : $(TOTALH) aliasthis.h aliasthis.c
apply.obj : $(TOTALH) apply.c
argtypes.obj : $(TOTALH) mtype.h argtypes.c
arrayop.obj : $(TOTALH) identifier.h declaration.h arrayop.c
attrib.obj : $(TOTALH) identifier.h declaration.h attrib.h attrib.c
Expand Down
14 changes: 7 additions & 7 deletions test/compilable/test7190.d
@@ -1,7 +1,7 @@
// PERMUTE_ARGS:
// REQUIRED_ARGS: -c -Icompilable/extra-files

import example7190.controllers.HomeController;
import example7190.models.HomeModel;

void main(){}
// PERMUTE_ARGS:
// REQUIRED_ARGS: -c -Icompilable/extra-files

import example7190.controllers.HomeController;
import example7190.models.HomeModel;

void main(){}

0 comments on commit 7fbceaa

Please sign in to comment.