Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…er-master
  • Loading branch information
bobbylight committed Jun 21, 2015
2 parents 6577703 + de01087 commit f4e0f7b
Show file tree
Hide file tree
Showing 8 changed files with 219 additions and 6 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ group = 'com.fifesoft'
archivesBaseName = 'languagesupport'

dependencies {
compile group: 'org.mozilla', name: 'rhino', version: '1.7R4'
compile group: 'org.mozilla', name: 'rhino', version: '1.7.6'
testCompile group: 'junit', name: 'junit', version: '4.11'
}

Expand Down Expand Up @@ -36,7 +36,7 @@ compileJava {

ext.sharedManifest = manifest {
attributes('Main-Class': 'org.fife.rsta.ac.demo.DemoApp',
'Class-Path': 'rsyntaxtextarea.jar autocomplete.jar rhino-1.7R4.jar',
'Class-Path': 'rsyntaxtextarea.jar autocomplete.jar rhino-1.7.6.jar',
'Specification-Title': 'RSyntaxTextArea Language Support',
'Specification-Version': version,
'Implementation-Title': 'org.fife.ui',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public class ClassFile implements AccessFlags {
public static final String RUNTIME_VISIBLE_ANNOTATIONS = "RuntimeVisibleAnnotations";
public static final String SIGNATURE = "Signature";
public static final String SOURCE_FILE = "SourceFile";
public static final String BOOTSTRAP_METHODS = "BootstrapMethods";

/**
* The 4-byte class file header, "<code>CAFEBABE</code>".
Expand Down Expand Up @@ -542,6 +543,13 @@ private AttributeInfo readAttribute(DataInputStream in) throws IOException {
ai = sf;
}

else if (BOOTSTRAP_METHODS.equals(attrName)) { // 4.7.23
//String name = getClassFile().getClassName(false) + "." + getName();
//System.out.println(name + ": Attribute " + attrName + " not supported");
Util.skipBytes(in, attributeLength);
//ai = null;
}

else if (SIGNATURE.equals(attrName)) { // 4.8.8
int signatureIndex = in.readUnsignedShort();
String sig = getUtf8ValueFromConstantPool(signatureIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,14 @@ public List<String> getClassParamTypes() {
int colon = temp.indexOf(':', offs);
while (offs<temp.length() && colon>-1) {
String ident = temp.substring(offs, colon);
char ch = temp.charAt(colon+1);
int colonCount = 1;
char ch = temp.charAt(colon+colonCount);
if (ch==':') { // sometimes, there is another ':'
colonCount++;
ch = temp.charAt(colon+colonCount);
}
if (ch=='L') { // A ClassTypeSignature
int semicolon = temp.indexOf(';', colon+2);
int semicolon = temp.indexOf(';', colon+colonCount+1);
if (semicolon>-1) {
//String type = temp.substring(colon+2, semicolon);
// TODO: ...
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* 03/21/2010
*
* Copyright (C) 2010 Robert Futrell
* robert_futrell at users.sourceforge.net
* http://fifesoft.com/rsyntaxtextarea
*
* This library is distributed under a modified BSD license. See the included
* RSTALanguageSupport.License.txt file for details.
*/
package org.fife.rsta.ac.java.classreader.constantpool;

/**
* Class representing a <code>CONSTANT_InvokeDynamic_info</code> structure.
*
* @author Robert Futrell
* @version 1.0
*/
public class ConstantInvokeDynamicInfo extends ConstantPoolInfo {

private int bootstrapMethodAttrIndex;

private int nameAndTypeIndex;


/**
* Constructor.
*
* @param bootstrapMethodAttrIndex
* @param nameAndTypeIndex
*/
public ConstantInvokeDynamicInfo(int bootstrapMethodAttrIndex, int nameAndTypeIndex) {
super(CONSTANT_InvokeDynamic);
this.bootstrapMethodAttrIndex = bootstrapMethodAttrIndex;
this.nameAndTypeIndex = nameAndTypeIndex;
}


public int getBootstrapMethodAttrIndex() {
return bootstrapMethodAttrIndex;
}


public int getNameAndTypeIndex() {
return nameAndTypeIndex;
}


/**
* Returns a string representation of this object. Useful for debugging.
*
* @return A string representation of this object.
*/
@Override
public String toString() {
return "[ConstantInvokeDynamicInfo: " +
"bootstrapMethodAttrIndex=" + getBootstrapMethodAttrIndex() +
"; nameAndTypeIndex=" + getNameAndTypeIndex() +
"]";
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* 03/21/2010
*
* Copyright (C) 2010 Robert Futrell
* robert_futrell at users.sourceforge.net
* http://fifesoft.com/rsyntaxtextarea
*
* This library is distributed under a modified BSD license. See the included
* RSTALanguageSupport.License.txt file for details.
*/
package org.fife.rsta.ac.java.classreader.constantpool;

/**
* Class representing a <code>CONSTANT_MethodHandle</code> structure.
*
* @author Robert Futrell
* @version 1.0
*/
public class ConstantMethodHandleInfo extends ConstantPoolInfo {

private int referenceKind;

private int referenceIndex;


/**
* Constructor.
*
* @param referenceKind
* @param referenceIndex
*/
public ConstantMethodHandleInfo(int referenceKind, int referenceIndex) {
super(CONSTANT_MethodHandle);
this.referenceKind = referenceKind;
this.referenceIndex = referenceIndex;
}


public int getReferenceKind() {
return referenceKind;
}

public int getReferenceIndex() {
return referenceIndex;
}


/**
* Returns a string representation of this object. Useful for debugging.
*
* @return A string representation of this object.
*/
@Override
public String toString() {
return "[ConstantMethodHandleInfo: " +
"referenceKind=" + getReferenceKind() +
"; referenceIndex=" + getReferenceIndex() +
"]";
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* 03/21/2010
*
* Copyright (C) 2010 Robert Futrell
* robert_futrell at users.sourceforge.net
* http://fifesoft.com/rsyntaxtextarea
*
* This library is distributed under a modified BSD license. See the included
* RSTALanguageSupport.License.txt file for details.
*/
package org.fife.rsta.ac.java.classreader.constantpool;

/**
* Class representing a <code>CONSTANT_MethodType</code> structure.
*
* @author Robert Futrell
* @version 1.0
*/
public class ConstantMethodTypeInfo extends ConstantPoolInfo {

private int descriptorIndex;

/**
* Constructor.
*
* @param descriptorIndex
*/
public ConstantMethodTypeInfo(int descriptorIndex) {
super(CONSTANT_MethodType);
this.descriptorIndex = descriptorIndex;
}


public int getDescriptorIndex() {
return descriptorIndex;
}


/**
* Returns a string representation of this object. Useful for debugging.
*
* @return A string representation of this object.
*/
@Override
public String toString() {
return "[ConstantMethodTypeInfo: " +
"bootstrapMethodAttrIndex=" + getDescriptorIndex() +
"]";
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,23 @@ public static ConstantPoolInfo readConstantPoolInfo(ClassFile cf,
cpi = new ConstantUtf8Info(byteArray);
break;

case CONSTANT_MethodHandle:
int referenceKind = in.read();
int referenceIndex = in.readUnsignedShort();
cpi = new ConstantMethodHandleInfo(referenceKind, referenceIndex);
break;

case CONSTANT_MethodType:
descriptorIndex = in.readUnsignedShort();
cpi = new ConstantMethodTypeInfo(descriptorIndex);
break;

case CONSTANT_InvokeDynamic:
int bootstrapMethodAttrIndex = in.readUnsignedShort();
nameAndTypeIndex = in.readUnsignedShort();
cpi = new ConstantInvokeDynamicInfo(bootstrapMethodAttrIndex, nameAndTypeIndex);
break;

default:
throw new IOException("Unknown tag for constant pool info: " + tag);

Expand All @@ -107,4 +124,4 @@ public static ConstantPoolInfo readConstantPoolInfo(ClassFile cf,
}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,10 @@ interface ConstantTypes {

public static final int CONSTANT_Utf8 = 1;

}
public static final int CONSTANT_MethodHandle = 15;

public static final int CONSTANT_MethodType = 16;

public static final int CONSTANT_InvokeDynamic = 18;

}

0 comments on commit f4e0f7b

Please sign in to comment.