Skip to content

Commit

Permalink
Merge pull request #35 from drug007/fix_issue_34
Browse files Browse the repository at this point in the history
Close #34 `sdl example not building by ldc2`
  • Loading branch information
drug007 authored Jan 9, 2022
2 parents aa3d10d + dafdf7a commit d4ff986
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
matrix:
# Latest stable version, update at will
os: [ ubuntu-18.04, windows-2019 ]
dc: [ dmd-latest, dmd-master ]
dc: [ dmd-latest, dmd-master, ldc-master, ldc-latest ]

runs-on: ${{ matrix.os }}
steps:
Expand Down
15 changes: 9 additions & 6 deletions auxil/source/auxil/model.d
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,7 @@ mixin template visitImpl()

static if (hasTreePath) visitor.tree_path.put(0);
static if (hasTreePath) scope(exit) visitor.tree_path.popBack;
const len = getLength!(Data, data);
auto len = getLength!(Data, data);
static if (is(typeof(model.length)))
assert(len == model.length);
if (!len)
Expand Down Expand Up @@ -1000,14 +1000,17 @@ mixin template visitImpl()
else static if (dataHasAggregateModel!Data)
{
scope(exit) dbgPrint!(hasSize, hasTreePath)("scope(exit) this.size: ", this.size);
// work around ldc2 issue
// expression `const len = getLength!(Data, data);` is not a constant
const len2 = DrawableMembers!Data.length;
switch(start_value)
{
static foreach(i; 0..len)
static foreach(i; 0..len2)
{
// reverse fields order if Order.Bubbling
case (Sinking) ? i : len - i - 1:
case (Sinking) ? i : len2 - i - 1:
{
enum FieldNo = (Sinking) ? i : len - i - 1;
enum FieldNo = (Sinking) ? i : len2 - i - 1;
enum member = DrawableMembers!Data[FieldNo];
static if (hasTreePath) visitor.tree_path.back = cast(int) FieldNo;
static if (hasSize) scope(exit) this.size += mixin("this." ~ member).size;
Expand All @@ -1022,9 +1025,9 @@ mixin template visitImpl()
goto case;
}
// the dummy case needed because every `goto case` should be followed by a case clause
case len:
case len2:
// flow cannot get here directly
if (start_value == len)
if (start_value == len2)
assert(0);
break;
default:
Expand Down

0 comments on commit d4ff986

Please sign in to comment.