Changeset 13450


Ignore:
Timestamp:
Sep 11, 2019 12:57:32 PM (3 months ago)
Author:
molsson
Message:

#5827 Refactored createInStreamAccess().

Location:
branches/dev-mo-2267/Compiler
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/dev-mo-2267/Compiler/ModelicaFlatTree/src/jastadd/FlatUtil.jrag

    r13398 r13450  
    704704        }
    705705        res.getFAccessPart(0).setName(prefix + name);
     706        return res;
     707    }
     708   
     709   
     710    public abstract FAccess FAccess.copyAndAddSuffix(String suffix);
     711   
     712    public FAccessString FAccessEmpty.copyAndAddSuffix(String suffix) {
     713        throw new UnsupportedOperationException();
     714    }
     715   
     716    public FAccessString FAccessString.copyAndAddSuffix(String suffix) {
     717        String name = getName();
     718        String end = "";
     719        if (name.endsWith("'")) {
     720            name = name.substring(0, name.length() - 1);
     721            end = "'";
     722        }
     723        return new FAccessString(name + suffix + end);
     724    }
     725   
     726    public FAccessFull FAccessFull.copyAndAddSuffix(String suffix) {
     727        FAccessFull res = fullCopy();
     728        String name = res.getFAccessPart(0).getName();
     729        String end = "";
     730        if (name.endsWith("'")) {
     731            name = name.substring(0, name.length() - 1);
     732            end = "'";
     733        }
     734        res.getFAccessPart(0).setName(name + suffix + end);
    706735        return res;
    707736    }
  • branches/dev-mo-2267/Compiler/ModelicaFrontEnd/src/jastadd/flattening/Flattening.jrag

    r13442 r13450  
    12531253    inh FAccess InstAssignable.createInStreamAccess(FAccess streamAccess);
    12541254    eq InstClassDecl.getChild().createInStreamAccess(FAccess streamAccess) {
    1255         FAccess lastPart = streamAccess.copyLastSuffix();
    1256         String streamName = lastPart.name();
    1257         String end = "";
    1258         if (streamName.endsWith("]")) {
    1259             int index = streamName.lastIndexOf("[");
    1260             end = streamName.substring(index);
    1261             streamName = streamName.substring(0, index);
    1262         }
    1263         if (streamName.endsWith("'")) {
    1264             streamName = streamName.substring(0, streamName.length() - 1);
    1265             end = "'" + end;
    1266         }
    1267         FAccess result = streamAccess.copyPrefix().append(streamName + "__instream_" + end, lastPart.getFArraySubscripts());
     1255        FAccess result = streamAccess.copyAndAddSuffix("__instream_");
    12681256        int i = 2;
    12691257        while (componentExists(new QualifiedName(result.name()))) {
    1270             result = streamAccess.copyPrefix().append(streamName + "__instream_" + i + end, lastPart.getFArraySubscripts());
     1258            result = streamAccess.copyAndAddSuffix("__instream_" + i);
    12711259            i++;
    12721260        }
Note: See TracChangeset for help on using the changeset viewer.