MCPcopy Index your code
hub / github.com/lutzroeder/netron / emitSingleAssignment

Method emitSingleAssignment

source/python.js:17237–17256  ·  view source on GitHub ↗
(stmt)

Source from the content-addressed store, hash-verified

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.');

Callers 1

emitAssignmentMethod · 0.80

Calls 5

parseTypeFromExprMethod · 0.80
emitSugaredExprMethod · 0.80
setSugaredVarMethod · 0.80
emitTupleAssignMethod · 0.80
emitSelectAssignMethod · 0.80

Tested by

no test coverage detected