soot.tagkit.Tag Java Examples

The following examples show how to use soot.tagkit.Tag. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AXmlHandler.java    From JAADAS with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns the Android resource Id of the attribute which has the given name.
 * 
 * @param	name	the attribute's name.
 * @return	the resource Id defined by Android or -1 if the attribute does not exist.
 * @see		android.R.attr
 */
public static int getAttributeResourceId(String name) {
	// try to get attribute's resource Id from Androids R class. Since we
	// don't want a hard-coded reference to the Android classes, we maintain
	// our own list.
	if (name.equals("name"))
		return resId_name;
	else if (name.equals("maxSdkVersion"))
		return resId_maxSdkVersion;
	else if (name.equals("minSdkVersion"))
		return resId_minSdkVersion;
	else if (name.equals("onClick"))
		return resId_onClick;
	
	// If we couldn't find the value, try to find Android's R class in Soot
	SootClass rClass = Scene.v().forceResolve("android.R$attr", SootClass.BODIES);
	if (!rClass.declaresFieldByName(name))
		return -1;
	SootField idField = rClass.getFieldByName(name);
	for (Tag t : idField.getTags())
		if (t instanceof IntegerConstantValueTag) {
			IntegerConstantValueTag cvt = (IntegerConstantValueTag) t;
			return cvt.getIntValue();
		}
	return -1;
}
 
Example #2
Source File: SootClassBuilder.java    From JAADAS with GNU General Public License v3.0 6 votes vote down vote up
@Override
public FieldVisitor visitField(int access, String name,
		String desc, String signature, Object value) {
	soot.Type type = AsmUtil.toJimpleType(desc);
	addDep(type);
	SootField field = new SootField(name, type, access);
	Tag tag;
	if (value instanceof Integer)
		tag = new IntegerConstantValueTag((Integer) value);
	else if (value instanceof Float)
		tag = new FloatConstantValueTag((Float) value);
	else if (value instanceof Long)
		tag = new LongConstantValueTag((Long) value);
	else if (value instanceof Double)
		tag = new DoubleConstantValueTag((Double) value);
	else if (value instanceof String)
		tag = new StringConstantValueTag(value.toString());
	else
		tag = null;
	if (tag != null)
		field.addTag(tag);
	if (signature != null)
		field.addTag(new SignatureTag(signature));
	klass.addField(field);
	return new FieldBuilder(field, this);
}
 
Example #3
Source File: JavaAttribute.java    From JAADAS with GNU General Public License v3.0 6 votes vote down vote up
public void printAllTags(PrintWriter writer){
    this.writerOut = writer;
    if (tags != null) {
        Iterator<Tag> it = tags.iterator();
        while (it.hasNext()){
            printAttributeTag(it.next());
        }
    }
    if (vbAttrs != null) {
        Iterator<PosColorAttribute> vbIt = vbAttrs.iterator();
        while (vbIt.hasNext()){
            PosColorAttribute attr = vbIt.next();
            if (attr.hasColor()){
                startPrintValBoxAttr();
                printSourcePositionAttr(attr.javaStartPos(), attr.javaEndPos());
                printJimplePositionAttr(attr.jimpleStartPos(), attr.jimpleEndPos());
                //printColorAttr(attr.color().red(), attr.color().green(), attr.color().blue(), attr.color().fg());
                endPrintValBoxAttr();
            }
        }
    }
}
 
Example #4
Source File: DexPrinter.java    From JAADAS with GNU General Public License v3.0 6 votes vote down vote up
private Set<Annotation> buildMethodParameterAnnotations(SootMethod m,
		final int paramIdx) {
	Set<String> skipList = new HashSet<String>();
	Set<Annotation> annotations = buildCommonAnnotations(m, skipList);
	
	for (Tag t : m.getTags()) {
        if (t.getName().equals("VisibilityParameterAnnotationTag")) {
            VisibilityParameterAnnotationTag vat = (VisibilityParameterAnnotationTag)t;
            List<ImmutableAnnotation> visibilityItems = buildVisibilityParameterAnnotationTag
            		(vat, skipList, paramIdx);
        	annotations.addAll(visibilityItems);
        }
	}
	
	return annotations;
}
 
Example #5
Source File: StmtHelper.java    From soot-infoflow-android-iccta with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Copy all the tags of {from} to {to}, if {to} already contain the copied tag, then overwrite it.
 * 
 * @param from
 * @param to
 */
