Skip to content

Commit

Permalink
Merge 2.076.0 front-end and stdlibs
Browse files Browse the repository at this point in the history
Biggest changes:

* idgen.d has been replaced by a CTFE implementation, id.d.
  I manually added a C++ header declaring the symbols we need and
  adapted (simplified) the CMake script accordingly.
* More semantic() methods have been extracted as visitors; most notably
  for expressions.
  • Loading branch information
kinke committed Oct 7, 2017
1 parent f56bbf4 commit d16a806
Show file tree
Hide file tree
Showing 118 changed files with 14,773 additions and 11,101 deletions.
42 changes: 3 additions & 39 deletions CMakeLists.txt
Expand Up @@ -258,38 +258,6 @@ if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
endif()


# Build (generate executable) of D source
macro(build_idgen input_d output_exec extra_d_flags link_flags extra_deps)
separate_arguments(FLAG_LIST WINDOWS_COMMAND "${D_COMPILER_FLAGS} ${extra_d_flags} ${link_flags}")
add_custom_command(
OUTPUT ${output_exec}
COMMAND ${D_COMPILER} ${FLAG_LIST} -I${PROJECT_SOURCE_DIR}/${DDMDFE_PATH} -of${output_exec} ${input_d}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
DEPENDS ${input_d} ${extra_deps}
)
endmacro()


#
# Build idgen.
#
build_idgen(${DDMDFE_PATH}/idgen.d ${PROJECT_BINARY_DIR}/idgen${CMAKE_EXECUTABLE_SUFFIX} ${DDMD_DFLAGS} "" "")
# Run idgen.
add_custom_command(
OUTPUT
${PROJECT_BINARY_DIR}/${DDMDFE_PATH}/id.d
${PROJECT_BINARY_DIR}/${DDMDFE_PATH}/id.h
COMMAND ${PROJECT_BINARY_DIR}/idgen #provide full path to avoid clash with idgen on path
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
DEPENDS ${PROJECT_BINARY_DIR}/idgen${CMAKE_EXECUTABLE_SUFFIX}
)
set(LDC_CXX_GENERATED
${PROJECT_BINARY_DIR}/${DDMDFE_PATH}/id.h
)
set(LDC_D_GENERATED
${PROJECT_BINARY_DIR}/${DDMDFE_PATH}/id.d
)

#
# Gather source files.
#
Expand Down Expand Up @@ -371,25 +339,22 @@ set(DRV_HDR
driver/toobj.h
driver/tool.h
)
# exclude idgen and man.d
# exclude man.d
list(REMOVE_ITEM FE_SRC_D
${PROJECT_SOURCE_DIR}/${DDMDFE_PATH}/idgen.d
${PROJECT_SOURCE_DIR}/${DDMDFE_PATH}/root/man.d
)
# exclude ldmd.d from ldc
list(REMOVE_ITEM DRV_SRC_D
${PROJECT_SOURCE_DIR}/driver/ldmd.d
)
set(LDC_CXX_SOURCE_FILES
${LDC_CXX_GENERATED}
${FE_HDR}
${GEN_SRC}
${GEN_HDR}
${IR_SRC}
${IR_HDR}
)
set(LDC_D_SOURCE_FILES
${LDC_D_GENERATED}
${FE_SRC_D}
${GEN_SRC_D}
${DRV_SRC_D}
Expand All @@ -403,7 +368,6 @@ source_group("Header Files\\gen" FILES ${GEN_HDR})
source_group("Source Files\\ir" FILES ${IR_SRC} ${IR_SRC_D})
source_group("Header Files\\ir" FILES ${IR_HDR})
source_group("Source Files" FILES ${DRV_SRC_D})
source_group("Generated Files" REGULAR_EXPRESSION "(id\\.[cdh]|impcnvtab\\.c)$")


#
Expand Down Expand Up @@ -674,14 +638,14 @@ if(MSVC_IDE)
OUTPUT ${LDC_EXE_FULL}
COMMAND ${D_COMPILER} -L$<TARGET_LINKER_FILE:${LDC_LIB}> ${LDC_FLAG_LIST} -I${PROJECT_SOURCE_DIR}/${DDMDFE_PATH} -of${LDC_EXE_FULL} ${LDC_D_SOURCE_FILES} $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:-g> $<$<NOT:$<CONFIG:Debug>>:-O> $<$<NOT:$<CONFIG:Debug>>:-inline> $<$<NOT:$<CONFIG:Debug>>:-release>
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
DEPENDS ${LDC_D_SOURCE_FILES} ${FE_RES} ${PROJECT_BINARY_DIR}/${DDMDFE_PATH}/id.d ${LDC_LIB}
DEPENDS ${LDC_D_SOURCE_FILES} ${FE_RES} ${LDC_LIB}
)
else()
build_d_executable(
"${LDC_EXE_FULL}"
"${LDC_D_SOURCE_FILES}"
"$<TARGET_LINKER_FILE:${LDC_LIB}>"
"${LDC_D_SOURCE_FILES};${FE_RES};${PROJECT_BINARY_DIR}/${DDMDFE_PATH}/id.d"
"${LDC_D_SOURCE_FILES};${FE_RES}"
"${LDC_LIB}"
)
endif()
Expand Down
4 changes: 3 additions & 1 deletion ddmd/access.d
Expand Up @@ -5,11 +5,13 @@
* Copyright: Copyright (c) 1999-2017 by Digital Mars, All Rights Reserved
* Authors: $(LINK2 http://www.digitalmars.com, Walter Bright)
* License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(DMDSRC _access.d)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/ddmd/access.d, _access.d)
*/

