Remove code made obsolete with type checking.
This commit is contained in:
parent
f8320bcb82
commit
3fa292347f
|
@ -4,11 +4,8 @@ module Chalk
|
|||
# that is provided by chalk's standard library, and therefore
|
||||
# has predefined output.
|
||||
abstract class BuiltinFunction
|
||||
# Gets the number of parameters this function has.
|
||||
getter param_count : Int32
|
||||
|
||||
# Creates a new function with *param_count* parameters.
|
||||
def initialize(@param_count)
|
||||
def initialize()
|
||||
end
|
||||
|
||||
# Uses the given `Compiler::Emitter` to output code.
|
||||
|
@ -22,11 +19,8 @@ module Chalk
|
|||
# function also accepts trees rather than register numbers,
|
||||
# and therefore can accept and manipulate trees.
|
||||
abstract class InlineFunction
|
||||
# Gets the number of parameters this function has.
|
||||
getter param_count : Int32
|
||||
|
||||
# Creates a new function with *param_count* parameters.
|
||||
def initialize(@param_count)
|
||||
def initialize()
|
||||
end
|
||||
|
||||
# Generates code like `Compiler::CodeGenerator` would.
|
||||
|
|
|
@ -96,12 +96,9 @@ module Chalk
|
|||
generate! tree.right, table, free, free + 1
|
||||
opr tree.op, target, free
|
||||
when Trees::TreeCall
|
||||
entry = table[tree.name]?
|
||||
raise "Unknown function" unless entry &&
|
||||
entry.is_a?(FunctionEntry)
|
||||
function = entry.function
|
||||
raise "Invalid call" if tree.params.size != function.param_count
|
||||
generate! tree, function, table, target, free
|
||||
entry = table[tree.name]?.not_nil!
|
||||
raise "Unknown function" unless entry.is_a?(FunctionEntry)
|
||||
generate! tree, entry.function, table, target, free
|
||||
when Trees::TreeBlock
|
||||
table = Table.new(table)
|
||||
tree.children.each do |child|
|
||||
|
|
|
@ -5,10 +5,6 @@ module Chalk
|
|||
module Builtin
|
||||
# Inline function to draw sprite at address I.
|
||||
class InlineDrawFunction < InlineFunction
|
||||
def initialize
|
||||
@param_count = 3
|
||||
end
|
||||
|
||||
def generate!(emitter, params, table, target, free)
|
||||
if !params[2].is_a?(Trees::TreeLit)
|
||||
raise "Third parameter must be a constant."
|
||||
|
@ -24,10 +20,6 @@ module Chalk
|
|||
|
||||
# Inline function to await for a key and return it.
|
||||
class InlineAwaitKeyFunction < InlineFunction
|
||||
def initialize
|
||||
@param_count = 0
|
||||
end
|
||||
|
||||
def generate!(emitter, params, table, target, free)
|
||||
emitter.instructions << Ir::AwaitKeyInstruction.new target
|
||||
end
|
||||
|
@ -38,10 +30,6 @@ module Chalk
|
|||
|
||||
# Inline function to get font for a given value.
|
||||
class InlineGetFontFunction < InlineFunction
|
||||
def initialize
|
||||
@param_count = 1
|
||||
end
|
||||
|
||||
def generate!(emitter, params, table, target, free)
|
||||
emitter.generate! params[0], table, free, free + 1
|
||||
emitter.instructions << Ir::GetFontInstruction.new free
|
||||
|
@ -53,14 +41,11 @@ module Chalk
|
|||
|
||||
# Inline function to set the delay timer.
|
||||
class InlineSetDelayFunction < InlineFunction
|
||||
def initialize
|
||||
@param_count = 1
|
||||
end
|
||||
|
||||
def generate!(emitter, params, table, target, free)
|
||||
emitter.generate! params[0], table, free, free + 1
|
||||
emitter.instructions << Ir::SetDelayTimerInstruction.new free
|
||||
end
|
||||
|
||||
def type
|
||||
return Compiler::FunctionType.new([Compiler::Type::U8], Compiler::Type::U0)
|
||||
end
|
||||
|
@ -68,10 +53,6 @@ module Chalk
|
|||
|
||||
# Inline function to get the delay timer.
|
||||
class InlineGetDelayFunction < InlineFunction
|
||||
def initialize
|
||||
@param_count = 0
|
||||
end
|
||||
|
||||
def generate!(emitter, params, table, target, free)
|
||||
emitter.instructions << Ir::GetDelayTimerInstruction.new target
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user