public static void copyTags(Unit from, Unit to)
{
	List<Tag> tags = from.getTags();
	
	for (Tag tag : tags)
	{
		to.removeTag(tag.getName());  //exception??
		
		to.addTag(tag);
	}
}
 
Example #6
Source File: AsmMethodSource.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
void setUnit(AbstractInsnNode insn, Unit u) {
	if (Options.v().keep_line_number() && lastLineNumber >= 0) {
		Tag lineTag = u.getTag("LineNumberTag");
		if (lineTag == null) {
			lineTag = new LineNumberTag(lastLineNumber);
			u.addTag(lineTag);
		}
		else if (((LineNumberTag) lineTag).getLineNumber() != lastLineNumber)
			throw new RuntimeException("Line tag mismatch");
	}
	
	Unit o = units.put(insn, u);
	if (o != null)
		throw new AssertionError(insn.getOpcode() + " already has a unit, " + o);
}
 
Example #7
Source File: DavaPrinter.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
/**
 *   Prints out the method corresponding to b Body, (declaration and body),
 *   in the textual format corresponding to the IR used to encode b body.
 *
 *   @param out a PrintWriter instance to print to.
 */
private void printTo(Body b, PrintWriter out) {
    b.validate();

    String decl = b.getMethod().getDavaDeclaration();

    {
        out.println("    " + decl);
        for( Iterator<Tag> tIt = b.getMethod().getTags().iterator(); tIt.hasNext(); ) {
            final Tag t = tIt.next();
            if (Options.v().print_tags_in_output()){
                out.println(t);
            }
        }
        out.println("    {");


 /*
   The locals are now printed out from within the toString method of ASTMethodNode
   Nomair A Naeem 10-MARCH-2005
 */
        //printLocalsInBody(b, out);
    }

    printStatementsInBody(b, out);

    out.println("    }");

}
 
Example #8
Source File: JavaAttribute.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
private int getJimpleLnOfHost(Host h){
Iterator<Tag> it = h.getTags().iterator();
while (it.hasNext()){
	Tag t = it.next();
	if (t instanceof JimpleLineNumberTag) {
		return ((JimpleLineNumberTag)t).getStartLineNumber();
	}
}
return 0;
  }
 
Example #9
Source File: JavaAttribute.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
private int getJavaLnOfHost(Host h){
	Iterator<Tag> it = h.getTags().iterator();
	while (it.hasNext()){
		Tag t = it.next();
		//G.v().out.println(t.getClass().toString());
		if (t instanceof SourceLnPosTag) {
			//G.v().out.println("t is LineNumberTag");
			return ((SourceLnPosTag)t).startLn();
		}
           else if (t instanceof LineNumberTag){
               return (new Integer(((LineNumberTag)t).toString())).intValue();
           }
	}
	return 0;
}
 
Example #10
Source File: JavaAttribute.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
public void printInfoTags(PrintWriter writer){
    this.writerOut = writer;
    Iterator<Tag> it = tags.iterator();
    while (it.hasNext()){
        printAttributeTag(it.next());
    }
}
 
Example #11
Source File: Attribute.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
private int getJimpleLnOfHost(Host h){
	Iterator<Tag> it = h.getTags().iterator();
	while (it.hasNext()){
		Tag t = it.next();
		if (t instanceof JimpleLineNumberTag) {
			return ((JimpleLineNumberTag)t).getStartLineNumber();
		}
	}
	return 0;
}
 
Example #12
Source File: Attribute.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
private int getJavaLnOfHost(Host h){
	Iterator<Tag> it = h.getTags().iterator();
	while (it.hasNext()){
		Tag t = it.next();
		if (t instanceof SourceLnPosTag) {
			return ((SourceLnPosTag)t).startLn();
		}
           else if (t instanceof LineNumberTag){
               return (new Integer(((LineNumberTag)t).toString())).intValue();
           }
	}
	return 0;
}
 
Example #13
Source File: AbstractASMBackend.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Emits the bytecode for all attributes of a method
 * @param fv The MethodVisitor to emit the bytecode to
 * @param f The SootMethod the bytecode is to be emitted for
 */
protected void generateAttributes(MethodVisitor mv, SootMethod m) {
    for (Tag t : m.getTags()) {
        if (t instanceof Attribute) {
            org.objectweb.asm.Attribute a = createASMAttribute((Attribute) t);
            mv.visitAttribute(a);
        }
    }
}
 