module ddmd.access;

// Online documentation: https://dlang.org/phobos/ddmd_access.html

import ddmd.aggregate;
import ddmd.dclass;
import ddmd.declaration;
Expand Down
7 changes: 5 additions & 2 deletions ddmd/aggregate.d
Expand Up @@ -5,11 +5,13 @@
* Copyright: Copyright (c) 1999-2017 by Digital Mars, All Rights Reserved
* Authors: $(LINK2 http://www.digitalmars.com, Walter Bright)
* License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(DMDSRC _aggregate.d)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/ddmd/aggregate.d, _aggregate.d)
*/

module ddmd.aggregate;

// Online documentation: https://dlang.org/phobos/ddmd_aggregate.html

import core.stdc.stdio;
import core.checkedint;

Expand All @@ -22,6 +24,7 @@ import ddmd.dsymbol;
import ddmd.dtemplate;
import ddmd.errors;
import ddmd.expression;
import ddmd.expressionsem;
import ddmd.func;
import ddmd.globals;
import ddmd.id;
Expand Down Expand Up @@ -204,7 +207,7 @@ extern (C++) abstract class AggregateDeclaration : ScopeDsymbol
ti.semantic(sc3);
ti.semantic2(sc3);
ti.semantic3(sc3);
auto e = DsymbolExp.resolve(Loc(), sc3, ti.toAlias(), false);
auto e = resolve(Loc(), sc3, ti.toAlias(), false);

sc3.endCTFE();

Expand Down
5 changes: 4 additions & 1 deletion ddmd/aliasthis.d
Expand Up @@ -5,18 +5,21 @@
* Copyright: Copyright (c) 1999-2017 by Digital Mars, All Rights Reserved
* Authors: $(LINK2 http://www.digitalmars.com, Walter Bright)
* License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(DMDSRC _aliasthis.d)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/ddmd/aliasthis.d, _aliasthis.d)
*/

module ddmd.aliasthis;

// Online documentation: https://dlang.org/phobos/ddmd_aliasthis.html

import core.stdc.stdio;
import ddmd.aggregate;
import ddmd.declaration;
import ddmd.dscope;
import ddmd.dsymbol;
import ddmd.errors;
import ddmd.expression;
import ddmd.expressionsem;
import ddmd.globals;
import ddmd.identifier;
import ddmd.mtype;
Expand Down
4 changes: 3 additions & 1 deletion ddmd/apply.d
Expand Up @@ -5,11 +5,13 @@
* Copyright: Copyright (c) 1999-2017 by Digital Mars, All Rights Reserved
* Authors: $(LINK2 http://www.digitalmars.com, Walter Bright)
* License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(DMDSRC _apply.d)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/ddmd/apply.d, _apply.d)
*/

module ddmd.apply;

// Online documentation: https://dlang.org/phobos/ddmd_apply.html

import ddmd.arraytypes;
import ddmd.dtemplate;
import ddmd.expression;
Expand Down
4 changes: 3 additions & 1 deletion ddmd/argtypes.d
Expand Up @@ -5,11 +5,13 @@
* Copyright: Copyright (c) 1999-2017 by Digital Mars, All Rights Reserved
* Authors: $(LINK2 http://www.digitalmars.com, Walter Bright)
* License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(DMDSRC _argtypes.d)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/ddmd/argtypes.d, _argtypes.d)
*/

module ddmd.argtypes;

// Online documentation: https://dlang.org/phobos/ddmd_argtypes.html

import core.stdc.stdio;
import ddmd.declaration;
import ddmd.globals;
Expand Down
37 changes: 26 additions & 11 deletions ddmd/arrayop.d
Expand Up @@ -5,17 +5,20 @@
* Copyright: Copyright (c) 1999-2017 by Digital Mars, All Rights Reserved
* Authors: $(LINK2 http://www.digitalmars.com, Walter Bright)
* License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(DMDSRC _arrayop.d)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/ddmd/arrayop.d, _arrayop.d)
*/

module ddmd.arrayop;

// Online documentation: https://dlang.org/phobos/ddmd_arrayop.html

