Package edu.mit.csail.sdg.alloy4compiler.ast.Sig

Examples of edu.mit.csail.sdg.alloy4compiler.ast.Sig.Field


  private TypeDeclaration getClass(String classId) {
    TypeDeclaration result = ast.newTypeDeclaration();

    Sig classSig = getSig("Class");
    SafeList<Field> classFields = classSig.getFields();
    Field classIdRelations = getField("id", classFields);
    Map<String, List<String>> classIdRel = getRelations(classIdRelations);

    Field classExtendRel = getField("extend", classFields);
    Map<String, List<String>> extendRel = getRelations(classExtendRel);

    // id
    String className = classIdRel.get(classId).get(0);
    result.setName(ast.newSimpleName(className));
View Full Code Here


  private List<MethodDeclaration> getClassMethods(
      SafeList<Field> classFields, String classId) {
    List<MethodDeclaration> result = new ArrayList<MethodDeclaration>();

    Field methodsRel = getField("methods", classFields);

    Map<String, List<String>> methodsMap = getRelations(methodsRel);

    List<String> methods = methodsMap.get(classId);

    if (methods != null) {
      Sig methodSig = getSig("Method");
      SafeList<Field> mFields = methodSig.getFields();
      Field mIdRelations = getField("id", mFields);
      Map<String, List<String>> idRel = getRelations(mIdRelations);
      Field mArgRelations = getField("param", mFields);
      Map<String, List<String>> argRel = getRelations(mArgRelations);
      Field mVisRelations = getField("acc", mFields);
      Map<String, List<String>> visRel = getRelations(mVisRelations);
      Field mBodyRelations = getField("b", mFields);

      Map<String, List<String>> bodyRel = getRelations(mBodyRelations);

      for (String method : methods) {
        String id = idRel.get(method).get(0);
View Full Code Here

    SafeList<Field> sFields = null;

    // pega o nome da classe que contem o metodo para usar no qualified this
    Sig classSig = getSig("Class");
    SafeList<Field> classFields = classSig.getFields();
    Field classIdRelations = getField("id", classFields);
    Map<String, List<String>> classIdRel = getRelations(classIdRelations);

    //debug
//    System.out.println("Body id: " + bodyId);
   
    if (isInstanceOfType(bodyId, "MethodInvocation")) {
      s = getSig("MethodInvocation");
      sFields = s.getFields();
      Field idRelations = getField("id", sFields);
      String methodId = getFieldInstance(idRelations, bodyId);
      Field qualRelations = getField("q", sFields);
      String qualifier = getFieldInstance(qualRelations, bodyId);
      String className = classIdRel.get(classId).get(0);
      return getMethodInvocationExpression(methodId, qualifier, className);

    } else if (isInstanceOfType(bodyId, "ConstructorMethodInvocation")) {
      s = getSig("ConstructorMethodInvocation");
      sFields = s.getFields();
      Field idRelations = getField("idMethod", sFields);
      String methodId = getFieldInstance(idRelations, bodyId);
      Field idClassRelations = getField("idClass", sFields);
      String className = getFieldInstance(idClassRelations, bodyId);
      return getConstructorMethodInvocationExpression(methodId, className);
    } else if (isInstanceOfType(bodyId, "FieldInvocation")) {
      s = getSig("FieldInvocation");
      sFields = s.getFields();
      Field idRelations = getField("id", sFields);
      String fieldId = getFieldInstance(idRelations, bodyId);
      Field qualRelations = getField("q", sFields);
      String qualifier = getFieldInstance(qualRelations, bodyId);
      String className = classIdRel.get(classId).get(0);
      return getFieldInvocationExpression(fieldId, qualifier, className);
    } else if (isInstanceOfType(bodyId, "ConstructorFieldInvocation")) {
      s = getSig("ConstructorFieldInvocation");
      sFields = s.getFields();
      Field idRelations = getField("idField", sFields);
      String fieldId = getFieldInstance(idRelations, bodyId);
      Field idClassRelations = getField("idClass", sFields);
      String className = getFieldInstance(idClassRelations, bodyId);
      return getConstructorFieldInvocationExpression(fieldId, className);
    } else {
      // System.out.println(bodyId);
      // Random generator = new Random();
View Full Code Here

   
    if (s == null)
      return false;

    SafeList<Field> sFields = s.getFields();
    Field idRelations = getField("id", sFields);
   
    //debug
//    System.out.println("sFieds: " + sFields);
//    System.out.println("idRelations: "  + idRelations);
   
View Full Code Here

  }

  private Expression createParameter(String methodId, String classId) {
    Sig classSig = getSig("Class");
    SafeList<Field> cFields = classSig.getFields();
    Field cIdRelations = getField("id", cFields);
    Field cMethodsRelations = getField("methods", cFields);
   
    Sig methodSig = getSig("Method");
   
    SafeList<Field> mFields = methodSig.getFields();
    Field mIdRelations = getField("id", mFields);
   
    Map<String, List<String>> idRel = getRelations(mIdRelations);
   
    Field mArgRelations = getField("param", mFields);
    Map<String, List<String>> argRel = getRelations(mArgRelations);

    String parameterType = "";
    boolean someMethodwithoutParameter = false;
    for (String s : idRel.keySet()) {
View Full Code Here

  private Expression createParameter(String methodId) {
    // pegar parametros dos metodo
    Sig methodSig = getSig("Method");
    SafeList<Field> mFields = methodSig.getFields();
    Field mIdRelations = getField("id", mFields);
    Map<String, List<String>> idRel = getRelations(mIdRelations);
    Field mArgRelations = getField("param", mFields);
    Map<String, List<String>> argRel = getRelations(mArgRelations);

    String parameterType = "";
    for (String s : idRel.keySet()) {
      if (idRel.get(s).size() > 0 && idRel.get(s).get(0).equals(methodId)) {
View Full Code Here

  private List<FieldDeclaration> getClassFields(SafeList<Field> classFields,
      String td) {
    List<FieldDeclaration> result = new ArrayList<FieldDeclaration>();

    Field fieldsRel = getField("fields", classFields);

    Map<String, List<String>> fieldsMap = getRelations(fieldsRel);

    List<String> fields = fieldsMap.get(td);

    if (fields != null) {
      Sig fieldSig = getSig("Field");
      SafeList<Field> fFields = fieldSig.getFields();
      Field fIdRelations = getField("id", fFields);
      Map<String, List<String>> idRel = getRelations(fIdRelations);
      Field fTypeRelations = getField("type", fFields);
      Map<String, List<String>> typeRel = getRelations(fTypeRelations);
      Field fVisRelations = getField("acc", fFields);
      Map<String, List<String>> visRel = getRelations(fVisRelations);

      for (String field : fields) {
        String id = idRel.get(field).get(0);
        String type = typeRel.get(field).get(0);
View Full Code Here

      result = ast.newPrimitiveType(PrimitiveType.INT);

    else {
      Sig classSig = getSig("Class");
      SafeList<Field> classFields = classSig.getFields();
      Field classIdRelations = getField("id", classFields);
      Map<String, List<String>> classRel = getRelations(classIdRelations);
      List<String> id = classRel.get(type);
      if (id != null) {
        result = ast.newSimpleType(ast.newName(id.get(0)));
      }
View Full Code Here

  private List<ImportDeclaration> getImports(String classId) {
    List<ImportDeclaration> result = new ArrayList<ImportDeclaration>();

    Sig cuSig = getSig("Class");
    SafeList<Field> cuFields = cuSig.getFields();
    Field packageRelations = getField("imports", cuFields);
    Map<String, List<String>> r = getRelations(packageRelations);
    List<String> imported = r.get(classId);

    if (imported != null) {
      for (String importedPackage : imported) {
View Full Code Here

  private PackageDeclaration getPackage(String classId) {
    PackageDeclaration result = ast.newPackageDeclaration();

    Sig classSig = getSig("Class");
    SafeList<Field> cFields = classSig.getFields();
    Field packageRelations = getField("package", cFields);
    Map<String, List<String>> r = getRelations(packageRelations);

    String packageName = r.get(classId).get(0);

    result.setName(ast.newSimpleName(packageName));
View Full Code Here

TOP

Related Classes of edu.mit.csail.sdg.alloy4compiler.ast.Sig.Field

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.