コード例 #1
0
ファイル: SymbolDescription.java プロジェクト: trungpv88/gama
 @Override
 public IType getType() {
   // Adapter ca pour prendre ne ocmpte les ITypeProvider
   IType tt = facets.getTypeDenotedBy(TYPE, this);
   IType kt = facets.getTypeDenotedBy(INDEX, this, tt.getKeyType());
   IType ct = facets.getTypeDenotedBy(OF, this, tt.getContentType());
   final boolean isContainerWithNoContentsType = tt.isContainer() && ct == Types.NO_TYPE;
   final boolean isContainerWithNoKeyType = tt.isContainer() && kt == Types.NO_TYPE;
   final boolean isSpeciesWithAgentType = tt.id() == IType.SPECIES && ct.id() == IType.AGENT;
   if (isContainerWithNoContentsType || isContainerWithNoKeyType || isSpeciesWithAgentType) {
     compileTypeProviderFacets();
     final IExpression expr = facets.getExpr(INIT, VALUE, UPDATE, FUNCTION, DEFAULT);
     if (expr != null) {
       final IType exprType = expr.getType();
       if (tt.isAssignableFrom(exprType)) {
         tt = exprType;
       } else {
         if (isContainerWithNoKeyType) {
           kt = exprType.getKeyType();
         }
         if (isContainerWithNoContentsType || isSpeciesWithAgentType) {
           ct = exprType.getContentType();
         }
       }
     }
   }
   return GamaType.from(tt, kt, ct);
 }
コード例 #2
0
ファイル: ListExpression.java プロジェクト: meghendra/gama
 ListExpression(final List<? extends IExpression> elements) {
   this.elements = elements.toArray(new IExpression[0]);
   int n = this.elements.length;
   values = new Object[n];
   setName(elements.toString());
   type = Types.LIST.of(GamaType.findCommonType(this.elements, GamaType.TYPE));
   isConst();
 }