Skip to content

Commit d70ab8e

Browse files
committed
feat: store strings opcodes playground
1 parent 5a3b80e commit d70ab8e

File tree

2 files changed

+105
-0
lines changed

2 files changed

+105
-0
lines changed

playground/strings.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
var_dump(
4+
'single quotes',
5+
"double quotes",
6+
7+
'escaped single quote \' in single quotes',
8+
'escaped double quote \" in single quotes',
9+
10+
"escaped single quote \' in double quotes",
11+
"escaped double quote \" in double quotes",
12+
13+
'quoted "string" in single quoted string',
14+
15+
'concatenated' . 'string',
16+
'concatenated' . "string2",
17+
'concatenated with const' . PHP_EOL . 'string',
18+
19+
sprintf('templated string'),
20+
sprintf('templated string with %s', 'variable'),
21+
sprintf('templated string with "%s" in quotes', 'variable'),
22+
23+
base64_encode("base64 encoded string"),
24+
25+
str_repeat('repeated string', 3),
26+
str_replace('repeated', 'replaced', 'repeated string'),
27+
substr('repeated string', 9),
28+
substr('repeated string', 0, -6),
29+
30+
ord('A'),
31+
mb_ord('A'),
32+
33+
chr(34),
34+
mb_chr(34),
35+
36+
explode(' ', 'explode me'),
37+
implode(' ', ['implode', 'me']),
38+
39+
str_split('split string'),
40+
mb_str_split('split string'),
41+
42+
str_starts_with('php', 'p'),
43+
44+
str_pad('pad', 10, '-'),
45+
str_shuffle('shuffled string'),
46+
strcmp('str1', 'str2'),
47+
48+
);

playground/strings.phpo

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
2+
$_main:
3+
; (lines=51, args=0, vars=0, tmps=2)
4+
; (after optimizer)
5+
; /Users/xepozz/IdeaProjects/xepozz/php-opcodes-lang-plugin/playground/strings.phpo:1-48
6+
0000 EXT_STMT
7+
0001 INIT_FCALL 30 576 string("var_dump")
8+
0002 SEND_VAL string("single quotes") 1
9+
0003 SEND_VAL string("double quotes") 2
10+
0004 SEND_VAL string("escaped single quote ' in single quotes") 3
11+
0005 SEND_VAL string("escaped double quote \\\" in single quotes") 4
12+
0006 SEND_VAL string("escaped single quote \\' in double quotes") 5
13+
0007 SEND_VAL string("escaped double quote \" in double quotes") 6
14+
0008 SEND_VAL string("quoted \"string\" in single quoted string") 7
15+
0009 SEND_VAL string("concatenatedstring") 8
16+
0010 SEND_VAL string("concatenatedstring2") 9
17+
0011 SEND_VAL string("concatenated with const
18+
string") 10
19+
0012 SEND_VAL string("templated string") 11
20+
0013 SEND_VAL string("templated string with variable") 12
21+
0014 SEND_VAL string("templated string with \"variable\" in quotes") 13
22+
0015 SEND_VAL string("YmFzZTY0IGVuY29kZWQgc3RyaW5n") 14
23+
0016 SEND_VAL string("repeated stringrepeated stringrepeated string") 15
24+
0017 SEND_VAL string("replaced string") 16
25+
0018 SEND_VAL string("string") 17
26+
0019 SEND_VAL string("repeated ") 18
27+
0020 SEND_VAL int(65) 19
28+
0021 INIT_FCALL 1 112 string("mb_ord")
29+
0022 SEND_VAL string("A") 1
30+
0023 V0 = DO_ICALL
31+
0024 SEND_VAR V0 20
32+
0025 SEND_VAL string("\"") 21
33+
0026 INIT_FCALL 1 112 string("mb_chr")
34+
0027 SEND_VAL int(34) 1
35+
0028 V0 = DO_ICALL
36+
0029 SEND_VAR V0 22
37+
0030 SEND_VAL array(...) 23
38+
0031 SEND_VAL string("implode me") 24
39+
0032 SEND_VAL array(...) 25
40+
0033 INIT_FCALL 1 112 string("mb_str_split")
41+
0034 SEND_VAL string("split string") 1
42+
0035 V0 = DO_ICALL
43+
0036 SEND_VAR V0 26
44+
0037 SEND_VAL bool(true) 27
45+
0038 INIT_FCALL 3 144 string("str_pad")
46+
0039 SEND_VAL string("pad") 1
47+
0040 SEND_VAL int(10) 2
48+
0041 SEND_VAL string("-") 3
49+
0042 V0 = DO_ICALL
50+
0043 SEND_VAR V0 28
51+
0044 INIT_FCALL 1 112 string("str_shuffle")
52+
0045 SEND_VAL string("shuffled string") 1
53+
0046 V0 = DO_ICALL
54+
0047 SEND_VAR V0 29
55+
0048 SEND_VAL int(-1) 30
56+
0049 DO_ICALL
57+
0050 RETURN int(1)

0 commit comments

Comments
 (0)