Add a clear function.

This commit is contained in:
Danila Fedorin 2018-08-08 22:21:57 -07:00
parent e740fd7688
commit eb32577d38
2 changed files with 11 additions and 0 deletions

View File

@ -68,6 +68,7 @@ module Chalk
table.set_function "set_sound", FunctionEntry.new Builtin::InlineSetSoundFunction.new table.set_function "set_sound", FunctionEntry.new Builtin::InlineSetSoundFunction.new
table.set_function "draw_number", FunctionEntry.new Builtin::InlineDrawNumberFunction.new table.set_function "draw_number", FunctionEntry.new Builtin::InlineDrawNumberFunction.new
table.set_function "draw_sprite", FunctionEntry.new Builtin::InlineDrawSpriteFunction.new table.set_function "draw_sprite", FunctionEntry.new Builtin::InlineDrawSpriteFunction.new
table.set_function "clear", FunctionEntry.new Builtin::InlineClearFunction.new
return table return table
end end

View File

@ -97,5 +97,15 @@ module Chalk
return Compiler::FunctionType.new([Compiler::Type::U8] * 3, Compiler::Type::U0) return Compiler::FunctionType.new([Compiler::Type::U8] * 3, Compiler::Type::U0)
end end
end end
class InlineClearFunction < InlineFunction
def generate!(emitter, params, table, target, free)
emitter.instructions << Ir::ClearInstruction.new
end
def type
return Compiler::FunctionType.new(([] of Compiler::Type), Compiler::Type::U0)
end
end
end end
end end