Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
af3
AF3
Commits
e6241cb4
Commit
e6241cb4
authored
May 21, 2012
by
Florian Hölzl
Browse files
STL example runs as GCC equivalence test
refs 727
parent
c2561603
Changes
2
Hide whitespace changes
Inline
Side-by-side
org.fortiss.af3.generator.common/trunk/src/org/fortiss/af3/generator/common/model/c/StaticArray.java
0 → 100644
View file @
e6241cb4
/*--------------------------------------------------------------------------+
$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
();
}
};
}
}
org.fortiss.af3.generator.common/trunk/src/org/fortiss/af3/generator/common/utils/CSourcePackageUtils.java
View file @
e6241cb4
...
...
@@ -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
;
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment