Browse Source

Add a clear function.

master
Danila Fedorin 3 years ago
parent
commit
eb32577d38
  1. 1
      src/chalk/compiler.cr
  2. 10
      src/chalk/inline.cr

1
src/chalk/compiler.cr

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

10
src/chalk/inline.cr

@ -97,5 +97,15 @@ module Chalk
return Compiler::FunctionType.new([Compiler::Type::U8] * 3, Compiler::Type::U0)
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
Loading…
Cancel
Save