nitc :: PlatformPhase :: defaultinit
nitc $ PlatformPhase :: SELF
Type of this instance, automatically specialized in every classnitc $ PlatformPhase :: process_annotated_node
Specific actions to execute on annotated nodesnitc :: Phase :: _in_hierarchy
The dependence relation of the phase with the other phasesnitc :: Phase :: _toolcontext
The toolcontext instance attached to the phasecore :: Object :: class_factory
Implementation used byget_class
to create the specific class.
nitc :: PlatformPhase :: defaultinit
nitc :: Phase :: defaultinit
core :: Object :: defaultinit
nitc :: Phase :: in_hierarchy
The dependence relation of the phase with the other phasesnitc :: Phase :: in_hierarchy=
The dependence relation of the phase with the other phasescore :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: Object :: native_class_name
The class name of the object in CString format.core :: Object :: output_class_name
Display class name on stdout (debug only).nitc :: Phase :: process_annotated_node
Specific actions to execute on annotated nodesnitc :: Phase :: process_mainmodule
Specific action to execute on the whole program.nitc :: Phase :: process_nclassdef
Specific actions to execute on the tree of a class definitionnitc :: Phase :: process_nmodule
Specific actions to execute on the whole tree of a modulenitc :: Phase :: process_nmodule_after
Specific actions to execute on the whole tree of a modulenitc :: Phase :: process_npropdef
Specific actions to execute on the tree of a propertynitc :: Phase :: toolcontext
The toolcontext instance attached to the phasenitc :: Phase :: toolcontext=
The toolcontext instance attached to the phase
private class PlatformPhase
super Phase
redef fun process_annotated_node(nmoduledecl, nat)
do
var annotation_name = "platform"
# Skip if we are not interested
if nat.name != annotation_name then return
# Do some validity checks and print errors if the annotation is used incorrectly
var modelbuilder = toolcontext.modelbuilder
if not nmoduledecl isa AModuledecl then
modelbuilder.error(nat, "Syntax Error: only the declaration of modules may use `{annotation_name}`.")
return
end
var args = nat.n_args
var platform_name
if args.length > 1 then
modelbuilder.error(nat, "Syntax Error: `{annotation_name}` expects at most a single argument.")
return
else if args.is_empty then
platform_name = nmoduledecl.n_name.collect_text
else
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
end
var nmodule = nmoduledecl.parent.as(AModule)
var mmodule = nmodule.mmodule
var platform = toolcontext.platform_from_name(platform_name)
if platform == null then
toolcontext.error(nat.location, "Error: target platform `{platform_name}` unknown.")
return
end
var previous_target_platform = mmodule.target_platform
if previous_target_platform != null and previous_target_platform != platform then
modelbuilder.error(nat, "Syntax Error: a target platform has already been defined as `{previous_target_platform}`.")
end
mmodule.local_target_platform = platform
end
end
src/platform/platform.nit:36,1--85,3