Example #14
Source File: AbstractASMBackend.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Emits the bytecode for all attributes of a field
 * @param fv The FieldVisitor to emit the bytecode to
 * @param f The SootField the bytecode is to be emitted for
 */
protected void generateAttributes(FieldVisitor fv, SootField f) {
    for (Tag t : f.getTags()) {
        if (t instanceof Attribute) {
            org.objectweb.asm.Attribute a = createASMAttribute((Attribute) t);
            fv.visitAttribute(a);
        }
    }
}
 
Example #15
Source File: AbstractASMBackend.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
/**
* Emits the bytecode for all attributes of the class
*/
  protected void generateAttributes() {
      for (Tag t : sc.getTags()) {
          if (t instanceof Attribute) {
              cv.visitAttribute(createASMAttribute((Attribute) t));
          }
      }
  }
 
Example #16
Source File: TaggedInstruction.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
public Tag getTag() {
	if (instructionTag == null) {
		throw new RuntimeException("Must tag instruction first! (0x"
				+ Integer.toHexString(codeAddress) + ": " + instruction
				+ ")");
	}
	return instructionTag;
}
 
Example #17
Source File: DexField.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Add constant tag. Should only be called if field is final.
 * @param df
 * @param sf
 */
private static void addConstantTag(SootField df, Field sf) {
    Tag tag = null;

    EncodedValue ev = sf.getInitialValue();

    if (ev instanceof BooleanEncodedValue) {
      tag = new IntegerConstantValueTag(((BooleanEncodedValue) ev).getValue() ==true?1:0);
    } else if (ev instanceof ByteEncodedValue) {
      tag = new IntegerConstantValueTag(((ByteEncodedValue) ev).getValue());
    } else if (ev instanceof CharEncodedValue) {
      tag = new IntegerConstantValueTag(((CharEncodedValue) ev).getValue());
    } else if (ev instanceof DoubleEncodedValue) {
      tag = new DoubleConstantValueTag(((DoubleEncodedValue) ev).getValue());
    } else if (ev instanceof FloatEncodedValue) {
      tag = new FloatConstantValueTag(((FloatEncodedValue) ev).getValue());
    } else if (ev instanceof IntEncodedValue) {
      tag = new IntegerConstantValueTag(((IntEncodedValue) ev).getValue());
    } else if (ev instanceof LongEncodedValue) {
      tag = new LongConstantValueTag(((LongEncodedValue) ev).getValue());
    } else if (ev instanceof ShortEncodedValue) {
      tag = new IntegerConstantValueTag(((ShortEncodedValue) ev).getValue());
    } else if (ev instanceof StringEncodedValue) {
      tag = new StringConstantValueTag(((StringEncodedValue) ev).getValue());
    }

    if (tag != null)
      df.addTag(tag);
}
 
Example #18
Source File: DexPrinter.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
private Set<Annotation> buildMethodAnnotations(SootMethod m) {
	Set<String> skipList = new HashSet<String>();
	Set<Annotation> annotations = buildCommonAnnotations(m, skipList);
	
	for (Tag t : m.getTags()) {
        if (t.getName().equals("VisibilityAnnotationTag")){
            List<ImmutableAnnotation> visibilityItems = buildVisibilityAnnotationTag
            		((VisibilityAnnotationTag) t, skipList);
        	annotations.addAll(visibilityItems);
        }
	}
	
	return annotations;
}
 
Example #19
Source File: PAG.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
private void addNodeTag( Node node, SootMethod m ) {
    if( nodeToTag != null ) {
        Tag tag;
        if( m == null ) {
            tag = new StringTag( node.toString() );
        } else {
            tag = new LinkTag( node.toString(), m, m.getDeclaringClass().getName() );
        }
        nodeToTag.put( node, tag );
    }
}
 
Example #20
Source File: DexPrinter.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
private Set<Annotation> buildFieldAnnotations(SootField f) {
	Set<String> skipList = new HashSet<String>();
	Set<Annotation> annotations = buildCommonAnnotations(f, skipList);
	
	for (Tag t : f.getTags()) {
        if (t.getName().equals("VisibilityAnnotationTag")){
            List<ImmutableAnnotation> visibilityItems = buildVisibilityAnnotationTag
            		((VisibilityAnnotationTag) t, skipList);
        	annotations.addAll(visibilityItems);
        }
	}
		
	return annotations;
}
 
