add byte code generation
This commit is contained in:
committed by
Yan Zhulanow
parent
7536170e1d
commit
2801253a9c
@@ -1888,6 +1888,22 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
if (descriptor instanceof PropertyDescriptor) {
|
||||
PropertyDescriptor propertyDescriptor = (PropertyDescriptor) descriptor;
|
||||
|
||||
JetFile file = DescriptorToSourceUtils.getContainingFile(propertyDescriptor);
|
||||
if (file != null && file.getName() == "ANDROIDXML.kt") {
|
||||
|
||||
String userData = (String) file.getUserData(AndroidConst.ANDROID_SYNTHETIC);
|
||||
String androidPackage = file.getUserData(AndroidConst.ANDROID_USER_PACKAGE);
|
||||
|
||||
Type retType = typeMapper.mapType(propertyDescriptor.getReturnType());
|
||||
v.load(0, Type.getType("Landroid/app/Activity;"));
|
||||
v.getstatic(androidPackage.replace(".", "/") + "/R$id",
|
||||
propertyDescriptor.getName().asString(), "I");
|
||||
v.invokevirtual("android/app/Activity", "findViewById", "(I)" + "Landroid/view/View;");
|
||||
v.checkcast(retType);
|
||||
|
||||
return StackValue.onStack(retType);
|
||||
}
|
||||
|
||||
boolean directToField =
|
||||
expression.getReferencedNameElementType() == JetTokens.FIELD_IDENTIFIER && contextKind() != OwnerKind.TRAIT_IMPL;
|
||||
JetExpression r = getReceiverForSelector(expression);
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package org.jetbrains.jet.lang.resolve.android;
|
||||
|
||||
import com.intellij.openapi.util.Key;
|
||||
|
||||
public class AndroidConst {
|
||||
public static final Key<String> ANDROID_SYNTHETIC = Key.create("ANDROID_SYNTHETIC");
|
||||
public static final Key<String> ANDROID_USER_PACKAGE = Key.create("ANDROID_USER_PACKAGE");
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.myapp"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0" >
|
||||
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS"/>
|
||||
<uses-sdk
|
||||
android:minSdkVersion="18"
|
||||
android:targetSdkVersion="18" />
|
||||
<permission android:name="android"></permission>
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/Theme.Sample" >
|
||||
<activity
|
||||
android:name="com.example.android.basiccontactables.MainActivity"
|
||||
android:label="@string/app_name"
|
||||
android:launchMode="singleTop">
|
||||
<meta-data
|
||||
android:name="android.app.searchable"
|
||||
android:resource="@xml/searchable" />
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEARCH" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
||||
Reference in New Issue
Block a user