Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
A little re-think that avoids code-dupe.
Also simplifies code generation for an error case that should never
really occur.
  • Loading branch information
jnthn committed Jan 7, 2013
1 parent b16cdd9 commit 1268e9d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/org/perl6/nqp/runtime/Ops.java
Expand Up @@ -535,20 +535,23 @@ public static SixModelObject bindattr(SixModelObject obj, SixModelObject ch, Str
}
public static long bindattr_i(SixModelObject obj, SixModelObject ch, String name, long value, ThreadContext tc) {
tc.native_i = value;
tc.native_type = ThreadContext.NATIVE_INT;
obj.bind_attribute_native(tc, ch, name, STable.NO_HINT);
if (tc.native_type != ThreadContext.NATIVE_INT)
throw new RuntimeException("Attribute '" + name + "' is not a native int");
return value;
}
public static double bindattr_n(SixModelObject obj, SixModelObject ch, String name, double value, ThreadContext tc) {
tc.native_n = value;
tc.native_type = ThreadContext.NATIVE_NUM;
obj.bind_attribute_native(tc, ch, name, STable.NO_HINT);
if (tc.native_type != ThreadContext.NATIVE_NUM)
throw new RuntimeException("Attribute '" + name + "' is not a native num");
return value;
}
public static String bindattr_s(SixModelObject obj, SixModelObject ch, String name, String value, ThreadContext tc) {
tc.native_s = value;
tc.native_type = ThreadContext.NATIVE_STR;
obj.bind_attribute_native(tc, ch, name, STable.NO_HINT);
if (tc.native_type != ThreadContext.NATIVE_STR)
throw new RuntimeException("Attribute '" + name + "' is not a native str");
return value;
}

Expand Down

0 comments on commit 1268e9d

Please sign in to comment.