public static Expr subscript(Expr array, Expr index, ArrayType type) { SubscriptExpr expr = new SubscriptExpr(); expr.setArray(array); expr.setIndex(index); expr.setType(type); return expr; }
@Override public void visit(SubscriptExpr expr) { pushLocation(expr.getLocation()); try { Expr index = expr.getIndex(); Expr array = expr.getArray(); expr.getIndex().acceptVisitor(this); index = resultExpr; expr.getArray().acceptVisitor(this); array = resultExpr; expr.setArray(array); expr.setIndex(index); resultExpr = expr; } finally {
@Override public void visit(SubscriptExpr expr) { try { if (expr.getLocation() != null) { pushLocation(expr.getLocation()); } precedence = Precedence.MEMBER_ACCESS; expr.getArray().acceptVisitor(this); writer.append('['); precedence = Precedence.min(); expr.getIndex().acceptVisitor(this); writer.append(']'); if (expr.getLocation() != null) { popLocation(); } } catch (IOException e) { throw new RenderingException("IO error occurred", e); } }
@Override public void visit(SubscriptExpr expr) { WasmExpression ptr = getArrayElementPointer(expr); switch (expr.getType()) { case BYTE: result = new WasmLoadInt32(1, ptr, WasmInt32Subtype.INT8); break; case SHORT: result = new WasmLoadInt32(2, ptr, WasmInt32Subtype.INT16); break; case CHAR: result = new WasmLoadInt32(2, ptr, WasmInt32Subtype.UINT16); break; case INT: case OBJECT: result = new WasmLoadInt32(4, ptr, WasmInt32Subtype.INT32); break; case LONG: result = new WasmLoadInt64(8, ptr, WasmInt64Subtype.INT64); break; case FLOAT: result = new WasmLoadFloat32(4, ptr); break; case DOUBLE: result = new WasmLoadFloat64(8, ptr); break; } }
@Override public void visit(SubscriptExpr expr) { try { if (expr.getLocation() != null) { pushLocation(expr.getLocation()); } precedence = Precedence.MEMBER_ACCESS; expr.getArray().acceptVisitor(this); writer.append('['); precedence = Precedence.min(); expr.getIndex().acceptVisitor(this); writer.append(']'); if (expr.getLocation() != null) { popLocation(); } } catch (IOException e) { throw new RenderingException("IO error occurred", e); } }
private void storeArrayItem(SubscriptExpr leftValue, Expr rightValue) { WasmExpression ptr = getArrayElementPointer(leftValue); accept(rightValue); switch (leftValue.getType()) { case BYTE: result = new WasmStoreInt32(1, ptr, result, WasmInt32Subtype.INT8); break; case SHORT: result = new WasmStoreInt32(2, ptr, result, WasmInt32Subtype.INT16); break; case CHAR: result = new WasmStoreInt32(2, ptr, result, WasmInt32Subtype.UINT16); break; case INT: case OBJECT: result = new WasmStoreInt32(4, ptr, result, WasmInt32Subtype.INT32); break; case LONG: result = new WasmStoreInt64(8, ptr, result, WasmInt64Subtype.INT64); break; case FLOAT: result = new WasmStoreFloat32(4, ptr, result); break; case DOUBLE: result = new WasmStoreFloat64(8, ptr, result); break; } }
@Override protected Expr clone(Map<Expr, Expr> cache) { Expr known = cache.get(this); if (known != null) { return known; } SubscriptExpr copy = new SubscriptExpr(); copy.setArray(array != null ? array.clone(cache) : null); copy.setIndex(index != null ? index.clone(cache) : null); copy.setType(type); return copy; } }
@Override public void visit(SubscriptExpr expr) { pushLocation(expr.getLocation()); try { expr.getIndex().acceptVisitor(this); Expr index = resultExpr; expr.getArray().acceptVisitor(this); Expr array = resultExpr; expr.setArray(array); expr.setIndex(index); resultExpr = expr; } finally { popLocation(); } }
@Override public void visit(SubscriptExpr expr) { WasmExpression ptr = getArrayElementPointer(expr); switch (expr.getType()) { case BYTE: result = new WasmLoadInt32(1, ptr, WasmInt32Subtype.INT8); break; case SHORT: result = new WasmLoadInt32(2, ptr, WasmInt32Subtype.INT16); break; case CHAR: result = new WasmLoadInt32(2, ptr, WasmInt32Subtype.UINT16); break; case INT: case OBJECT: result = new WasmLoadInt32(4, ptr, WasmInt32Subtype.INT32); break; case LONG: result = new WasmLoadInt64(8, ptr, WasmInt64Subtype.INT64); break; case FLOAT: result = new WasmLoadFloat32(4, ptr); break; case DOUBLE: result = new WasmLoadFloat64(8, ptr); break; } }
SubscriptExpr expr = new SubscriptExpr(); expr.setArray(readExpr(input)); expr.setIndex(readExpr(input)); expr.setType(ArrayType.values()[input.readByte()]); return expr;
private void storeArrayItem(SubscriptExpr leftValue, Expr rightValue) { WasmExpression ptr = getArrayElementPointer(leftValue); accept(rightValue); switch (leftValue.getType()) { case BYTE: result = new WasmStoreInt32(1, ptr, result, WasmInt32Subtype.INT8); break; case SHORT: result = new WasmStoreInt32(2, ptr, result, WasmInt32Subtype.INT16); break; case CHAR: result = new WasmStoreInt32(2, ptr, result, WasmInt32Subtype.UINT16); break; case INT: case OBJECT: result = new WasmStoreInt32(4, ptr, result, WasmInt32Subtype.INT32); break; case LONG: result = new WasmStoreInt64(8, ptr, result, WasmInt64Subtype.INT64); break; case FLOAT: result = new WasmStoreFloat32(4, ptr, result); break; case DOUBLE: result = new WasmStoreFloat64(8, ptr, result); break; } }
public static Expr subscript(Expr array, Expr index, ArrayType type) { SubscriptExpr expr = new SubscriptExpr(); expr.setArray(array); expr.setIndex(index); expr.setType(type); return expr; }
@Override protected Expr clone(Map<Expr, Expr> cache) { Expr known = cache.get(this); if (known != null) { return known; } SubscriptExpr copy = new SubscriptExpr(); copy.setArray(array != null ? array.clone(cache) : null); copy.setIndex(index != null ? index.clone(cache) : null); copy.setType(type); return copy; } }