예제 #1
0
void kk_matvec(AType A, XType x, YType y, int rows_per_thread, int team_size, int vector_length) {

  typedef typename XType::non_const_value_type Scalar;
  typedef typename AType::execution_space execution_space;
  typedef KokkosSparse::CrsMatrix<const Scalar,int,execution_space,void,int> matrix_type ;
  typedef typename Kokkos::View<Scalar*,Kokkos::LayoutLeft,execution_space> y_type;
  typedef typename Kokkos::View<const Scalar*,Kokkos::LayoutLeft,execution_space,Kokkos::MemoryRandomAccess > x_type;

  int rows_per_team = launch_parameters<execution_space>(A.numRows(),A.nnz(),rows_per_thread,team_size,vector_length);

  double s_a = 1.0;
  double s_b = 0.0;
  SPMV_Functor<matrix_type,x_type,y_type,0,false> func (s_a,A,x,s_b,y,rows_per_team);

  int worksets = (y.extent(0)+rows_per_team-1)/rows_per_team;

  Kokkos::TeamPolicy<Kokkos::Schedule<ScheduleType> > policy(1,1);

  if(team_size>0)
    policy = Kokkos::TeamPolicy<Kokkos::Schedule<ScheduleType> >(worksets,team_size,vector_length);
  else
    policy = Kokkos::TeamPolicy<Kokkos::Schedule<ScheduleType> >(worksets,Kokkos::AUTO,vector_length);

  Kokkos::parallel_for(policy,func);
}
int main()
{
    AType a[2][5] = {
                    AType(1,2), AType(3,4),
                    AType(5,6), AType(7,8),
                    AType(9,10), AType(11,12),
                    AType(13,14), AType(15,16),
                    AType(17,18), AType(19,20),
                    };

    AType *p;

    //p = (AType *)a;
    p = (AType *)a;

    for(int i=0;i<2;i++){
        for(int j=0;j<5;j++){
            p->show();
            p++;
        }
        cout << endl;
    }

    return 0;
}
예제 #3
0
void TypeAnalysis::genericRelational(CallInst * ci) {
    AType * lhs = state.get(ci->getOperand(0));
    AType * rhs = state.get(ci->getOperand(1));
    if (lhs->isDoubleScalar() and rhs->isDoubleScalar()) {
        state.update(ci, AType::D1);
    } else {
        state.update(ci, AType::DV);
    }
}
예제 #4
0
파일: unboxing.cpp 프로젝트: janvitek/rift
bool Unboxing::genericArithmetic(llvm::Instruction::BinaryOps op) {
    llvm::Value * lhs = ins->getOperand(0);
    llvm::Value * rhs = ins->getOperand(1);
    AType * lhsType = state().get(lhs);
    AType * rhsType = state().get(rhs);
    if (lhsType->isDouble() and rhsType->isDouble()) {
        return doubleArithmetic(lhs, rhs, lhsType, rhsType, op);
    }
    return false;
}
예제 #5
0
파일: unboxing.cpp 프로젝트: janvitek/rift
bool Unboxing::genericRelational(llvm::CmpInst::Predicate op) {
    llvm::Value * lhs = ins->getOperand(0);
    llvm::Value * rhs = ins->getOperand(1);
    AType * lhsType = state().get(lhs);
    AType * rhsType = state().get(rhs);
    if (lhsType->isDouble() and rhsType->isDouble()) {
        return doubleRelational(lhs, rhs, lhsType, rhsType, op);
    }

    return false;
}
예제 #6
0
void TypeAnalysis::genericRelational(CallInst * ci) {
    AType * lhs = state.get(ci->getOperand(0));
    AType * rhs = state.get(ci->getOperand(1));
    if (lhs->isScalar() and rhs->isScalar()) {
        state.update(ci,
                new AType(AType::Kind::R,
                    AType::Kind::DV,
                    AType::Kind::D));
    } else {
        state.update(ci, new AType(AType::Kind::R, AType::Kind::DV));
    }
}
예제 #7
0
void TypeAnalysis::genericGetElement(CallInst * ci) {
    AType * from = state.get(ci->getOperand(0));
    AType * index = state.get(ci->getOperand(1));
    if (from->isDouble()) {
        if (index->isDoubleScalar()) {
            state.update(ci, AType::D1);
        } else {
            state.update(ci, AType::DV);
        }
    } else if (from->isCharacter()) {
        state.update(ci, AType::CV);
    } else {
        state.update(ci, AType::T);
    }
}
void kk_inspector_matvec(AType A, XType x, YType y, int rows_per_thread, int team_size, int vector_length) {

  typedef typename XType::non_const_value_type Scalar;
  typedef typename AType::execution_space execution_space;
  typedef KokkosSparse::CrsMatrix<const Scalar,int,execution_space,void,int> matrix_type ;
  typedef typename Kokkos::View<Scalar*,Kokkos::LayoutLeft,execution_space> y_type;
  typedef typename Kokkos::View<const Scalar*,Kokkos::LayoutLeft,execution_space,Kokkos::MemoryRandomAccess > x_type;

  //int rows_per_team = launch_parameters<execution_space>(A.numRows(),A.nnz(),rows_per_thread,team_size,vector_length);
  //static int worksets = (y.extent(0)+rows_per_team-1)/rows_per_team;
  static int worksets = std::is_same<Schedule,Kokkos::Static>::value ?
                        team_size>0?execution_space::concurrency()/team_size:execution_space::concurrency() : //static
                        team_size>0?execution_space::concurrency()*32/team_size:execution_space::concurrency()*32 ; //dynamic
  static Kokkos::View<int*> workset_offsets;
  if(workset_offsets.extent(0) == 0) {
    workset_offsets = Kokkos::View<int*> ("WorksetOffsets",worksets+1);
    const size_t nnz = A.nnz();
    int nnz_per_workset = (nnz+worksets-1)/worksets;
    workset_offsets(0) = 0;
    int ws = 1;
    for(int row = 0; row<A.numRows(); row++) {
      if(A.graph.row_map(row) > ws*nnz_per_workset) {
        workset_offsets(ws) = row;
        ws++;
      }
    }
    if(workset_offsets(ws-1) < A.numRows()) {
      workset_offsets(ws) = A.numRows();
    }
    printf("Worksets: %i %i\n",worksets,ws);
    worksets = ws;
  }
  double s_a = 1.0;
  double s_b = 0.0;
  SPMV_Inspector_Functor<matrix_type,x_type,y_type,0,false,int> func (s_a,A,x,workset_offsets,s_b,y);

  Kokkos::TeamPolicy<Kokkos::Schedule<Schedule> > policy(1,1);

  if(team_size>0)
    policy = Kokkos::TeamPolicy<Kokkos::Schedule<Schedule> >(worksets,team_size,vector_length);
  else
    policy = Kokkos::TeamPolicy<Kokkos::Schedule<Schedule> >(worksets,Kokkos::AUTO,vector_length);

  Kokkos::parallel_for("KokkosSparse::PerfTest::SpMV_Inspector", policy,func);
}
예제 #9
0
파일: unboxing.cpp 프로젝트: janvitek/rift
bool Unboxing::genericGetElement() {
    llvm::Value * src = ins->getOperand(0);
    llvm::Value * idx = ins->getOperand(1);
    AType * srcType = state().get(src);
    AType * idxType = state().get(idx);

    if (srcType->isDouble()) {
        src = CastInst::CreatePointerCast(src, type::ptrDoubleVector, "", ins); 
        if (idxType->isDoubleScalar()) {
            llvm::Value * i = state().getMetadata(idx);
            if (i) {
                llvm::Value * res = RUNTIME_CALL(m->doubleGetSingleElement, src, i);
                updateDoubleScalar(res);
                return true;
            }
        }
    }
    return false;
}
예제 #10
0
void ObjectData::read(char * & st, char * & k) { 
  AType t;
  
  t.read(st, "type", "explicit_type", k);	// k unchanged
  set_type(t);
  
  k = read_keyword(st);
  
  if (!strcmp(k, "multiplicity")) {
    multiplicity = read_string(st);
    k = read_keyword(st);
  }
  
  ordering = ::ordering(k);
  
  k = read_keyword(st);
  
  if (!strcmp(k, "in_state")) {
    in_state = read_string(st);
    k = read_keyword(st);
  }
  
  if (!strcmp(k, "is_control")) {
    is_control = TRUE;
    k = read_keyword(st);
  }
  
  if (!strcmp(k, "uml_selection")) {
    uml_selection = read_string(st);
    k = read_keyword(st);
  }
  
  if (!strcmp(k, "cpp_selection")) {
    cpp_selection = read_string(st);
    k = read_keyword(st);
  }
  
  if (!strcmp(k, "java_selection")) {
    java_selection = read_string(st);
    k = read_keyword(st);
  }
}
예제 #11
0
파일: tests.cpp 프로젝트: evandar/project
 /** Checks that a dot operator result type is correctly set to be double scalar by the type analysis. */
 void project4() {
     char const * source = "function(a, b) { a %*% b }";
     try {
         Environment * env = new Environment(nullptr);
         RVal * actual = eval(env, source);
         llvm::Function * f = actual->f->bitcode;
         // run type analysis on the function
         //auto pm = llvm::legacy::FunctionPassManager(f->getParent());
         TypeAnalysis ta;
         ta.runOnFunction(*f);
         // check the type of the genericDot intrinsic call
         for (auto & b : *f) {
             for (auto & i : b) {
                 if (llvm::CallInst * ci = llvm::dyn_cast<llvm::CallInst>(&i)) {
                     llvm::StringRef s = ci->getCalledFunction()->getName();
                     if (s == "genericDot") {
                         AType * t = ta.state.get(ci);
                         if (t->kind != AType::Kind::R or not t->isScalar())
                             throw "Generic dot does not have correct type";
                         if (ta.state.getLocation(t) != ci)
                             throw "Location attached to the generic dot type is invalid";
                         t = t->payload;
                         if (ta.state.getLocation(t) != nullptr)
                             throw "Generic dot payload cannot have location";
                         t = t->payload;
                         if (ta.state.getLocation(t) != nullptr)
                             throw "Generic dot payload cannot have location";
                         return;
                     }
                 }
             }
         }
         throw "Generic dot not found";
     } catch (char const * e) {
         cout << "ERROR at line " << __LINE__ << " : " << e << endl;
         cout << source << endl << endl;
     } catch (...) {
         cout << "ERROR at line " << __LINE__ << " : " << endl;
         cout << source << endl << endl;
     }
 }