Example #21
Source File: DexPrinter.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
private EncodedValue makeConstantItem(SootField sf, Tag t) {
    if (!(t instanceof ConstantValueTag))
        throw new RuntimeException("error: t not ConstantValueTag.");

    if (t instanceof IntegerConstantValueTag) {
        Type sft = sf.getType();
        IntegerConstantValueTag i = (IntegerConstantValueTag) t;
        if (sft instanceof BooleanType) {
            int v = i.getIntValue();
            if (v == 0) {
                return ImmutableBooleanEncodedValue.FALSE_VALUE;
            } else if (v == 1) {
            	return ImmutableBooleanEncodedValue.TRUE_VALUE;
            } else {
                throw new RuntimeException(
                        "error: boolean value from int with value != 0 or 1.");
            }
        } else if (sft instanceof CharType) {
        	return new ImmutableCharEncodedValue((char) i.getIntValue());
        } else if (sft instanceof ByteType) {
        	return new ImmutableByteEncodedValue((byte) i.getIntValue());
        } else if (sft instanceof IntType) {
        	return new ImmutableIntEncodedValue(i.getIntValue());
        } else if (sft instanceof ShortType) {
        	return new ImmutableShortEncodedValue((short) i.getIntValue());
        } else {
            throw new RuntimeException("error: unexpected constant tag type: " + t
                    + " for field " + sf);
        }
    } else if (t instanceof LongConstantValueTag) {
        LongConstantValueTag l = (LongConstantValueTag) t;
        return new ImmutableLongEncodedValue(l.getLongValue());
    } else if (t instanceof DoubleConstantValueTag) {
        DoubleConstantValueTag d = (DoubleConstantValueTag) t;
        return new ImmutableDoubleEncodedValue(d.getDoubleValue());
    } else if (t instanceof FloatConstantValueTag) {
        FloatConstantValueTag f = (FloatConstantValueTag) t;
        return new ImmutableFloatEncodedValue(f.getFloatValue());
    } else if (t instanceof StringConstantValueTag) {
        StringConstantValueTag s = (StringConstantValueTag) t;
        return new ImmutableStringEncodedValue(s.getStringValue());
    } else
    	throw new RuntimeException("Unexpected constant type");
}
 
Example #22
Source File: AndroidSourceSinkManager.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Finds the last assignment to the given local representing a resource ID
 * by searching upwards from the given statement
 * 
 * @param stmt
 *            The statement from which to look backwards
 * @param local
 *            The variable for which to look for assignments
 * @return The last value assigned to the given variable
 */
private Integer findLastResIDAssignment(Stmt stmt, Local local, BiDiInterproceduralCFG<Unit, SootMethod> cfg, Set<Stmt> doneSet) {
	if (!doneSet.add(stmt))
		return null;

	// If this is an assign statement, we need to check whether it changes
	// the variable we're looking for
	if (stmt instanceof AssignStmt) {
		AssignStmt assign = (AssignStmt) stmt;
		if (assign.getLeftOp() == local) {
			// ok, now find the new value from the right side
			if (assign.getRightOp() instanceof IntConstant)
				return ((IntConstant) assign.getRightOp()).value;
			else if (assign.getRightOp() instanceof FieldRef) {
				SootField field = ((FieldRef) assign.getRightOp()).getField();
				for (Tag tag : field.getTags())
					if (tag instanceof IntegerConstantValueTag)
						return ((IntegerConstantValueTag) tag).getIntValue();
					else
						System.err.println("Constant " + field + " was of unexpected type");
			} else if (assign.getRightOp() instanceof InvokeExpr) {
				InvokeExpr inv = (InvokeExpr) assign.getRightOp();
				if (inv.getMethod().getName().equals("getIdentifier") && inv.getMethod().getDeclaringClass().getName().equals("android.content.res.Resources") && this.resourcePackages != null) {
					// The right side of the assignment is a call into the
					// well-known
					// Android API method for resource handling
					if (inv.getArgCount() != 3) {
						System.err.println("Invalid parameter count for call to getIdentifier");
						return null;
					}

					// Find the parameter values
					String resName = "";
					String resID = "";
					String packageName = "";

					// In the trivial case, these values are constants
					if (inv.getArg(0) instanceof StringConstant)
						resName = ((StringConstant) inv.getArg(0)).value;
					if (inv.getArg(1) instanceof StringConstant)
						resID = ((StringConstant) inv.getArg(1)).value;
					if (inv.getArg(2) instanceof StringConstant)
						packageName = ((StringConstant) inv.getArg(2)).value;
					else if (inv.getArg(2) instanceof Local)
						packageName = findLastStringAssignment(stmt, (Local) inv.getArg(2), cfg);
					else {
						System.err.println("Unknown parameter type in call to getIdentifier");
						return null;
					}

					// Find the resource
					ARSCFileParser.AbstractResource res = findResource(resName, resID, packageName);
					if (res != null)
						return res.getResourceID();
				}
			}
		}
	}

	// Continue the search upwards
	for (Unit pred : cfg.getPredsOf(stmt)) {
		if (!(pred instanceof Stmt))
			continue;
		Integer lastAssignment = findLastResIDAssignment((Stmt) pred, local, cfg, doneSet);
		if (lastAssignment != null)
			return lastAssignment;
	}
	return null;
}
 
Example #23
Source File: JimpleIndexNumberTransformer.java    From soot-infoflow-android-iccta with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void updateJimple() 
{
	Chain<SootClass> sootClasses = Scene.v().getClasses();
	
	for (Iterator<SootClass> iter = sootClasses.iterator(); iter.hasNext(); )
	{
		SootClass sc = iter.next();
		
		//Putting all the code in a try-catch.
		//Just trying the best to put the index number to "JimpleIndexNumberTag" of Stmt.
		try
		{
			List<SootMethod> sms = sc.getMethods();
			
			for (SootMethod sm : sms)
			{
				Body b = sm.retrieveActiveBody();
				
				PatchingChain<Unit> units = b.getUnits();
				
				int indexNumber = 0;
				
				for (Iterator<Unit> iterU = units.snapshotIterator(); iterU.hasNext(); )
				{
					Stmt stmt = (Stmt) iterU.next();
					
					//System.out.println(indexNumber + "->" + stmt);
					
					Tag t = new JimpleIndexNumberTag(indexNumber++);
					stmt.addTag(t);
				}
			}
		}
		catch (Exception ex)
		{
			//System.out.println("Exception in " + sc.getName());
			//ex.printStackTrace();
		}
	}
}
 
Example #24
Source File: PAG.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
public PAG( final SparkOptions opts ) {
      this.opts = opts;
      if( opts.add_tags() ) {
          nodeToTag = new HashMap<Node, Tag>();
      }
      if (opts.rta() && opts.on_fly_cg()) {
      	throw new RuntimeException("Incompatible options rta:true and on-fly-cg:true for cg.spark. Use -p cg-"
      			+ ".spark on-fly-cg:false when using RTA.");
}
      typeManager = new TypeManager(this);
      if( !opts.ignore_types() ) {
          typeManager.setFastHierarchy( Scene.v().getOrMakeFastHierarchy() );
      }
      switch( opts.set_impl() ) {
          case SparkOptions.set_impl_hash:
              setFactory = HashPointsToSet.getFactory();
              break;
          case SparkOptions.set_impl_hybrid:
              setFactory = HybridPointsToSet.getFactory();
              break;
          case SparkOptions.set_impl_heintze:
          	setFactory = SharedHybridSet.getFactory();
          	break;
          case SparkOptions.set_impl_sharedlist:
          	setFactory = SharedListSet.getFactory();
          	break;
          case SparkOptions.set_impl_array:
              setFactory = SortedArraySet.getFactory();
              break;
          case SparkOptions.set_impl_bit:
              setFactory = BitPointsToSet.getFactory();
              break;
          case SparkOptions.set_impl_double:
              P2SetFactory oldF;
              P2SetFactory newF;
              switch( opts.double_set_old() ) {
                  case SparkOptions.double_set_old_hash:
                      oldF = HashPointsToSet.getFactory();
                      break;
                  case SparkOptions.double_set_old_hybrid:
                      oldF = HybridPointsToSet.getFactory();
                      break;
                  case SparkOptions.double_set_old_heintze:
                  	oldF = SharedHybridSet.getFactory();
                  	break;
                  case SparkOptions.double_set_old_sharedlist:
                  	oldF = SharedListSet.getFactory();
                  	break;
                  case SparkOptions.double_set_old_array:
                      oldF = SortedArraySet.getFactory();
                      break;
                  case SparkOptions.double_set_old_bit:
                      oldF = BitPointsToSet.getFactory();
                      break;
                  default:
                      throw new RuntimeException();
              }
              switch( opts.double_set_new() ) {
                  case SparkOptions.double_set_new_hash:
                      newF = HashPointsToSet.getFactory();
                      break;
                  case SparkOptions.double_set_new_hybrid:
                      newF = HybridPointsToSet.getFactory();
                      break;
                  case SparkOptions.double_set_new_heintze:
                  	newF = SharedHybridSet.getFactory();
                  	break;
                  case SparkOptions.double_set_new_sharedlist:
                  	newF = SharedListSet.getFactory();
                  	break;
                  case SparkOptions.double_set_new_array:
                      newF = SortedArraySet.getFactory();
                      break;
                  case SparkOptions.double_set_new_bit:
                      newF = BitPointsToSet.getFactory();
                      break;
                  default:
                      throw new RuntimeException();
              }
              setFactory = DoublePointsToSet.getFactory( newF, oldF );
              break;
          default:
              throw new RuntimeException();
      }
      runGeomPTA = opts.geom_pta();
  }
 
Example #25
Source File: UnitContainer.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
public void addTag(Tag t) {
	throw new UnsupportedOperationException();
}
 
Example #26
Source File: UnitContainer.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
public Tag getTag(String aName) {
	throw new UnsupportedOperationException();
}
 
Example #27
Source File: UnitContainer.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
public List<Tag> getTags() {
	throw new UnsupportedOperationException();
}
 
Example #28
Source File: AbstractJasminClass.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
protected void emitMethod(SootMethod method)
  {
     if (method.isPhantom())
         return;

     // Emit prologue
          emit(".method " + Modifier.toString(method.getModifiers()) + " " +
               method.getName() + jasminDescriptorOf(method.makeRef()));

          Iterator<SootClass> throwsIt = method.getExceptions().iterator();
          while (throwsIt.hasNext()){
              SootClass exceptClass = throwsIt.next();
              emit(".throws "+exceptClass.getName());
          }
          if (method.hasTag("SyntheticTag") || Modifier.isSynthetic(method.getModifiers())){
              emit(".synthetic");
          }
          if (method.hasTag("DeprecatedTag")){
              emit(".deprecated");
          }
          if (method.hasTag("SignatureTag")){
              String sigAttr = ".signature_attr ";
              SignatureTag sigTag = (SignatureTag)method.getTag("SignatureTag");
              sigAttr += "\""+sigTag.getSignature()+"\"";
              emit(sigAttr);
          }
          if (method.hasTag("AnnotationDefaultTag")){
              String annotDefAttr = ".annotation_default ";
              AnnotationDefaultTag annotDefTag = (AnnotationDefaultTag)method.getTag("AnnotationDefaultTag");
              annotDefAttr += getElemAttr(annotDefTag.getDefaultVal());
              annotDefAttr += ".end .annotation_default";
              emit(annotDefAttr);
          }
          Iterator<Tag> vit = method.getTags().iterator();
          while (vit.hasNext()){
              Tag t = (Tag)vit.next();
              if (t.getName().equals("VisibilityAnnotationTag")){
                  emit(getVisibilityAnnotationAttr((VisibilityAnnotationTag)t));
              }
              if (t.getName().equals("VisibilityParameterAnnotationTag")){
                  emit(getVisibilityParameterAnnotationAttr((VisibilityParameterAnnotationTag)t));
              }
          }

     if(method.isConcrete())
     {
          if(!method.hasActiveBody())
              throw new RuntimeException("method: " + method.getName() + " has no active body!");
          else
              emitMethodBody(method);
     }
     
     // Emit epilogue
          emit(".end method");

   Iterator<Tag> it =  method.getTags().iterator();
   while(it.hasNext()) {
Tag tag = (Tag) it.next();
if(tag instanceof Attribute)
    emit(".method_attribute "  + tag.getName() + " \"" + new String(Base64.encode(tag.getValue())) +"\"");
   }	    
  }
 
Example #29
Source File: PAG.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
public Map<Node, Tag> getNodeTags() {
    return nodeToTag;
}
 
Example #30
Source File: SparkTransformer.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
protected void addTag( Host h, Node n, Map<Node, Tag> nodeToTag, Tag unknown ) {
    if( nodeToTag.containsKey( n ) ) h.addTag( nodeToTag.get(n) );
    else h.addTag( unknown );
}