Limit methods to 255 arguments

This allows us to use a single byte to store the number of arguments.
Currently this is not yet used, but will be when we rework the memory
layout of VM instructions.
parent a1d6c210
Pipeline #163678552 passed with stages
in 88 minutes and 29 seconds
......@@ -85,6 +85,8 @@ module Inkoc
RUNTIME_DIRECTORY = 'runtime'
MAXIMUM_METHOD_ARGUMENTS = 255
attr_reader :source_directories, :mode, :target
def self.core_module_name(name)
......
......@@ -399,5 +399,12 @@ module Inkoc
location
)
end
def too_many_arguments(location)
error(
"Methods are limited to a maximum of #{Config::MAXIMUM_METHOD_ARGUMENTS} arguments",
location
)
end
end
end
......@@ -591,6 +591,10 @@ module Inkoc
end
def on_method(node, scope)
if node.arguments.length > Config::MAXIMUM_METHOD_ARGUMENTS
diagnostics.too_many_arguments(node.location)
end
type = TypeSystem::Block.named_method(node.name, typedb.block_type)
new_scope = TypeScope.new(
......
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