예제 #12
0
bool TypeAnalysis::runOnFunction(llvm::Function & f) {
    state.clear();
    if (DEBUG) std::cout << "runnning TypeAnalysis..." << std::endl;
    // for all basic blocks, for all instructions
    do {
        // cout << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << endl;
        state.iterationStart();
        for (auto & b : f) {
            for (auto & i : b) {
                if (CallInst * ci = dyn_cast<CallInst>(&i)) {
                    StringRef s = ci->getCalledFunction()->getName();
                    if (s == "doubleVectorLiteral") {
                        // when creating literal from a double, it is
                        // always double scalar
                        llvm::Value * op = ci->getOperand(0);
                        AType * t = new AType(AType::Kind::D);
                        state.update(op, t);
                        state.update(ci, new AType(AType::Kind::DV, t));
                    } else if (s == "characterVectorLiteral") {
                        state.update(ci, new AType(AType::Kind::CV));
                    } else if (s == "fromDoubleVector") {
                        state.update(ci,
                                new AType(AType::Kind::R,
                                    state.get(ci->getOperand(0))));
                    } else if (s == "fromCharacterVector") {
                        state.update(ci,
                                new AType(AType::Kind::R,
                                    state.get(ci->getOperand(0))));
                    } else if (s == "fromFunction") {
                        state.update(ci,
                                new AType(AType::Kind::R,
                                    state.get(ci->getOperand(0))));
                    } else if (s == "genericGetElement") {
                        genericGetElement(ci);
                    } else if (s == "genericSetElement") {
                        // don't do anything for set element as it does not
                        // produce any new value
                    } else if (s == "genericAdd") {
                        genericArithmetic(ci);
                    } else if (s == "genericSub") {
                        genericArithmetic(ci);
                    } else if (s == "genericMul") {
                        genericArithmetic(ci);
                    } else if (s == "genericDiv") {
                        genericArithmetic(ci);
                    } else if (s == "genericEq") {
                        genericRelational(ci);
                    } else if (s == "genericNeq") {
                        genericRelational(ci);
                    } else if (s == "genericLt") {
                        genericRelational(ci);
                    } else if (s == "genericGt") {
                        genericRelational(ci);
                    } else if (s == "length") {
                        // result of length operation is always 
                        // double scalar
                        state.update(ci, new AType(AType::Kind::D));
                    } else if (s == "type") {
                        // result of type operation is always 
                        // character vector
                        state.update(ci, new AType(AType::Kind::CV));
                    } else if (s == "c") {
                        // make sure the types to c are correct
                        AType * t1 = state.get(ci->getArgOperand(1));
                        for (unsigned i = 2; i < ci->getNumArgOperands(); ++i)
                            t1 = t1->merge(state.get(ci->getArgOperand(i)));
                        if (t1->isScalar())
                            // concatenation of scalars is a vector
                            t1 = new AType(AType::Kind::R, AType::Kind::DV);
                        state.update(ci, t1);
                    } else if (s == "genericEval") {
                        state.update(ci, new AType(AType::Kind::R));
                    } else if (s == "envGet") {
                        state.update(ci, new AType(AType::Kind::R));
                    }
                } else if (PHINode * phi = dyn_cast<PHINode>(&i)) {
                    AType * first = state.get(phi->getOperand(0));
                    AType * second = state.get(phi->getOperand(1));
                    AType * result = first->merge(second);
                    state.update(phi, result);
                }
            }
        }
    } while (!state.hasReachedFixpoint());
    if (DEBUG) {
        f.dump();
        cout << state << endl;
    }
    return false;
}
	static bool isend(AType &a, IType it)
	{
		return it == a.end();
	}
	static IType end(AType &a)
	{
		return a.end();
	}
	static IType begin(AType &a)
	{
		return a.begin();
	}
