Commit e6241cb4 authored by Florian Hölzl's avatar Florian Hölzl
Browse files

STL example runs as GCC equivalence test

refs 727
parent c2561603
/*--------------------------------------------------------------------------+
$Id$
| |
| Copyright 2012 ForTISS GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.generator.common.model.c;
import java.util.List;
import org.fortiss.af3.generator.common.model.source.DeclarationBase;
import org.fortiss.af3.project.model.typesystem.ITerm;
import org.fortiss.af3.project.model.typesystem.IType;
/**
* C statically initialized array model.
*
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash:
*/
public class StaticArray {
/** The array name. */
private String identifier;
/** The array element type. */
private IType elementType;
/** The list of static values. */
private List<ITerm> values;
/** Constructor. */
public StaticArray(IType type, String identifier, List<ITerm> values) {
this.identifier = identifier;
this.elementType = type;
this.values = values;
}
/** Generates array implementation. */
public DeclarationBase getDeclaration() {
return new DeclarationBase() {
@Override
public String toString() {
StringBuffer buf = new StringBuffer();
buf.append(elementType.toString()).append(' ').append(identifier).append('[')
.append(values.size()).append("] = { ");
for(ITerm val : values) {
buf.append(val.toString()).append(", ");
}
buf.append("};\n");
return buf.toString();
}
};
}
}
......@@ -62,4 +62,22 @@ public class CSourcePackageUtils {
}
return rootPackage;
}
/**
* Returns the sub-package with the given name.
*
* @param parent
* the parent to be searched
* @param name
* the name
* @return the sub-package
*/
public static SourcePackage findSubPackageByName(String name, SourcePackage parent) {
for(SourcePackage sp : parent.getSubPackages()) {
if(sp.getBaseLocation().equals(name)) {
return sp;
}
}
return null;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment