00001 00004 package edu.tum.cs.srl; 00005 00006 import edu.tum.cs.util.StringTool; 00007 00008 public class Signature { 00009 public String returnType; 00010 public String[] argTypes; 00011 public String functionName; 00015 public boolean isLogical; 00016 00017 public Signature(String functionName, String returnType, String[] argTypes, boolean isLogical) { 00018 this.returnType = returnType; 00019 this.argTypes = argTypes; 00020 this.functionName = functionName; 00021 this.isLogical = isLogical; 00022 } 00023 00024 public Signature(String functionName, String returnType, String[] argTypes) { 00025 this(functionName, returnType, argTypes, false); 00026 } 00027 00028 public void replaceType(String oldType, String newType) { 00029 if(this.returnType.equals(oldType)) 00030 this.returnType = newType; 00031 for(int i = 0; i < argTypes.length; i++) { 00032 if(argTypes[i].equals(oldType)) 00033 argTypes[i] = newType; 00034 } 00035 } 00036 00037 public boolean isBoolean() { 00038 return returnType.equalsIgnoreCase("boolean"); 00039 } 00040 00041 @Override 00042 public String toString() { 00043 return String.format("%s %s(%s)", returnType, functionName, StringTool.join(",", argTypes)); 00044 } 00045 00046 public static String formatVarName(String functionName, String[] args) { 00047 return String.format("%s(%s)", functionName, StringTool.join(",", args)); 00048 } 00049 }