예제 #1
0
 @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(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();
 }