(stmt)
| 17235 | */ |
| 17236 | } |
| 17237 | emitSingleAssignment(stmt) { |
| 17238 | torch._C.AT_ASSERT(stmt instanceof ast.AnnAssign); |
| 17239 | const rhs = stmt.value; |
| 17240 | const lhs = stmt.target; |
| 17241 | if (lhs instanceof ast.Name) { |
| 17242 | let type = null; |
| 17243 | if (stmt.annotation) { |
| 17244 | type = this._typeParser.parseTypeFromExpr(stmt.annotation); |
| 17245 | } |
| 17246 | const rhs_sugared_val = this.emitSugaredExpr(rhs, 1, type); |
| 17247 | // BC HACK |
| 17248 | this.environment_stack.setSugaredVar(stmt.range(), lhs.id, rhs_sugared_val, /*annotated_type=*/type); |
| 17249 | } else if (lhs instanceof ast.Tuple) { |
| 17250 | this.emitTupleAssign(lhs, rhs); |
| 17251 | } else if (lhs instanceof ast.Attribute) { |
| 17252 | this.emitSelectAssign(lhs, rhs, null, stmt.range()); |
| 17253 | } else { |
| 17254 | throw new python.Error('Unexpected expression on left-hand side of assignment.'); |
| 17255 | } |
| 17256 | } |
| 17257 | emitSelectAssign(lhs, rhs, type, loc) { |
| 17258 | if (!rhs) { |
| 17259 | throw new python.Error('Expected RHS for assignment.'); |
no test coverage detected