Skip to content

Commit fd7161c

Browse files
committed
wip
1 parent 6d526e0 commit fd7161c

File tree

10 files changed

+75
-22
lines changed

10 files changed

+75
-22
lines changed

Dockerfile.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM ubuntu:noble
2+
3+
RUN apt update && apt install -y pkg-config build-essential autoconf bison re2c \
4+
libxml2-dev libsqlite3-dev cmake gdb
5+
WORKDIR /app
6+
7+
COPY ./sapi/cli/php php
8+
RUN chmod +x /app/php

LE.md

Whitespace-only changes.

Zend/zend.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,16 +144,17 @@ struct _zend_inheritance_cache_entry {
144144
zend_class_entry *traits_and_interfaces[1];
145145
};
146146

147-
typedef struct _zend_generic_type {
147+
typedef struct _zend_type_parameter {
148148
struct _zend_generic_type *elements;
149149
size_t element_count;
150-
char *type;
151-
} zend_generic_type;
150+
zend_string *name;
151+
} zend_type_parameter;
152152

153153
struct _zend_class_entry {
154154
// TYPE HERE
155155
char type;
156-
zend_generic_type *generic_type;
156+
size_t generic_type_count;
157+
zend_type_parameter *generic_type;
157158
zend_string *name;
158159
/* class_entry or string depending on ZEND_ACC_LINKED */
159160
union {

Zend/zend_ast.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ enum _zend_ast_kind {
156156
ZEND_AST_NAMED_ARG,
157157
ZEND_AST_PARENT_PROPERTY_HOOK_CALL,
158158

159+
ZEND_AST_GENERIC_TYPE,
160+
159161
/* 3 child nodes */
160162
ZEND_AST_METHOD_CALL = 3 << ZEND_AST_NUM_CHILDREN_SHIFT,
161163
ZEND_AST_NULLSAFE_METHOD_CALL,

Zend/zend_compile.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,9 +483,11 @@ typedef struct _zend_internal_arg_info {
483483
} zend_internal_arg_info;
484484

485485
/* arg_info for user functions */
486+
//LEHP-RELEVANT
486487
typedef struct _zend_arg_info {
487488
zend_string *name;
488489
zend_type type;
490+
//LEHP-ASSUMPTION: LEPHP code evaluated at runtime
489491
zend_string *default_value;
490492
} zend_arg_info;
491493

Zend/zend_language_scanner.l

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,30 +1537,14 @@ OPTIONAL_WHITESPACE_OR_COMMENTS ({WHITESPACE}|{MULTI_LINE_COMMENT}|{SINGLE_LINE_
15371537
RETURN_TOKEN_WITH_IDENT(T_PRINT);
15381538
}
15391539

1540-
<ST_IN_SCRIPTING>"<"{LABEL}">" {
1541-
yyless(1);
1542-
yy_push_state(ST_GENERIC);
1540+
<ST_IN_SCRIPTING> "!🥖" {
15431541
RETURN_TOKEN(T_GENERIC_START);
15441542
}
15451543

1546-
<ST_GENERIC>{LABEL} {
1547-
RETURN_TOKEN_WITH_STR(T_STRING, 0);
1548-
}
1549-
1550-
<ST_GENERIC>"," {
1551-
RETURN_TOKEN(',');
1552-
}
1553-
1554-
<ST_GENERIC>">" {
1555-
yy_pop_state();
1544+
<ST_IN_SCRIPTING> "!🥥" {
15561545
RETURN_TOKEN(T_GENERIC_END);
15571546
}
15581547

1559-
<ST_GENERIC>{WHITESPACE} {
1560-
HANDLE_NEWLINES(yytext, yyleng);
1561-
RETURN_TOKEN(T_WHITESPACE);
1562-
}
1563-
15641548
<ST_IN_SCRIPTING>"class" {
15651549
RETURN_TOKEN_WITH_IDENT(T_CLASS);
15661550
}

Zend/zend_types.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ typedef struct {
142142
zend_type types[1];
143143
} zend_type_list;
144144

145+
//LEHP-RELEVANT new generic type
145146
#define _ZEND_TYPE_EXTRA_FLAGS_SHIFT 25
146147
#define _ZEND_TYPE_MASK ((1u << 25) - 1)
147148
/* Only one of these bits may be set. */
@@ -553,11 +554,20 @@ typedef struct _HashTableIterator {
553554
uint32_t next_copy; // circular linked list via index into EG(ht_iterators)
554555
} HashTableIterator;
555556

557+
typedef struct _zend_generic_value {
558+
struct _zend_generic_value *elements;
559+
size_t element_count;
560+
zend_string *name;
561+
} zend_generic_value;
562+
556563
struct _zend_object {
557564
zend_refcounted_h gc;
558565
uint32_t handle; // TODO: may be removed ???
559566
uint32_t extra_flags; /* OBJ_EXTRA_FLAGS() */
560567
zend_class_entry *ce;
568+
//LEHP-OPTIMIZATION: COPY THIS FROM _zend_class_entry
569+
size_t generic_value_count;
570+
zend_generic_value *generic_values;
561571
const zend_object_handlers *handlers;
562572
HashTable *properties;
563573
zval properties_table[1];

t.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
class test!🥖K!🥖!🥖bruh!🥥!🥥{
3+
public function __construct(
4+
public K $lol
5+
){
6+
}
7+
}
8+
9+
class bruh {
10+
public function __construct(
11+
public array!🥖bruh!🥥 $le
12+
){}
13+
14+
public function test(test!🥖bruh!🥥 $le): test!🥖bruh!🥥 {
15+
}
16+
};
17+
18+
19+
echo "hi\n";

t2.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
class test<K>{
3+
public function __construct(
4+
public K $lol
5+
){
6+
}
7+
}
8+
9+
echo "hi\n";

tree.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
$tokens = token_get_all('<?php
3+
4+
class test!🥖K!🥥{
5+
public function __construct(
6+
public !🥖K!🥥 $lol
7+
){
8+
}
9+
}
10+
11+
$t = new test!🥖bruh!🥥(new bruh(4));
12+
13+
14+
$le = [new bruh()]
15+
array_map(fn (test!🥖bruh!🥥 $klfe)=>, $le)
16+
echo "hi\n";');
17+
18+
var_export($tokens);

0 commit comments

Comments
 (0)