renamed to kide(crystal)
This commit is contained in:
parent
fb105cb895
commit
337b1a8ee0
2
Gemfile
2
Gemfile
@ -1,7 +1,7 @@
|
|||||||
source "http://rubygems.org"
|
source "http://rubygems.org"
|
||||||
|
|
||||||
gem "parslet" , :git => 'https://github.com/NigelThorne/parslet.git'
|
gem "parslet" , :git => 'https://github.com/NigelThorne/parslet.git'
|
||||||
gem "sapphire-reader" , "0.1.0" , :require => "parser" , :git => "https://github.com/sapphire-vm/sapphire-reader.git"
|
gem "kide-reader" , "0.1.0" , :require => "parser" , :git => "https://github.com/kide-vm/kide-reader.git"
|
||||||
|
|
||||||
group :development do
|
group :development do
|
||||||
gem "minitest"
|
gem "minitest"
|
||||||
|
@ -6,10 +6,10 @@ GIT
|
|||||||
blankslate (~> 2.0)
|
blankslate (~> 2.0)
|
||||||
|
|
||||||
GIT
|
GIT
|
||||||
remote: https://github.com/sapphire-vm/sapphire-reader.git
|
remote: https://github.com/kide-vm/kide-reader.git
|
||||||
revision: 0c88e7eff569a6c1b0f354418daacb9ad2ac621a
|
revision: 0c88e7eff569a6c1b0f354418daacb9ad2ac621a
|
||||||
specs:
|
specs:
|
||||||
sapphire-reader (0.1.0)
|
kide-reader (0.1.0)
|
||||||
|
|
||||||
GEM
|
GEM
|
||||||
remote: http://rubygems.org/
|
remote: http://rubygems.org/
|
||||||
@ -87,7 +87,7 @@ PLATFORMS
|
|||||||
x64-mingw32
|
x64-mingw32
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
sapphire-reader (= 0.1.0)!
|
kide-reader (= 0.1.0)!
|
||||||
jeweler
|
jeweler
|
||||||
minitest
|
minitest
|
||||||
parslet!
|
parslet!
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#Sapphire
|
#Kide
|
||||||
|
|
||||||
|
|
||||||
Sapphire is about native code generation in and of ruby. In is done.
|
Kide is about native code generation in and of ruby. In is done.
|
||||||
|
|
||||||
### Step 1 - Assembly
|
### Step 1 - Assembly
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ Celebrate New year 2030
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
Contributing to sapphire
|
Contributing to kide
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
Probably best to talk to me, if it's not a typo or so.
|
Probably best to talk to me, if it's not a typo or so.
|
||||||
|
6
Rakefile
6
Rakefile
@ -14,8 +14,8 @@ require 'rake'
|
|||||||
require 'jeweler'
|
require 'jeweler'
|
||||||
Jeweler::Tasks.new do |gem|
|
Jeweler::Tasks.new do |gem|
|
||||||
# gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
|
# gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
|
||||||
gem.name = "sapphire"
|
gem.name = "kide"
|
||||||
gem.homepage = "http://github.com/sapphire-ruby/sapphire"
|
gem.homepage = "http://github.com/kide-ruby/kide"
|
||||||
gem.license = "MIT"
|
gem.license = "MIT"
|
||||||
gem.summary = %Q{Create fast code}
|
gem.summary = %Q{Create fast code}
|
||||||
gem.description = %Q{A long way to china and back}
|
gem.description = %Q{A long way to china and back}
|
||||||
@ -51,7 +51,7 @@ Rake::RDocTask.new do |rdoc|
|
|||||||
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
||||||
|
|
||||||
rdoc.rdoc_dir = 'rdoc'
|
rdoc.rdoc_dir = 'rdoc'
|
||||||
rdoc.title = "sapphire #{version}"
|
rdoc.title = "kide #{version}"
|
||||||
rdoc.rdoc_files.include('README*')
|
rdoc.rdoc_files.include('README*')
|
||||||
rdoc.rdoc_files.include('lib/**/*.rb')
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
||||||
end
|
end
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- encoding: utf-8 -*-
|
||||||
|
|
||||||
Gem::Specification.new do |s|
|
Gem::Specification.new do |s|
|
||||||
s.name = 'sapphire'
|
s.name = 'kide'
|
||||||
s.version = '0.0.1'
|
s.version = '0.0.1'
|
||||||
|
|
||||||
s.authors = ['Torsten Ruger']
|
s.authors = ['Torsten Ruger']
|
||||||
s.email = 'torsten@villataika.fi'
|
s.email = 'torsten@villataika.fi'
|
||||||
s.extra_rdoc_files = ['README.markdown']
|
s.extra_rdoc_files = ['README.markdown']
|
||||||
s.files = %w(README.markdown LICENSE.txt Rakefile) + Dir.glob("lib/**/*")
|
s.files = %w(README.markdown LICENSE.txt Rakefile) + Dir.glob("lib/**/*")
|
||||||
s.homepage = 'https://github.com/sapphire-vm/sapphire'
|
s.homepage = 'https://github.com/kide-vm/kide'
|
||||||
s.license = 'MIT'
|
s.license = 'MIT'
|
||||||
s.require_paths = ['lib']
|
s.require_paths = ['lib']
|
||||||
s.summary = 'Hey sapphire, what do you want to be when you grow up: I like pink and red, i wanna be a ruby'
|
s.summary = 'Hey kide, what do you want to be when you grow up: I like pink and red, i wanna be a ruby'
|
||||||
|
|
||||||
s.add_dependency 'parslet', '~> 1.6.1'
|
s.add_dependency 'parslet', '~> 1.6.1'
|
||||||
end
|
end
|
@ -7,7 +7,7 @@ module Ast
|
|||||||
context.current_class = clazz
|
context.current_class = clazz
|
||||||
expressions.each do |expression|
|
expressions.each do |expression|
|
||||||
# check if it's a function definition and add
|
# check if it's a function definition and add
|
||||||
# if not, execute it, but that does means we should be in sapphire (executable), not ruby. ie throw an error for now
|
# if not, execute it, but that does means we should be in kide (executable), not ruby. ie throw an error for now
|
||||||
raise "only functions for now #{expression.inspect}" unless expression.is_a? Ast::FunctionExpression
|
raise "only functions for now #{expression.inspect}" unless expression.is_a? Ast::FunctionExpression
|
||||||
puts "compiling expression #{expression}"
|
puts "compiling expression #{expression}"
|
||||||
expression_value = expression.compile(context )
|
expression_value = expression.compile(context )
|
||||||
|
@ -55,7 +55,7 @@ module Boot
|
|||||||
end
|
end
|
||||||
[:putstring,:putint,:fibo,:exit].each do |f|
|
[:putstring,:putint,:fibo,:exit].each do |f|
|
||||||
#puts "Boot Kernel::#{f}"
|
#puts "Boot Kernel::#{f}"
|
||||||
obj.add_method_definition Sapphire::Kernel.send(f , @context)
|
obj.add_method_definition Kide::Kernel.send(f , @context)
|
||||||
end
|
end
|
||||||
obj = get_or_create_class :String
|
obj = get_or_create_class :String
|
||||||
[:get , :set].each do |f|
|
[:get , :set].each do |f|
|
||||||
|
@ -8,7 +8,7 @@ function.
|
|||||||
A normal ruby function is one that is parsed and transformed to code. But not all functionality can be written in ruby,
|
A normal ruby function is one that is parsed and transformed to code. But not all functionality can be written in ruby,
|
||||||
one of those chicken and egg things. C uses Assembler in this situation, we use Kernel function.
|
one of those chicken and egg things. C uses Assembler in this situation, we use Kernel function.
|
||||||
|
|
||||||
Slightly more here : http://sapphire-vm.github.io/2014/06/10/more-clarity.html
|
Slightly more here : http://kide-vm.github.io/2014/06/10/more-clarity.html
|
||||||
|
|
||||||
The Kernal module is scattered into several files, but that is just so the file doesn't get too long.
|
The Kernal module is scattered into several files, but that is just so the file doesn't get too long.
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#integer related kernel functions
|
#integer related kernel functions
|
||||||
module Sapphire
|
module Kide
|
||||||
module Kernel
|
module Kernel
|
||||||
# The conversion to base10 is quite a bit more complicated than i thought. The bulk of it is in div10
|
# The conversion to base10 is quite a bit more complicated than i thought. The bulk of it is in div10
|
||||||
# We set up variables, do the devision and write the result to the string
|
# We set up variables, do the devision and write the result to the string
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
module Sapphire
|
module Kide
|
||||||
module Kernel
|
module Kernel
|
||||||
def self.putstring context
|
def self.putstring context
|
||||||
function = Virtual::MethodDefinition.new(:putstring , [] )
|
function = Virtual::MethodDefinition.new(:putstring , [] )
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
module Sapphire
|
module Kide
|
||||||
module Kernel
|
module Kernel
|
||||||
def self.exit context
|
def self.exit context
|
||||||
function = Virtual::MethodDefinition.new(:exit , [] , Virtual::Integer)
|
function = Virtual::MethodDefinition.new(:exit , [] , Virtual::Integer)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
require 'parslet'
|
require 'parslet'
|
||||||
|
|
||||||
require "elf/object_writer"
|
require "elf/object_writer"
|
||||||
require 'parser/sapphire'
|
require 'parser/kide'
|
||||||
require 'parser/transform'
|
require 'parser/transform'
|
||||||
require "virtual/machine"
|
require "virtual/machine"
|
||||||
require "ast/all"
|
require "ast/all"
|
@ -8,7 +8,7 @@ provides the stack glue. All the stuff a compiler would usually do.
|
|||||||
|
|
||||||
Also all syscalls are abstracted as functions.
|
Also all syscalls are abstracted as functions.
|
||||||
|
|
||||||
The Sapphire Convention
|
The Kide Convention
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
Since we're not in c, we use the regsters more suitably for our job:
|
Since we're not in c, we use the regsters more suitably for our job:
|
||||||
|
@ -7,7 +7,7 @@ module Vm
|
|||||||
|
|
||||||
# Admittately it would be simpler just to create the (abstract) instructions and let the machine
|
# Admittately it would be simpler just to create the (abstract) instructions and let the machine
|
||||||
# encode them into what-ever is neccessary, but this approach leaves more possibility to
|
# encode them into what-ever is neccessary, but this approach leaves more possibility to
|
||||||
# optimize the actual instruction stream (not just the sapphire instruction stream). Makes sense?
|
# optimize the actual instruction stream (not just the kide instruction stream). Makes sense?
|
||||||
|
|
||||||
# We have basic classes (literally) of instructions
|
# We have basic classes (literally) of instructions
|
||||||
# - Memory
|
# - Memory
|
||||||
|
@ -7,7 +7,7 @@ module Ast
|
|||||||
context.current_class = clazz
|
context.current_class = clazz
|
||||||
expressions.each do |expression|
|
expressions.each do |expression|
|
||||||
# check if it's a function definition and add
|
# check if it's a function definition and add
|
||||||
# if not, execute it, but that does means we should be in sapphire (executable), not ruby. ie throw an error for now
|
# if not, execute it, but that does means we should be in kide (executable), not ruby. ie throw an error for now
|
||||||
raise "only functions for now #{expression.inspect}" unless expression.is_a? Ast::FunctionExpression
|
raise "only functions for now #{expression.inspect}" unless expression.is_a? Ast::FunctionExpression
|
||||||
puts "compiling expression #{expression}"
|
puts "compiling expression #{expression}"
|
||||||
expression_value = expression.compile(context )
|
expression_value = expression.compile(context )
|
||||||
|
@ -69,7 +69,7 @@ module Boot
|
|||||||
end
|
end
|
||||||
[:utoa, :putstring,:putint,:fibo,:exit].each do |f|
|
[:utoa, :putstring,:putint,:fibo,:exit].each do |f|
|
||||||
#puts "Boot Kernel::#{f}"
|
#puts "Boot Kernel::#{f}"
|
||||||
obj.add_function Sapphire::Kernel.send(f , @context)
|
obj.add_function Kide::Kernel.send(f , @context)
|
||||||
end
|
end
|
||||||
obj = get_or_create_class :String
|
obj = get_or_create_class :String
|
||||||
[:get , :set].each do |f|
|
[:get , :set].each do |f|
|
||||||
|
@ -4,4 +4,4 @@ Here we have a placeholder for things i am currently developing.
|
|||||||
|
|
||||||
Basically Parfait is the smallest amount of code needed to make a ruby-like OO system work.
|
Basically Parfait is the smallest amount of code needed to make a ruby-like OO system work.
|
||||||
|
|
||||||
A work in progress that started from here : http://sapphire-vm.github.io/2014/06/10/more-clarity.html
|
A work in progress that started from here : http://kide-vm.github.io/2014/06/10/more-clarity.html
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# this is not a "normal" ruby file, ie it is not required by sapphire
|
# this is not a "normal" ruby file, ie it is not required by kide
|
||||||
# instead it is parsed by sapphire to define part of the sapphire that runs
|
# instead it is parsed by kide to define part of the kide that runs
|
||||||
|
|
||||||
class Array < BaseObject
|
class Array < BaseObject
|
||||||
def initialize size
|
def initialize size
|
||||||
|
@ -17,7 +17,7 @@ module Fragments
|
|||||||
end
|
end
|
||||||
|
|
||||||
def parse
|
def parse
|
||||||
parser = Parser::Sapphire.new
|
parser = Parser::Kide.new
|
||||||
syntax = parser.parse_with_debug(@string_input)
|
syntax = parser.parse_with_debug(@string_input)
|
||||||
parts = Parser::Transform.new.apply(syntax)
|
parts = Parser::Transform.new.apply(syntax)
|
||||||
# file is a list of expressions, all but the last must be a function
|
# file is a list of expressions, all but the last must be a function
|
||||||
|
@ -5,10 +5,10 @@ class TestHello < MiniTest::Test
|
|||||||
|
|
||||||
def test_hello
|
def test_hello
|
||||||
@string_input = <<HERE
|
@string_input = <<HERE
|
||||||
"Hello Raisa, I am sapphire".putstring()
|
"Hello Raisa, I am kide".putstring()
|
||||||
HERE
|
HERE
|
||||||
@should = [0x0,0x40,0x2d,0xe9,0x1,0x0,0xa0,0xe3,0x2,0x10,0xa0,0xe1,0x3,0x20,0xa0,0xe1,0x4,0x70,0xa0,0xe3,0x0,0x0,0x0,0xef,0x0,0x80,0xbd,0xe8]
|
@should = [0x0,0x40,0x2d,0xe9,0x1,0x0,0xa0,0xe3,0x2,0x10,0xa0,0xe1,0x3,0x20,0xa0,0xe1,0x4,0x70,0xa0,0xe3,0x0,0x0,0x0,0xef,0x0,0x80,0xbd,0xe8]
|
||||||
@output = "Hello Raisa, I am sapphire "
|
@output = "Hello Raisa, I am kide "
|
||||||
@target = [:Object , :putstring]
|
@target = [:Object , :putstring]
|
||||||
parse
|
parse
|
||||||
write "hello"
|
write "hello"
|
||||||
|
@ -75,7 +75,7 @@ HERE
|
|||||||
end
|
end
|
||||||
|
|
||||||
def parse
|
def parse
|
||||||
parser = Parser::Sapphire.new
|
parser = Parser::Kide.new
|
||||||
syntax = parser.parse_with_debug(@string_input)
|
syntax = parser.parse_with_debug(@string_input)
|
||||||
parts = Parser::Transform.new.apply(syntax)
|
parts = Parser::Transform.new.apply(syntax)
|
||||||
# file is a list of expressions, all but the last must be a function
|
# file is a list of expressions, all but the last must be a function
|
||||||
|
@ -28,4 +28,4 @@ require "minitest/autorun"
|
|||||||
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
||||||
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'test'))
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'test'))
|
||||||
|
|
||||||
require 'sapphire'
|
require 'kide'
|
||||||
|
@ -19,7 +19,7 @@ class TestRunner < MiniTest::Test
|
|||||||
|
|
||||||
def execute file
|
def execute file
|
||||||
string = File.read(file)
|
string = File.read(file)
|
||||||
parser = Parser::Sapphire.new
|
parser = Parser::Kide.new
|
||||||
object_space = Vm::Program.new "Arm"
|
object_space = Vm::Program.new "Arm"
|
||||||
syntax = parser.parse_with_debug(string)
|
syntax = parser.parse_with_debug(string)
|
||||||
assert syntax
|
assert syntax
|
||||||
|
@ -8,7 +8,7 @@ module VirtualHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
def check
|
def check
|
||||||
parser = Parser::Sapphire.new
|
parser = Parser::Kide.new
|
||||||
syntax = parser.parse_with_debug(@string_input)
|
syntax = parser.parse_with_debug(@string_input)
|
||||||
parts = Parser::Transform.new.apply(syntax)
|
parts = Parser::Transform.new.apply(syntax)
|
||||||
machine = Virtual::Machine.new
|
machine = Virtual::Machine.new
|
||||||
|
Loading…
Reference in New Issue
Block a user