Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lang] Add optimization level parameter to the SARL batch compiler.
Signed-off-by: Stéphane Galland <galland@arakhne.org>
- Loading branch information
1 parent
df661f6
commit ecc5fd3
Showing
2 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
83 changes: 83 additions & 0 deletions
83
main/coreplugins/io.sarl.lang/src/io/sarl/lang/compiler/batch/OptimizationLevel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* $Id$ | ||
* | ||
* SARL is an general-purpose agent programming language. | ||
* More details on http://www.sarl.io | ||
* | ||
* Copyright (C) 2014-2018 the original authors or authors. | ||
* | ||
* 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 io.sarl.lang.compiler.batch; | ||
|
||
import com.google.common.base.Strings; | ||
|
||
/** Level of optimization of the Java code. | ||
* | ||
* @author $Author: sgalland$ | ||
* @version $FullVersion$ | ||
* @mavengroupid $GroupId$ | ||
* @mavenartifactid $ArtifactId$ | ||
* @since 0.8 | ||
*/ | ||
public enum OptimizationLevel { | ||
|
||
/** | ||
* No optimization, debugging information included. | ||
*/ | ||
G0, | ||
|
||
/** | ||
* No optimization, no debugging information included. | ||
*/ | ||
G1, | ||
|
||
/** | ||
* Optimization, no debugging information included. | ||
*/ | ||
G2; | ||
|
||
/** Replies the default optimization level. | ||
* | ||
* @return the default optimization level. | ||
*/ | ||
public static OptimizationLevel getDefault() { | ||
return G0; | ||
} | ||
|
||
/** Parse the given case insensitive string for obtaining the optimization level. | ||
* | ||
* @param name the string to parse. | ||
* @return the optimization level, or {@code null} if the string cannot be parsed. | ||
*/ | ||
public static OptimizationLevel valueOfCaseInsensitive(String name) { | ||
if (Strings.isNullOrEmpty(name)) { | ||
return null; | ||
} | ||
try { | ||
return valueOf(name.toUpperCase()); | ||
} catch (Exception exception) { | ||
return null; | ||
} | ||
} | ||
|
||
/** Replies the string representation of this optimization level. | ||
* | ||
* @return the string representation. | ||
*/ | ||
public String getCaseInsensitiveName() { | ||
return name().toLowerCase(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters