public DataType VisitAssignExp(AssignExp a) { DataType valueType = a.Src.Accept(this); scope.BindByScope(analyzer, a.Dst, valueType); return(DataType.Cont); }
public CodeExpression VisitAssignExp(AssignExp e) { return(m.BinOp( e.Dst.Accept(this), mppyoptocsop[e.op], e.Src.Accept(this))); }
public DataType VisitAssignExp(AssignExp a) { if (scope.stateType == State.StateType.CLASS && a.Dst is Identifier id && id.Name == "__slots__") { // The __slots__ attribute needs to be handled specially: // it actually introduces new attributes. BindClassSlots(a.Src); }
private void ClassTranslator_GenerateField(Identifier id, ExpTranslator xlat, AssignExp ass) { if (id.Name == "__slots__") { // We should already have analyzed the slots in // the type inference phase, so we ignore __slots__. return; } else { var(fieldType, nmspcs) = types.TranslateTypeOf(id); gen.EnsureImports(nmspcs); GenerateField(id.Name, fieldType, ass.Src?.Accept(xlat)); } }
//expr_stmt: testlist_star_expr (augassign (yield_expr|testlist)) | // ('=' (yield_expr|testlist_star_expr))*) public Statement expr_stmt() { // Hack to deal with print statement from python 2.* if (Peek(TokenType.ID, "print")) { return print_stmt(); } var lhs = testlist_star_expr(); if (Peek(augassign_set)) { var op = augassign(); Exp e2; if (Peek(TokenType.Yield)) e2 = yield_expr(); else e2 = testlist(); lhs = new AssignExp(lhs, op, e2, filename, lhs.Start, e2.End); } else { Exp rhs = null; while (PeekAndDiscard(TokenType.EQ)) { if (Peek(TokenType.Yield)) rhs = yield_expr(); else rhs = testlist_star_expr(); } if (rhs != null) lhs = new AssignExp(lhs, Op.Assign, rhs, filename, lhs.Start, rhs.End); } return new ExpStatement(lhs, filename, lhs.Start, lhs.End); }
private void ClassTranslator_GenerateField(Identifier id, ExpTranslator xlat, AssignExp ass) { IEnumerable<Exp> slotNames = null; var srcList = ass.Src as PyList; if (srcList != null) { slotNames= srcList.elts; } var srcTuple = ass.Src as PyTuple; if (srcTuple != null) { slotNames = srcTuple.values; } if (id.Name == "__slots__") { foreach (var slotName in slotNames.OfType<Str>()) { GenerateField(slotName.s, null); } } else { GenerateField(id.Name, ass.Src.Accept(xlat)); } }
private void ClassTranslator_GenerateField(Identifier id, ExpTranslator xlat, AssignExp ass) { IEnumerable <Exp> slotNames = null; if (ass.Src is PyList srcList) { slotNames = srcList.elts; } else if (ass.Src is PyTuple srcTuple) { slotNames = srcTuple.values; } if (id.Name == "__slots__") { if (slotNames == null) { // dynamically generated slots are hard. gen.Comment(ass.ToString()); } else { foreach (var slotName in slotNames.OfType <Str>()) { GenerateField(slotName.s, null); } } } else { GenerateField(id.Name, ass.Src.Accept(xlat)); } }
private void ClassTranslator_GenerateField(Identifier id, ExpTranslator xlat, AssignExp ass) { IEnumerable <Exp> slotNames = null; if (ass.Src is PyList srcList) { slotNames = srcList.elts; } else if (ass.Src is PyTuple srcTuple) { slotNames = srcTuple.values; } if (id.Name == "__slots__") { if (slotNames == null) { // dynamically generated slots are hard. gen.Comment(ass.ToString()); } else { foreach (var slotName in slotNames.OfType <Str>()) { //$TODO: test type inference for slots. var slotType = new CodeTypeReference(typeof(object)); GenerateField(slotName.s, slotType, null); } } } else { var(fieldType, nmspcs) = types.TranslateTypeOf(id); gen.EnsureImports(nmspcs); GenerateField(id.Name, fieldType, ass.Src.Accept(xlat)); } }
public void VisitAssignExp(AssignExp assignExp) { throw new NotImplementedException(); }