예제 #16
0
RelationData * RelationData::read(char *& st, char *& k,
                                  BrowserRelation *& unconsistent)
{
    unconsistent = 0;

    RelationData * result;
    int id;

    if (!strcmp(k, "relation_ref")) {
        if ((result = all[id = read_id(st)]) == 0)
            result = new RelationData(UmlRelations/*!!*/, id);

        k = read_keyword(st);
        return result;
    }
    else if (!strcmp(k, "relation")) {
        if ((result = all[id = read_id(st)]) == 0)
            result = new RelationData(relation_type(read_keyword(st)), id);
        else if (result->type != UmlRelations) {
            // shared identifier
            result->set_unconsistent();
            unconsistent = result->start;
            result = new RelationData(relation_type(read_keyword(st)), id);
            result->set_unconsistent();
        }
        else {
            result->type = relation_type(read_keyword(st));
            result->name = default_name(result->type);

            if (result->start != 0) {
                // Created by RelationData::read_ref()
                // invalidate start/end to not delete result
                // when start/end will be deleted
                result->start->invalidate();
                result->end->invalidate();
            }
        }

        k = read_keyword(st);

        if (!strcmp(k, "name")) {
            result->name = read_string(st);
            k = read_keyword(st);
        }

        result->BasicData::read(st, k);	// updates k

        if (in_lib_import()) {
            result->original_id = id;

            if (! strcmp(k, "oid")) {
                // a sub lib is imported as a part of the imported lib
                (void) read_id(st);
                k = read_keyword(st);
            }
        }
        else if (! strcmp(k, "oid")) {
            result->original_id = read_id(st);
            k = read_keyword(st);
        }

        bool assoc = isa_association(result->type);

        if (strcmp(k, "a"))
            wrong_keyword(k, "a");

        read_role(result->a, assoc, st, k, result);		// updates k
        result->start = BrowserRelation::read_ref(st, k);

        read_keyword(st, "b");

        if (!RelationData::uni_directional(result->type)) {
            read_role(result->b, assoc, st, k, result);	// updates k
            result->end = BrowserRelation::read_ref(st, k);
            // 'end' may be read before 'start' : relation's type was unknown
            result->end->set_name(0);
            result->end->set_name(result->name);
        }
        else {
            k = read_keyword(st);

            if (!strcmp(k, "multiplicity")) {
                result->b.multiplicity = read_string(st);
                k = read_keyword(st);
            }
            else
                result->b.multiplicity = 0;

            if (strcmp(k, "parent"))
                wrong_keyword(k, "parent");

            result->end_removed_from = BrowserClass::read_ref(st);
            result->b.uml_visibility =
                ((BrowserNode *) result->end_removed_from->parent())->get_visibility(UmlRelations);
            connect(result->end_removed_from->get_data(), SIGNAL(deleted()),
                    result, SLOT(end_deleted()));
            result->end = 0;

            // manage old declarations
            switch (result->type) {
            case UmlRealize:
            case UmlGeneralisation:
                if (result->a.cpp_decl == "Generated")
                    result->a.cpp_decl = "${type}";

                if (result->a.java_decl == "Generated")
                    result->a.java_decl = "${type}";

                if (result->a.idl_decl == "Generated")
                    result->a.idl_decl = "${type}";

                break;

            case UmlDependency:
                if (!result->a.cpp_decl.isEmpty()) {
                    if (result->stereotype == "friend")
                        result->a.cpp_decl = "${type}";
                    else if ((result->a.cpp_decl == "Generated") ||
                             (result->a.cpp_decl == "${type}"))
                        result->a.cpp_decl = "#include in header";
                    else if ((result->a.cpp_decl == "#include in source") &&
                             (read_file_format() < 56))
                        IncludeToHeaderIfExternal.append(result);
                }

                break;

            default:
                break;
            }
        }

        k = read_keyword(st);

        AType t;

        if (!strcmp(k, "association_type") ||
            !strcmp(k, "association_explicit_type")) {
            t.read(st, "association_type", "association_explicit_type", k);
            result->set_association(t);
            k = read_keyword(st);
        }

        return result;
    }
    else
        return 0;
}
예제 #17
0
void ClassData::read(char * & st, char * & k) {
  if (!strcmp(k, "abstract")) {
    is_abstract = TRUE;
    k = read_keyword(st);
  }
  else
    is_abstract = FALSE;
  
  if (!strcmp(k, "active")) {
    is_active = TRUE;
    k = read_keyword(st);
  }
  else
    is_active = FALSE;
  
  if (!strcmp(k, "visibility")) {
    uml_visibility = ::visibility(read_keyword(st));  
    k = read_keyword(st);
  }
  else {
    // old non nested class
    uml_visibility = UmlPackageVisibility;
  }
  
  if (!strcmp(k, "stereotype")) {
    set_stereotype(read_string(st));
    
    if (!strcmp(stereotype, "typedef")) {
      AType t;
      
      t.read(st, "base_type", "explicit_base_type");
      set_base_type(t);
    }
    
    k = read_keyword(st);
  }
  
  unsigned n, i;
  
  if (!strcmp(k, "nformals")) {
    n = read_unsigned(st);
    set_n_formalparams(n);
    
    for (i = 0; i != n; i += 1)
      formals[i].read(st);
    
    k = read_keyword(st);
  }
  else
    set_n_formalparams(0);

  if (!strcmp(k, "nactuals")) {
    n = read_unsigned(st);
    
    BrowserClass * cl = 0;

    for (i = 0; i != n; i += 1) {
      ActualParamData * actual = ActualParamData::read(st);

      actuals.append(actual);
      
      if (actual->get_class() != cl) {
	cl = actual->get_class();
	connect(cl->get_data(), SIGNAL(deleted()),
		this, SLOT(update_actuals()));
	connect(cl->get_data(), SIGNAL(changed()),
		this, SLOT(update_actuals()));
      }
    }

    k = read_keyword(st);
  }
  else {
    n = 0;
    actuals.clear();
  }
  
  if (!strcmp(k, "constraint")) {
    constraint = read_string(st);
    k = read_keyword(st);
  }
  else
    constraint = QString::null;
  
  if (!strcmp(k, "cpp_external")) {
    cpp_external = TRUE;
    k = read_keyword(st);
  }
  else
    cpp_external = FALSE;
  
  if (!strcmp(k, "cpp_visibility")) {
    cpp_visibility = ::visibility(read_keyword(st));
    k = read_keyword(st);
  }
  else
    cpp_visibility = UmlDefaultVisibility;

  if (!strcmp(k, "cpp_decl")) {
    cpp_decl = read_string(st);
    k = read_keyword(st);
  }
  else
    wrong_keyword(k, "cpp_decl");
  
  if (!strcmp(k, "java_external")) {
    java_external = TRUE;
    k = read_keyword(st);
  }
  else
    java_external = FALSE;
  
  if (read_file_format() <= 33) {
    // old file
    if ((cpp_visibility == UmlDefaultVisibility) &&
	(uml_visibility != UmlPublic) && 
	(uml_visibility != UmlPackageVisibility))
      cpp_visibility = uml_visibility;
    
    if (!strcmp(k, "public")) {
      uml_visibility = UmlPublic;
      k = read_keyword(st);
    }
    else
      uml_visibility = UmlPackageVisibility;
  }
  
  if (!strcmp(k, "final")) {
    java_final = TRUE;
    k = read_keyword(st);
  }
  else
    java_final = FALSE;
  
  if (!strcmp(k, "java_decl")) {
    java_decl = read_string(st);
    k = read_keyword(st);
  }
  else
    wrong_keyword(k, "java_decl");
  
  if (!strcmp(k, "java_annotation")) {
    java_annotation = read_string(st);
    k = read_keyword(st);
  }
  else
    java_annotation = QString::null;
  
  if (!strcmp(k, "php_external")) {
    php_external = TRUE;
    k = read_keyword(st);
  }
  else
    php_external = FALSE;
  
  if (!strcmp(k, "php_final")) {
    php_final = TRUE;
    k = read_keyword(st);
  }
  else
    php_final = FALSE;
  
  if (!strcmp(k, "php_decl")) {
    php_decl = read_string(st);
    k = read_keyword(st);
  }
  else if (read_file_format() >= 44)
    wrong_keyword(k, "php_decl");
  else
    php_decl = "";
  
  if (!strcmp(k, "python_external")) {
    python_external = TRUE;
    k = read_keyword(st);
  }
  else
    python_external = FALSE;
  
  if (!strcmp(k, "python_2_2")) {
    python_2_2 = TRUE;
    k = read_keyword(st);
  }
  else
    python_2_2 = (read_file_format() < 51);
  
  if (!strcmp(k, "python_decl")) {
    python_decl = read_string(st);
    k = read_keyword(st);
  }
  else if (read_file_format() >= 51)
    wrong_keyword(k, "python_decl");
  else
    python_decl = "";
  
  if (!strcmp(k, "idl_external")) {
    idl_external = TRUE;
    k = read_keyword(st);
  }
  else
    idl_external = FALSE;
  
  if (!strcmp(k, "local")) {
    idl_local = TRUE;
    k = read_keyword(st);
  }
  else
    idl_local = FALSE;
  
  if (!strcmp(k, "custom")) {
    idl_custom = TRUE;
    k = read_keyword(st);
  }
  else
    idl_custom = FALSE;
  
  if (!strcmp(k, "idl_decl")) {
    idl_decl = read_string(st);
    k = read_keyword(st);
  }
  else
    wrong_keyword(k, "idl_decl");
  
  AType t;
  
  t.read(st, "switch_type", "explicit_switch_type", k);
  set_switch_type(t);
  
  k = read_keyword(st);
}
예제 #18
0
void AttributeData::read(char *& st, char *& k)
{
    if (!strcmp(k, "class_attribute") ||
        !strcmp(k, "class_attribut")) {
        isa_class_attribute = TRUE;
        k = read_keyword(st);
    }
    else
        isa_class_attribute = FALSE;

    if (!strcmp(k, "volatile")) {
        isa_volatile_attribute = TRUE;
        k = read_keyword(st);
    }
    else
        isa_volatile_attribute = FALSE;

    if (!strcmp(k, "const_attribute") ||
        !strcmp(k, "const_attribut")) {
        isa_const_attribute = TRUE;
        k = read_keyword(st);
    }
    else
        isa_const_attribute = FALSE;

    if (!strcmp(k, "derivedunion")) {
        is_derived = TRUE;
        is_derivedunion = TRUE;
        k = read_keyword(st);
    }
    else if (!strcmp(k, "derived")) {
        is_derived = TRUE;
        is_derivedunion = FALSE;
        k = read_keyword(st);
    }
    else
        is_derived = is_derivedunion = FALSE;

    if (!strcmp(k, "ordered")) {
        is_ordered = TRUE;
        k = read_keyword(st);
    }
    else
        is_ordered = FALSE;

    if (!strcmp(k, "unique")) {
        is_unique = TRUE;
        k = read_keyword(st);
    }
    else
        is_unique = FALSE;

    uml_visibility = ::visibility(k);

    k = read_keyword(st);

    AType t;

    t.read(st, "type", "explicit_type", k);
    set_type(t);

    k = read_keyword(st);

    if (!strcmp(k, "multiplicity")) {
        multiplicity = read_string(st);
        k = read_keyword(st);
    }
    else
        multiplicity = 0;

    if (!strcmp(k, "init_value")) {
        init_value = QString(QTextCodec::codecForName(codec().toLatin1().constData())->fromUnicode(read_string(st)));
//        init_value = read_string(st);
        k = read_keyword(st);
    }
    else
        init_value = QString();

    if (!strcmp(k, "constraint")) {
        constraint = read_string(st);
        k = read_keyword(st);
    }
    else
        constraint = QString();

    BasicData::read(st, k);	// updates k

    if (!strcmp(k, "cpp_volatile")) {
        // old version
        isa_volatile_attribute = TRUE;
        k = read_keyword(st);
    }

    if (!strcmp(k, "cpp_mutable")) {
        cpp_mutable = TRUE;
        k = read_keyword(st);
    }
    else
        cpp_mutable = FALSE;

    if (!strcmp(k, "cpp_visibility")) {
        cpp_visibility = ::visibility(read_keyword(st));
        k = read_keyword(st);
    }
    else
        cpp_visibility = UmlDefaultVisibility;

    if (!strcmp(k, "cpp_decl")) {
        cpp_decl = read_string(st);
        k = read_keyword(st);
    }
    else
        cpp_decl = QString();

    if (!strcmp(k, "transient")) {
        java_transient = TRUE;
        k = read_keyword(st);
    }
    else
        java_transient = FALSE;

    if (!strcmp(k, "java_decl")) {
        java_decl = read_string(st);
        k = read_keyword(st);
    }
    else
        java_decl = QString();

    if (!strcmp(k, "java_annotation")) {
        java_annotation = read_string(st);
        k = read_keyword(st);
    }
    else
        java_annotation = QString();

    if (!strcmp(k, "php_decl")) {
        php_decl = read_string(st);
        k = read_keyword(st);
    }
    else
        php_decl = QString();

    if (!strcmp(k, "python_decl")) {
        python_decl = read_string(st);
        k = read_keyword(st);
    }
    else
        python_decl = QString();

    if (!strcmp(k, "idl_case")) {
        set_idlcase(BrowserAttribute::read_ref(st), "");
        k = read_keyword(st);
    }
    else if (!strcmp(k, "idl_explicit_case")) {
        set_idlcase(0, read_string(st));
        k = read_keyword(st);
    }
    else
        set_idlcase(0, "");

    if (!strcmp(k, "idl_decl")) {
        idl_decl = read_string(st);
        k = read_keyword(st);
    }
    else
        idl_decl = QString();
}
예제 #19
0
	static bool isend(AType &a, IType &it)
	{
		return it == a.arc_end();
	}
예제 #20
0
	static IType end(AType &a)
	{
		return a.arc_end();
	}
예제 #21
0
int main()
{
	int i;
    	AType<int> a;
    	cout<<"请输入"<<MAXSize<<"个整数:"<<endl;
    	a.SetAType();
	a.Sort();
	a.Display();

	AType<double> b;
	cout<<"请输入"<<MAXSize<<"个双精度浮点数:"<<endl;
	 b.SetAType();
	b.Sort();
	b.Display();

	AType<char> c;
	cout<<"请输入"<<MAXSize<<"个字符:"<<endl;
    	c.SetAType();
	c.Sort();
	c.Display();

    	return 0;
}
예제 #22
0
void TypeAnalysis::genericArithmetic(CallInst * ci) {
    AType * lhs = state.get(ci->getOperand(0));
    AType * rhs = state.get(ci->getOperand(1));
    state.update(ci, lhs->merge(rhs));
}