Skip to content

Commit c7c2297

Browse files
committed
Make atkey and atpos on type objects give null.
This simplifies code-gen for array/hash access.
1 parent eaeda37 commit c7c2297

File tree

2 files changed

+3
-27
lines changed

2 files changed

+3
-27
lines changed

src/vm/jvm/QAST/Compiler.nqp

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3066,7 +3066,7 @@ class QAST::CompilerJAST {
30663066
if $*BINDVAL {
30673067
self.compile_var($node)
30683068
}
3069-
elsif $node.scope ne 'positional' && $node.scope ne 'associative' {
3069+
else {
30703070
my $var_res := self.compile_var($node);
30713071
if ($var_res.type != $RT_OBJ) {
30723072
return $var_res;
@@ -3089,30 +3089,6 @@ class QAST::CompilerJAST {
30893089

30903090
result($il, $RT_OBJ);
30913091
}
3092-
else {
3093-
my $fb_temp := $node.unique('fb_tmp');
3094-
self.as_jast(QAST::Op.new(
3095-
:op('ifnull'),
3096-
QAST::Op.new(
3097-
:op('if'),
3098-
QAST::Op.new(
3099-
:op('isconcrete'),
3100-
QAST::Op.new(
3101-
:op('bind'),
3102-
QAST::Var.new( :name($fb_temp), :scope('local'), :decl('var') ),
3103-
$node[0]
3104-
)
3105-
),
3106-
QAST::Var.new(
3107-
:scope($node.scope),
3108-
QAST::Var.new( :name($fb_temp), :scope('local') ),
3109-
$node[1]
3110-
),
3111-
QAST::Op.new( :op('null') )
3112-
),
3113-
$node.fallback
3114-
))
3115-
}
31163092
}
31173093

31183094
method compile_var($node) {

src/vm/jvm/runtime/org/perl6/nqp/sixmodel/TypeObject.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public String get_str(ThreadContext tc) {
3434
}
3535

3636
public SixModelObject at_pos_boxed(ThreadContext tc, long index) {
37-
throw ExceptionHandling.dieInternal(tc, "Cannot do aggregate operation on a type object");
37+
return null;
3838
}
3939
public void bind_pos_boxed(ThreadContext tc, long index, SixModelObject value) {
4040
throw ExceptionHandling.dieInternal(tc, "Cannot do aggregate operation on a type object");
@@ -58,7 +58,7 @@ public void splice(ThreadContext tc, SixModelObject from, long offset, long coun
5858
throw ExceptionHandling.dieInternal(tc, "Cannot do aggregate operation on a type object");
5959
}
6060
public SixModelObject at_key_boxed(ThreadContext tc, String key) {
61-
throw ExceptionHandling.dieInternal(tc, "Cannot do aggregate operation on a type object");
61+
return null;
6262
}
6363
public void bind_key_boxed(ThreadContext tc, String key, SixModelObject value) {
6464
throw ExceptionHandling.dieInternal(tc, "Cannot do aggregate operation on a type object");

0 commit comments

Comments
 (0)