public override IPStmt VisitRemoveStmt(PParser.RemoveStmtContext context) { IPExpr variable = exprVisitor.Visit(context.lvalue()); IPExpr value = exprVisitor.Visit(context.expr()); if (PLanguageType.TypeIsOfKind(variable.Type, TypeKind.Sequence)) { if (!PrimitiveType.Int.IsAssignableFrom(value.Type)) { throw handler.TypeMismatch(context.expr(), value.Type, PrimitiveType.Int); } } else if (PLanguageType.TypeIsOfKind(variable.Type, TypeKind.Map)) { var map = (MapType)variable.Type.Canonicalize(); if (!map.KeyType.IsAssignableFrom(value.Type)) { throw handler.TypeMismatch(context.expr(), value.Type, map.KeyType); } } else { throw handler.TypeMismatch(variable, TypeKind.Sequence, TypeKind.Map); } return(new RemoveStmt(context, variable, value)); }
public override object VisitRemoveStmt(PParser.RemoveStmtContext context) { return(null); }