@Override public void visit(NewMultiArrayExpr expr) { super.visit(expr); visitType(expr.getType()); }
@Override public void visit(NewMultiArrayExpr expr) { try { output.writeByte(21); output.writeByte(expr.getDimensions().size()); for (Expr dimension : expr.getDimensions()) { writeExpr(dimension); } output.writeInt(symbolTable.lookup(expr.getType().toString())); } catch (IOException e) { throw new IOExceptionWrapper(e); } }
@Override public void visit(NewMultiArrayExpr expr) { writer.print(names.forMethod(ALLOC_MULTI_ARRAY_METHOD)).print("(&") .print(names.forClassInstance(expr.getType())).print(", "); writer.print("(int32_t[]) {"); expr.getDimensions().get(0).acceptVisitor(this); for (int i = 1; i < expr.getDimensions().size(); ++i) { writer.print(", "); expr.getDimensions().get(i).acceptVisitor(this); } writer.print("}, ").print(String.valueOf(expr.getDimensions().size())).print(")"); }
@Override public void visit(NewMultiArrayExpr expr) { ValueType type = expr.getType(); WasmBlock block = new WasmBlock(false); block.setType(WasmType.INT32); int dimensionList = -1; for (Expr dimension : expr.getDimensions()) { int dimensionAddress = binaryWriter.append(DataPrimitives.INT.createValue()); if (dimensionList < 0) { dimensionList = dimensionAddress; } accept(dimension); block.getBody().add(new WasmStoreInt32(4, new WasmInt32Constant(dimensionAddress), result, WasmInt32Subtype.INT32)); } int classPointer = classGenerator.getClassPointer(ValueType.arrayOf(type)); String allocName = context.names.forMethod(new MethodReference(Allocator.class, "allocateMultiArray", RuntimeClass.class, Address.class, int.class, RuntimeArray.class)); WasmCall call = new WasmCall(allocName); call.getArguments().add(new WasmInt32Constant(classPointer)); call.getArguments().add(new WasmInt32Constant(dimensionList)); call.getArguments().add(new WasmInt32Constant(expr.getDimensions().size())); call.setLocation(expr.getLocation()); block.getBody().add(call); result = block; }
@Override public void visit(NewMultiArrayExpr expr) { super.visit(expr); visitType(expr.getType()); }
@Override public void visit(NewMultiArrayExpr expr) { try { output.writeByte(21); output.writeByte(expr.getDimensions().size()); for (Expr dimension : expr.getDimensions()) { writeExpr(dimension); } output.writeInt(symbolTable.lookup(expr.getType().toString())); } catch (IOException e) { throw new IOExceptionWrapper(e); } }
@Override public void visit(NewMultiArrayExpr expr) { ValueType type = expr.getType(); WasmBlock block = new WasmBlock(false); block.setType(WasmType.INT32); int dimensionList = -1; for (Expr dimension : expr.getDimensions()) { int dimensionAddress = binaryWriter.append(DataPrimitives.INT.createValue()); if (dimensionList < 0) { dimensionList = dimensionAddress; } accept(dimension); block.getBody().add(new WasmStoreInt32(4, new WasmInt32Constant(dimensionAddress), result, WasmInt32Subtype.INT32)); } int classPointer = classGenerator.getClassPointer(ValueType.arrayOf(type)); String allocName = WasmMangling.mangleMethod(new MethodReference(Allocator.class, "allocateMultiArray", RuntimeClass.class, Address.class, int.class, RuntimeArray.class)); WasmCall call = new WasmCall(allocName); call.getArguments().add(new WasmInt32Constant(classPointer)); call.getArguments().add(new WasmInt32Constant(dimensionList)); call.getArguments().add(new WasmInt32Constant(expr.getDimensions().size())); call.setLocation(expr.getLocation()); block.getBody().add(call); result = block; }