@@ -112,20 +112,20 @@ CompilerValue *OperatorBlocks::compileJoin(Compiler *compiler)
112112{
113113 auto string1 = compiler->addInput (" STRING1" );
114114 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);
116116}
117117
118118CompilerValue *OperatorBlocks::compileLetterOf (Compiler *compiler)
119119{
120120 auto letter = compiler->addInput (" LETTER" );
121121 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 )) );
123123}
124124
125125CompilerValue *OperatorBlocks::compileLength (Compiler *compiler)
126126{
127127 auto string = compiler->addInput (" STRING" );
128- return compiler->addFunctionCall ( " operator_length " , Compiler::StaticType::Number, { Compiler::StaticType::String }, { string } );
128+ return compiler->addStringLength ( string);
129129}
130130
131131CompilerValue *OperatorBlocks::compileContains (Compiler *compiler)
@@ -182,35 +182,3 @@ CompilerValue *OperatorBlocks::compileMathOp(Compiler *compiler)
182182 else
183183 return compiler->addConstValue (Value ());
184184}
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