X-Git-Url: http://nitlanguage.org diff --git a/src/platform.nit b/src/platform.nit index 4d65c7e..8f2edbb 100644 --- a/src/platform.nit +++ b/src/platform.nit @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Platform system, used to customize the behavior of the compiler according -# to the target platform. Also detects conflicts between targetted platforms. +# Platform system, used to customize the behavior of the compiler. +# +# Customisation is done accordingly to the target platform. +# Also detects conflicts between targeted platforms. module platform -import modelize_property -import parser_util -import simple_misc_analysis -import modelbuilder +import modelize +private import parser_util +private import annotation redef class ToolContext var platform_phase: Phase = new PlatformPhase(self, [modelize_property_phase]) @@ -38,7 +39,7 @@ private class PlatformPhase var annotation_name = "platform" # Skip if we are not interested - if nat.n_atid.n_id.text != annotation_name then return + if nat.name != annotation_name then return # Do some validity checks and print errors if the annotation is used incorrectly var modelbuilder = toolcontext.modelbuilder @@ -55,21 +56,12 @@ private class PlatformPhase else if args.is_empty then platform_name = nmoduledecl.n_name.collect_text else - var arg = args.first - var format_error = "Syntax error: \"{annotation_name}\" expects its argument to be the name of the target platform as a String literal." - - if not arg isa AExprAtArg then + platform_name = args.first.as_string + if platform_name == null then + var format_error = "Syntax error: \"{annotation_name}\" expects its argument to be the name of the target platform as a String literal." modelbuilder.error(nat, format_error) return end - - var expr = arg.n_expr - if not expr isa AStringFormExpr then - modelbuilder.error(nat, format_error) - return - end - var target = expr.collect_text - platform_name = target.substring(1, target.length-2) end var nmodule = nmoduledecl.parent.as(AModule) @@ -93,7 +85,7 @@ end redef class MModule private var local_target_platform: nullable Platform = null - # Recusively get the platform targetted by this module or imported modules + # Recursively get the platform targeted by this module or imported modules fun target_platform: nullable Platform do var ltp = local_target_platform @@ -112,5 +104,12 @@ end # # Services will be added to this class in other modules. abstract class Platform + # Does the platform provide and support the library `unwind`? fun supports_libunwind: Bool do return true + + # Does the platform provide and supports the Boehm's GC library? + fun supports_libgc: Bool do return true + + # Does this platform declare its own main function? If so, we won't generate one in Nit. + fun no_main: Bool do return false end