Skip to content

Commit

Permalink
Unresolved differences between gdc/dmd front ends
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuclaw committed Apr 12, 2015
1 parent b2e2f80 commit f7f1e23
Show file tree
Hide file tree
Showing 19 changed files with 360 additions and 56 deletions.
3 changes: 0 additions & 3 deletions src/aggregate.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,6 @@ struct BaseClass
void copyBaseInterfaces(BaseClasses *);
};

#define CLASSINFO_SIZE_64 0x98 // value of ClassInfo.size
#define CLASSINFO_SIZE (0x3C+12+4) // value of ClassInfo.size

struct ClassFlags
{
typedef unsigned Type;
Expand Down
4 changes: 4 additions & 0 deletions src/arraytypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ typedef Array<class GotoStatement *> GotoStatements;

typedef Array<class TemplateInstance *> TemplateInstances;

#ifdef IN_GCC
typedef Array<struct Label *> Blocks;
#else
typedef Array<struct block *> Blocks;
#endif

typedef Array<struct Symbol *> Symbols;

Expand Down
4 changes: 2 additions & 2 deletions src/declaration.h
Original file line number Diff line number Diff line change
Expand Up @@ -534,10 +534,10 @@ class FuncDeclaration : public Declaration
// scopes from having the same name
VarDeclaration *vthis; // 'this' parameter (member and nested)
VarDeclaration *v_arguments; // '_arguments' parameter
#ifdef IN_GCC
#ifdef IN_GCC // %%
VarDeclaration *v_arguments_var; // '_arguments' variable
VarDeclaration *v_argptr; // '_argptr' variable
#endif
#endif // %%
VarDeclaration *v_argsave; // save area for args passed in registers for variadic functions
VarDeclarations *parameters; // Array of VarDeclaration's for parameters
DsymbolTable *labtab; // statement label symbol table
Expand Down
5 changes: 5 additions & 0 deletions src/expression.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,12 @@ Expression *getRightThis(Loc loc, Scope *sc, AggregateDeclaration *ad,
{
//printf("rewriting e1 to %s's this\n", f->toChars());
n++;
#ifdef IN_GCC
if (n > 1)
e1 = new VarExp(loc, f->vthis);
#else
e1 = new VarExp(loc, f->vthis);
#endif
}
else
{
Expand Down
16 changes: 8 additions & 8 deletions src/func.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,10 @@ FuncDeclaration::FuncDeclaration(Loc loc, Loc endloc, Identifier *id, StorageCla
localsymtab = NULL;
vthis = NULL;
v_arguments = NULL;
#ifdef IN_GCC
#ifdef IN_GCC // %%
v_argptr = NULL;
v_arguments_var = NULL;
#endif
#endif // %%
v_argsave = NULL;
parameters = NULL;
labtab = NULL;
Expand Down Expand Up @@ -1333,7 +1333,7 @@ void FuncDeclaration::semantic3(Scope *sc)
// Declare hidden variable _arguments[] and _argptr
if (f->varargs == 1)
{
#ifndef IN_GCC
#ifndef IN_GCC // %%
if (global.params.is64bit && !global.params.isWindows)
{
// Declare save area for varargs registers
Expand All @@ -1353,7 +1353,7 @@ void FuncDeclaration::semantic3(Scope *sc)
v_argsave->parent = this;
}
}
#endif
#endif // %%

if (f->linkage == LINKd)
{
Expand Down Expand Up @@ -1885,11 +1885,11 @@ void FuncDeclaration::semantic3(Scope *sc)
if (argptr)
{
// Initialize _argptr
#ifdef IN_GCC
#ifdef IN_GCC // %%
// Handled in FuncDeclaration::toObjFile
v_argptr = argptr;
v_argptr->init = new VoidInitializer(loc);
#else
#else // %%
Type *t = argptr->type;
if (global.params.is64bit && !global.params.isWindows)
{
Expand Down Expand Up @@ -1970,10 +1970,10 @@ void FuncDeclaration::semantic3(Scope *sc)

if (_arguments)
{
#ifdef IN_GCC
#ifdef IN_GCC // %%
v_arguments_var = _arguments;
v_arguments_var->init = new VoidInitializer(loc);
#endif
#endif // %%
/* Advance to elements[] member of TypeInfo_Tuple with:
* _arguments = v_arguments.elements;
*/
Expand Down
7 changes: 7 additions & 0 deletions src/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ struct Param
const char *moduleDepsFile; // filename for deps output
OutBuffer *moduleDeps; // contents to be written to deps file

#ifdef IN_GCC
const char *makeDepsFile; // filename for make deps output
OutBuffer *makeDeps; // contents to be written to make deps file
char makeDepsStyle; // 0: include system header files
// 1: ignore system header files
#endif

// Hidden debug switches
bool debugb;
bool debugc;
Expand Down
28 changes: 28 additions & 0 deletions src/interpret.c
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,16 @@ class CtfeCompiler : public Visitor
// we can't compile asm statements
}

#ifdef IN_GCC
void visit(ExtAsmStatement *s)
{
#if LOGCOMPILE
printf("%s ExtAsmStatement::ctfeCompile\n", s->loc.toChars());
#endif
// we can't compile ext asm statements
}
#endif

void ctfeCompile(Statement *s)
{
s->accept(this);
Expand Down Expand Up @@ -1938,6 +1948,24 @@ class Interpreter : public Visitor
result = CTFEExp::cantexp;
}

#ifdef IN_GCC
void visit(ExtAsmStatement *s)
{
#if LOG
printf("%s ExtAsmStatement::interpret()\n", s->loc.toChars());
#endif
if (istate->start)
{
if (istate->start != s)
return;
istate->start = NULL;
}

s->error("extended asm statements cannot be interpreted at compile time");
result = EXP_CANT_INTERPRET;
}
#endif

void visit(ImportStatement *s)
{
#if LOG
Expand Down
2 changes: 0 additions & 2 deletions src/magicport.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,6 @@
[
"function isf",
"struct BaseClass",
"variable CLASSINFO_SIZE_64",
"variable CLASSINFO_SIZE",
"struct ClassFlags",
"struct ClassDeclaration",
"struct InterfaceDeclaration"
Expand Down
6 changes: 3 additions & 3 deletions src/mtype.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ class TypeBasic;
class Parameter;

// Back end
#ifdef IN_GCC
#ifdef IN_GCC // %%
typedef union tree_node type;
#else
#else // %%
typedef struct TYPE type;
#endif
#endif // %%

void semanticTypeInfo(Scope *sc, Type *t);
MATCH deduceType(RootObject *o, Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes, unsigned *wm = NULL, size_t inferStart = 0);
Expand Down
Loading

0 comments on commit f7f1e23

Please sign in to comment.