import core.stdc.stdio;
import ddmd.arraytypes;
import ddmd.declaration;
import ddmd.dscope;
import ddmd.dsymbol;
import ddmd.expression;
import ddmd.expressionsem;
import ddmd.func;
import ddmd.globals;
import ddmd.id;
Expand Down Expand Up @@ -158,7 +161,7 @@ extern (C++) bool checkNonAssignmentArrayOp(Expression e, bool suggestion = fals
const(char)* s = "";
if (suggestion)
s = " (possible missing [])";
e.error("array operation %s without destination memory not allowed%s", e.toChars(), s);
e.error("array operation `%s` without destination memory not allowed%s", e.toChars(), s);
return true;
}
return false;
Expand All @@ -175,14 +178,11 @@ extern (C++) Expression arrayOp(BinExp e, Scope* sc)
Type tbn = tb.nextOf().toBasetype();
if (tbn.ty == Tvoid)
{
e.error("cannot perform array operations on void[] arrays");
e.error("cannot perform array operations on `void[]` arrays");
return new ErrorExp();
}
if (!isArrayOpValid(e))
{
e.error("invalid array operation %s (possible missing [])", e.toChars());
return new ErrorExp();
}
return arrayOpInvalidError(e);

auto arguments = new Expressions();

Expand Down Expand Up @@ -219,11 +219,11 @@ extern (C++) Expression arrayOp(BinExp e, Scope* sc)
{
const(char)* fmt;
if (tbn.ty == Tstruct || tbn.ty == Tclass)
fmt = "invalid array operation '%s' because %s doesn't support necessary arithmetic operations";
fmt = "invalid array operation `%s` because `%s` doesn't support necessary arithmetic operations";
else if (!tbn.isscalar())
fmt = "invalid array operation '%s' because %s is not a scalar type";
fmt = "invalid array operation `%s` because `%s` is not a scalar type";
else
fmt = "invalid array operation '%s' for element type %s";
fmt = "invalid array operation `%s` for element type `%s`";
e.error(fmt, e.toChars(), tbn.toChars());
return new ErrorExp();
}
Expand Down Expand Up @@ -255,7 +255,7 @@ extern (C++) Expression arrayOp(BinAssignExp e, Scope* sc)

if (tn && (!tn.isMutable() || !tn.isAssignable()))
{
e.error("slice %s is not mutable", e.e1.toChars());
e.error("slice `%s` is not mutable", e.e1.toChars());
return new ErrorExp();
}
if (e.e1.op == TOKarrayliteral)
Expand Down Expand Up @@ -646,3 +646,18 @@ extern (C++) bool isArrayOpOperand(Expression e)
}
return false;
}


/***************************************************
* Print error message about invalid array operation.
* Params:
* e = expression with the invalid array operation
* Returns:
* instance of ErrorExp
*/

ErrorExp arrayOpInvalidError(Expression e)
{
e.error("invalid array operation `%s` (possible missing [])", e.toChars());
return new ErrorExp();
}
4 changes: 3 additions & 1 deletion ddmd/arraytypes.d
Expand Up @@ -5,11 +5,13 @@
* Copyright: Copyright (c) 1999-2017 by Digital Mars, All Rights Reserved
* Authors: $(LINK2 http://www.digitalmars.com, Walter Bright)
* License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(DMDSRC _arraytypes.d)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/ddmd/arraytypes.d, _arraytypes.d)
*/

module ddmd.arraytypes;

// Online documentation: https://dlang.org/phobos/ddmd_arraytypes.html

import ddmd.dclass;
import ddmd.declaration;
import ddmd.dmodule;
Expand Down
9 changes: 9 additions & 0 deletions ddmd/astcodegen.d
@@ -1,5 +1,7 @@
module ddmd.astcodegen;

// Online documentation: https://dlang.org/phobos/ddmd_astcodegen.html

struct ASTCodegen
{
import ddmd.aggregate;
Expand All @@ -20,11 +22,15 @@ struct ASTCodegen
import ddmd.func;
import ddmd.hdrgen;
import ddmd.init;
import ddmd.initsem;
import ddmd.mtype;
import ddmd.nspace;
import ddmd.statement;
import ddmd.staticassert;
import ddmd.typesem;

alias initializerToExpression = ddmd.initsem.initializerToExpression;
alias typeToExpression = ddmd.typesem.typeToExpression;
alias UserAttributeDeclaration = ddmd.attrib.UserAttributeDeclaration;

alias MODconst = ddmd.mtype.MODconst;
Expand Down Expand Up @@ -69,6 +75,9 @@ struct ASTCodegen
alias STCdeprecated = ddmd.declaration.STCdeprecated;
alias STCstatic = ddmd.declaration.STCstatic;
alias STCextern = ddmd.declaration.STCextern;
alias STCfuture = ddmd.declaration.STCfuture;
alias STCalias = ddmd.declaration.STCalias;
alias STClocal = ddmd.declaration.STClocal;

alias Dsymbol = ddmd.dsymbol.Dsymbol;
alias Dsymbols = ddmd.dsymbol.Dsymbols;
Expand Down
4 changes: 3 additions & 1 deletion ddmd/asttypename.d
Expand Up @@ -3,11 +3,13 @@
* Copyright: Copyright (c) 1999-2017 by The D Language Foundation, All Rights Reserved
* Authors: Stefan Koch
* License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(DMDSRC _asttypename.d)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/ddmd/asttypename.d, _asttypename.d)
*/

module ddmd.asttypename;

// Online documentation: https://dlang.org/phobos/ddmd_asttypename.html

import ddmd.attrib;
import ddmd.aliasthis;
import ddmd.aggregate;
Expand Down

0 comments on commit d16a806

Please sign in to comment.