11/*
2- * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * The Universal Permissive License (UPL), Version 1.0
4040 */
4141package com .oracle .graal .python .builtins .modules .re ;
4242
43+ import static com .oracle .graal .python .builtins .modules .re .TRegexCache .FLAG_ASCII ;
44+ import static com .oracle .graal .python .builtins .modules .re .TRegexCache .FLAG_DOTALL ;
45+ import static com .oracle .graal .python .builtins .modules .re .TRegexCache .FLAG_IGNORECASE ;
46+ import static com .oracle .graal .python .builtins .modules .re .TRegexCache .FLAG_LOCALE ;
47+ import static com .oracle .graal .python .builtins .modules .re .TRegexCache .FLAG_MULTILINE ;
48+ import static com .oracle .graal .python .builtins .modules .re .TRegexCache .FLAG_UNICODE ;
49+ import static com .oracle .graal .python .builtins .modules .re .TRegexCache .FLAG_VERBOSE ;
50+ import static com .oracle .graal .python .nodes .BuiltinNames .T__SRE ;
51+ import static com .oracle .graal .python .nodes .ErrorMessages .BAD_CHAR_IN_GROUP_NAME ;
52+ import static com .oracle .graal .python .nodes .ErrorMessages .BAD_ESCAPE_END_OF_STRING ;
53+ import static com .oracle .graal .python .nodes .ErrorMessages .BAD_ESCAPE_S ;
54+ import static com .oracle .graal .python .nodes .ErrorMessages .INVALID_GROUP_REFERENCE ;
55+ import static com .oracle .graal .python .nodes .ErrorMessages .MISSING_GROUP_NAME ;
56+ import static com .oracle .graal .python .nodes .ErrorMessages .MISSING_LEFT_ANGLE_BRACKET ;
57+ import static com .oracle .graal .python .nodes .ErrorMessages .MISSING_RIGHT_ANGLE_BRACKET ;
58+ import static com .oracle .graal .python .nodes .ErrorMessages .OCTAL_ESCAPE_OUT_OF_RANGE ;
59+ import static com .oracle .graal .python .nodes .ErrorMessages .UNKNOWN_GROUP_NAME ;
60+ import static com .oracle .graal .python .nodes .SpecialMethodNames .J___CLASS_GETITEM__ ;
61+ import static com .oracle .graal .python .nodes .SpecialMethodNames .J___COPY__ ;
62+ import static com .oracle .graal .python .nodes .SpecialMethodNames .J___DEEPCOPY__ ;
63+ import static com .oracle .graal .python .util .PythonUtils .TS_ENCODING ;
64+ import static com .oracle .graal .python .util .PythonUtils .TS_ENCODING_BINARY ;
65+ import static com .oracle .graal .python .util .PythonUtils .tsLiteral ;
66+
67+ import java .util .ArrayList ;
68+ import java .util .LinkedHashMap ;
69+ import java .util .List ;
70+
4371import com .oracle .graal .python .PythonLanguage ;
4472import com .oracle .graal .python .annotations .ArgumentClinic ;
4573import com .oracle .graal .python .annotations .Builtin ;
72100import com .oracle .graal .python .nodes .call .CallNode ;
73101import com .oracle .graal .python .nodes .function .PythonBuiltinBaseNode ;
74102import com .oracle .graal .python .nodes .function .PythonBuiltinNode ;
103+ import com .oracle .graal .python .nodes .function .builtins .PythonBinaryBuiltinNode ;
75104import com .oracle .graal .python .nodes .function .builtins .PythonClinicBuiltinNode ;
76105import com .oracle .graal .python .nodes .function .builtins .PythonQuaternaryClinicBuiltinNode ;
77106import com .oracle .graal .python .nodes .function .builtins .PythonUnaryBuiltinNode ;
113142import com .oracle .truffle .api .strings .TruffleStringBuilder ;
114143import com .oracle .truffle .api .strings .TruffleStringBuilderUTF32 ;
115144
116- import java .util .ArrayList ;
117- import java .util .LinkedHashMap ;
118- import java .util .List ;
119-
120- import static com .oracle .graal .python .builtins .modules .re .TRegexCache .FLAG_ASCII ;
121- import static com .oracle .graal .python .builtins .modules .re .TRegexCache .FLAG_DOTALL ;
122- import static com .oracle .graal .python .builtins .modules .re .TRegexCache .FLAG_IGNORECASE ;
123- import static com .oracle .graal .python .builtins .modules .re .TRegexCache .FLAG_LOCALE ;
124- import static com .oracle .graal .python .builtins .modules .re .TRegexCache .FLAG_MULTILINE ;
125- import static com .oracle .graal .python .builtins .modules .re .TRegexCache .FLAG_UNICODE ;
126- import static com .oracle .graal .python .builtins .modules .re .TRegexCache .FLAG_VERBOSE ;
127- import static com .oracle .graal .python .nodes .BuiltinNames .T__SRE ;
128- import static com .oracle .graal .python .nodes .ErrorMessages .BAD_CHAR_IN_GROUP_NAME ;
129- import static com .oracle .graal .python .nodes .ErrorMessages .BAD_ESCAPE_END_OF_STRING ;
130- import static com .oracle .graal .python .nodes .ErrorMessages .BAD_ESCAPE_S ;
131- import static com .oracle .graal .python .nodes .ErrorMessages .INVALID_GROUP_REFERENCE ;
132- import static com .oracle .graal .python .nodes .ErrorMessages .MISSING_GROUP_NAME ;
133- import static com .oracle .graal .python .nodes .ErrorMessages .MISSING_LEFT_ANGLE_BRACKET ;
134- import static com .oracle .graal .python .nodes .ErrorMessages .MISSING_RIGHT_ANGLE_BRACKET ;
135- import static com .oracle .graal .python .nodes .ErrorMessages .OCTAL_ESCAPE_OUT_OF_RANGE ;
136- import static com .oracle .graal .python .nodes .ErrorMessages .UNKNOWN_GROUP_NAME ;
137- import static com .oracle .graal .python .util .PythonUtils .TS_ENCODING ;
138- import static com .oracle .graal .python .util .PythonUtils .TS_ENCODING_BINARY ;
139- import static com .oracle .graal .python .util .PythonUtils .tsLiteral ;
140-
141145@ CoreFunctions (extendClasses = {PythonBuiltinClassType .PPattern })
142146public final class PatternBuiltins extends PythonBuiltins {
143147
@@ -665,7 +669,7 @@ static Object getScanner(VirtualFrame frame, PPattern self, Object string, int p
665669 }
666670 }
667671
668- @ Builtin (name = "__copy__" , minNumOfPositionalArgs = 1 , parameterNames = {"$self" }, doc = "__copy__($self, /)\n --\n \n " )
672+ @ Builtin (name = J___COPY__ , minNumOfPositionalArgs = 1 , parameterNames = {"$self" }, doc = "__copy__($self, /)\n --\n \n " )
669673 @ GenerateNodeFactory
670674 public abstract static class CopyNode extends PythonBuiltinNode {
671675
@@ -675,7 +679,7 @@ static PPattern copy(PPattern self) {
675679 }
676680 }
677681
678- @ Builtin (name = "__deepcopy__" , minNumOfPositionalArgs = 2 , parameterNames = {"$self" , "memo" }, doc = "__deepcopy__($self, memo, /)\n --\n \n " )
682+ @ Builtin (name = J___DEEPCOPY__ , minNumOfPositionalArgs = 2 , parameterNames = {"$self" , "memo" }, doc = "__deepcopy__($self, memo, /)\n --\n \n " )
679683 @ GenerateNodeFactory
680684 public abstract static class DeepCopyNode extends PythonBuiltinNode {
681685
@@ -685,6 +689,16 @@ static PPattern deepCopy(PPattern self, Object memo) {
685689 }
686690 }
687691
692+ @ Builtin (name = J___CLASS_GETITEM__ , minNumOfPositionalArgs = 2 , isClassmethod = true )
693+ @ GenerateNodeFactory
694+ public abstract static class ClassGetItemNode extends PythonBinaryBuiltinNode {
695+ @ Specialization
696+ static Object classGetItem (Object cls , Object key ,
697+ @ Bind PythonLanguage language ) {
698+ return PFactory .createGenericAlias (language , cls , key );
699+ }
700+ }
701+
688702 /**
689703 * There are multiple nested inner nodes used in {@link SplitNode}. The number at the end of
690704 * each inner node indicates the nesting level.
0 commit comments