String.length property added
This commit is contained in:
@@ -72,6 +72,7 @@ public class IntrinsicMethods {
|
|||||||
declareIntrinsicFunction("String", "plus", 1, new Concat());
|
declareIntrinsicFunction("String", "plus", 1, new Concat());
|
||||||
|
|
||||||
declareIntrinsicStringMethods();
|
declareIntrinsicStringMethods();
|
||||||
|
declareIntrinsicProperty("String", "length", new StringLength());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void declareIntrinsicStringMethods() {
|
private void declareIntrinsicStringMethods() {
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package org.jetbrains.jet.codegen.intrinsics;
|
||||||
|
|
||||||
|
import com.intellij.psi.PsiElement;
|
||||||
|
import org.jetbrains.jet.codegen.ExpressionCodegen;
|
||||||
|
import org.jetbrains.jet.codegen.JetTypeMapper;
|
||||||
|
import org.jetbrains.jet.codegen.StackValue;
|
||||||
|
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||||
|
import org.objectweb.asm.Type;
|
||||||
|
import org.objectweb.asm.commons.InstructionAdapter;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author alex.tkachman
|
||||||
|
*/
|
||||||
|
public class StringLength implements IntrinsicMethod {
|
||||||
|
@Override
|
||||||
|
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List<JetExpression> arguments, StackValue receiver) {
|
||||||
|
receiver.put(JetTypeMapper.TYPE_OBJECT, v);
|
||||||
|
v.invokevirtual("java/lang/String", "length", "()I");
|
||||||
|
return StackValue.onStack(Type.INT_TYPE);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user