use of com.google.devtools.j2objc.ast.ArrayAccess in project j2objc by google.
the class ArrayRewriter method visit.
// We must handle object array assignment before its children because if the
// rhs is an array creation, we can optimize with "SetAndConsume".
@Override
public boolean visit(Assignment node) {
Expression lhs = node.getLeftHandSide();
TypeMirror lhsType = lhs.getTypeMirror();
if (lhs instanceof ArrayAccess && !lhsType.getKind().isPrimitive()) {
FunctionInvocation newAssignment = newArrayAssignment(node, (ArrayAccess) lhs, lhsType);
node.replaceWith(newAssignment);
newAssignment.accept(this);
return false;
}
return true;
}
use of com.google.devtools.j2objc.ast.ArrayAccess in project j2objc by google.
the class TranslationUtil method getOperatorFunctionModifier.
/**
* Returns the modifier for an assignment expression being converted to a
* function. The result will be "Array" if the lhs is an array access,
* "Strong" if the lhs is a field with a strong reference, and an empty string
* for local variables and weak fields.
*/
public String getOperatorFunctionModifier(Expression expr) {
VariableElement var = TreeUtil.getVariableElement(expr);
if (var == null) {
assert TreeUtil.trimParentheses(expr) instanceof ArrayAccess : "Expression cannot be resolved to a variable or array access.";
return "Array";
}
String modifier = "";
if (ElementUtil.isVolatile(var)) {
modifier += "Volatile";
}
if (!ElementUtil.isWeakReference(var) && (var.getKind().isField() || options.useARC())) {
modifier += "Strong";
}
return modifier;
}
Aggregations