@@ -112,20 +112,20 @@ CompilerValue *OperatorBlocks::compileJoin(Compiler *compiler)
112
112
{
113
113
auto string1 = compiler->addInput (" STRING1" );
114
114
auto string2 = compiler->addInput (" STRING2" );
115
- return compiler->addFunctionCall ( " operator_join " , Compiler::StaticType::String, { Compiler::StaticType::String, Compiler::StaticType::String }, { string1, string2 } );
115
+ return compiler->createStringConcat ( string1, string2);
116
116
}
117
117
118
118
CompilerValue *OperatorBlocks::compileLetterOf (Compiler *compiler)
119
119
{
120
120
auto letter = compiler->addInput (" LETTER" );
121
121
auto string = compiler->addInput (" STRING" );
122
- return compiler->addFunctionCall ( " operator_letter_of " , Compiler::StaticType::String, { Compiler::StaticType::Number, Compiler::StaticType::String }, { letter, string } );
122
+ return compiler->addStringChar (string, compiler-> createSub ( letter, compiler-> addConstValue ( 1 )) );
123
123
}
124
124
125
125
CompilerValue *OperatorBlocks::compileLength (Compiler *compiler)
126
126
{
127
127
auto string = compiler->addInput (" STRING" );
128
- return compiler->addFunctionCall ( " operator_length " , Compiler::StaticType::Number, { Compiler::StaticType::String }, { string } );
128
+ return compiler->addStringLength ( string);
129
129
}
130
130
131
131
CompilerValue *OperatorBlocks::compileContains (Compiler *compiler)
@@ -182,35 +182,3 @@ CompilerValue *OperatorBlocks::compileMathOp(Compiler *compiler)
182
182
else
183
183
return compiler->addConstValue (Value ());
184
184
}
185
-
186
- extern " C" StringPtr *operator_join (const StringPtr *string1, const StringPtr *string2)
187
- {
188
- StringPtr *ret = string_pool_new (true );
189
- ret->size = string1->size + string2->size ;
190
- string_alloc (ret, ret->size );
191
- memcpy (ret->data , string1->data , string1->size * sizeof (typeof (*string1->data )));
192
- memcpy (ret->data + string1->size , string2->data , (string2->size + 1 ) * sizeof (typeof (*string2->data ))); // +1: null-terminate
193
- return ret;
194
- }
195
-
196
- extern " C" StringPtr *operator_letter_of (double letter, const StringPtr *string)
197
- {
198
- StringPtr *ret = string_pool_new ();
199
-
200
- if (letter < 1 || letter > string->size ) {
201
- string_alloc (ret, 0 );
202
- ret->data [0 ] = u' \0 ' ;
203
- return ret;
204
- }
205
-
206
- string_alloc (ret, 1 );
207
- ret->data [0 ] = string->data [static_cast <size_t >(letter - 1 )];
208
- ret->data [1 ] = u' \0 ' ;
209
- ret->size = 1 ;
210
- return ret;
211
- }
212
-
213
- extern " C" double operator_length (const StringPtr *string)
214
- {
215
- return string->size ;
216
- }
0 commit comments