Skip to content

Commit

Permalink
Die on CStruct without any fields.
Browse files Browse the repository at this point in the history
  • Loading branch information
peschwa committed Sep 30, 2016
1 parent ec03b35 commit f4e333a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/CStruct.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.perl6.nqp.sixmodel.reprs.NativeCall.ArgType;

import org.perl6.nqp.runtime.ExceptionHandling;
import org.perl6.nqp.runtime.Ops;
import org.perl6.nqp.runtime.ThreadContext;

public class CStruct extends REPR {
Expand Down Expand Up @@ -110,6 +111,10 @@ private void generateStructClass(ThreadContext tc, STable st, List<AttrInfo> fie

int attributes = fields.size();

if (attributes == 0) {
ExceptionHandling.dieInternal(tc, "Class " + Ops.typeName(st.WHAT, tc) + " has repr CStruct but no fields");
}

// public $className extends com.sun.jna.Structure implements com.sun.jna.Structure.ByReference { ... }
cw.visit(Opcodes.V1_7, Opcodes.ACC_PUBLIC | Opcodes.ACC_SUPER, className, null, "com/sun/jna/Structure", null);

Expand Down

0 comments on commit f4e333a

Please sign in to comment.