Fixed a casting bug in Painless.
This commit is contained in:
parent
1d394868d4
commit
95a1b5b2a3
|
@ -233,6 +233,7 @@ public final class EChain extends AExpression {
|
||||||
if (last instanceof ADefLink) {
|
if (last instanceof ADefLink) {
|
||||||
final ADefLink lastDef = (ADefLink) last;
|
final ADefLink lastDef = (ADefLink) last;
|
||||||
expression.analyze(settings, definition, variables);
|
expression.analyze(settings, definition, variables);
|
||||||
|
// TODO: does it make more sense to just re-use last.after instead of using storeValueType?
|
||||||
lastDef.storeValueType = expression.expected = expression.actual;
|
lastDef.storeValueType = expression.expected = expression.actual;
|
||||||
this.actual = read ? lastDef.storeValueType : definition.voidType;
|
this.actual = read ? lastDef.storeValueType : definition.voidType;
|
||||||
} else {
|
} else {
|
||||||
|
@ -241,7 +242,7 @@ public final class EChain extends AExpression {
|
||||||
expression.analyze(settings, definition, variables);
|
expression.analyze(settings, definition, variables);
|
||||||
this.actual = read ? last.after : definition.voidType;
|
this.actual = read ? last.after : definition.voidType;
|
||||||
}
|
}
|
||||||
|
|
||||||
expression = expression.cast(settings, definition, variables);
|
expression = expression.cast(settings, definition, variables);
|
||||||
this.statement = true;
|
this.statement = true;
|
||||||
}
|
}
|
||||||
|
@ -316,7 +317,12 @@ public final class EChain extends AExpression {
|
||||||
expression.write(settings, definition, adapter);
|
expression.write(settings, definition, adapter);
|
||||||
|
|
||||||
if (link.load) {
|
if (link.load) {
|
||||||
WriterUtility.writeDup(adapter, link.after.sort.size, link.size);
|
// storeValueType may be different from after, so use storeValueType if last is an ADefLink
|
||||||
|
if (last instanceof ADefLink) {
|
||||||
|
WriterUtility.writeDup(adapter, ((ADefLink)last).storeValueType.sort.size, link.size);
|
||||||
|
} else {
|
||||||
|
WriterUtility.writeDup(adapter, link.after.sort.size, link.size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
link.store(settings, definition, adapter);
|
link.store(settings, definition, adapter);
|
||||||
|
|
|
@ -41,7 +41,6 @@ final class LDefArray extends ADefLink {
|
||||||
this.index = index;
|
this.index = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
ALink analyze(final CompilerSettings settings, final Definition definition, final Variables variables) {
|
ALink analyze(final CompilerSettings settings, final Definition definition, final Variables variables) {
|
||||||
index.analyze(settings, definition, variables);
|
index.analyze(settings, definition, variables);
|
||||||
|
@ -69,6 +68,7 @@ final class LDefArray extends ADefLink {
|
||||||
if (storeValueType == null) {
|
if (storeValueType == null) {
|
||||||
throw new IllegalStateException(error("Illegal tree structure."));
|
throw new IllegalStateException(error("Illegal tree structure."));
|
||||||
}
|
}
|
||||||
|
|
||||||
final String desc = Type.getMethodDescriptor(definition.voidType.type, definition.defType.type,
|
final String desc = Type.getMethodDescriptor(definition.voidType.type, definition.defType.type,
|
||||||
index.actual.type, storeValueType.type);
|
index.actual.type, storeValueType.type);
|
||||||
adapter.invokeDynamic("arrayStore", desc, DEF_BOOTSTRAP_HANDLE, DefBootstrap.ARRAY_STORE);
|
adapter.invokeDynamic("arrayStore", desc, DEF_BOOTSTRAP_HANDLE, DefBootstrap.ARRAY_STORE);
|
||||||
|
|
Loading…
Reference in New Issue