had to let go of crystal (sniff) as the name was taken
This commit is contained in:
parent
f8e3f17660
commit
fb105cb895
2
Gemfile
2
Gemfile
@ -1,7 +1,7 @@
|
||||
source "http://rubygems.org"
|
||||
|
||||
gem "parslet" , :git => 'https://github.com/NigelThorne/parslet.git'
|
||||
gem "crystal-reader" , "0.1.0" , :require => "parser" , :git => "https://github.com/crystal-vm/crystal-reader.git"
|
||||
gem "sapphire-reader" , "0.1.0" , :require => "parser" , :git => "https://github.com/sapphire-vm/sapphire-reader.git"
|
||||
|
||||
group :development do
|
||||
gem "minitest"
|
||||
|
@ -6,10 +6,10 @@ GIT
|
||||
blankslate (~> 2.0)
|
||||
|
||||
GIT
|
||||
remote: https://github.com/crystal-vm/crystal-reader.git
|
||||
remote: https://github.com/sapphire-vm/sapphire-reader.git
|
||||
revision: 0c88e7eff569a6c1b0f354418daacb9ad2ac621a
|
||||
specs:
|
||||
crystal-reader (0.1.0)
|
||||
sapphire-reader (0.1.0)
|
||||
|
||||
GEM
|
||||
remote: http://rubygems.org/
|
||||
@ -87,7 +87,7 @@ PLATFORMS
|
||||
x64-mingw32
|
||||
|
||||
DEPENDENCIES
|
||||
crystal-reader (= 0.1.0)!
|
||||
sapphire-reader (= 0.1.0)!
|
||||
jeweler
|
||||
minitest
|
||||
parslet!
|
||||
|
@ -1,7 +1,7 @@
|
||||
#Crystal
|
||||
#Sapphire
|
||||
|
||||
|
||||
Crystal is about native code generation in and of ruby. In is done.
|
||||
Sapphire is about native code generation in and of ruby. In is done.
|
||||
|
||||
### Step 1 - Assembly
|
||||
|
||||
@ -125,7 +125,7 @@ Celebrate New year 2030
|
||||
|
||||
|
||||
|
||||
Contributing to crystal
|
||||
Contributing to sapphire
|
||||
-----------------------
|
||||
|
||||
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'
|
||||
Jeweler::Tasks.new do |gem|
|
||||
# gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
|
||||
gem.name = "crystal"
|
||||
gem.homepage = "http://github.com/crystal-ruby/crystal"
|
||||
gem.name = "sapphire"
|
||||
gem.homepage = "http://github.com/sapphire-ruby/sapphire"
|
||||
gem.license = "MIT"
|
||||
gem.summary = %Q{Create fast code}
|
||||
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') : ""
|
||||
|
||||
rdoc.rdoc_dir = 'rdoc'
|
||||
rdoc.title = "crystal #{version}"
|
||||
rdoc.title = "sapphire #{version}"
|
||||
rdoc.rdoc_files.include('README*')
|
||||
rdoc.rdoc_files.include('lib/**/*.rb')
|
||||
end
|
||||
|
@ -1,17 +1,17 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
|
||||
Gem::Specification.new do |s|
|
||||
s.name = 'crystal'
|
||||
s.name = 'sapphire'
|
||||
s.version = '0.0.1'
|
||||
|
||||
s.authors = ['Torsten Ruger']
|
||||
s.email = 'torsten@villataika.fi'
|
||||
s.extra_rdoc_files = ['README.markdown']
|
||||
s.files = %w(README.markdown LICENSE.txt Rakefile) + Dir.glob("lib/**/*")
|
||||
s.homepage = 'https://github.com/crystal-vm/crystal'
|
||||
s.homepage = 'https://github.com/sapphire-vm/sapphire'
|
||||
s.license = 'MIT'
|
||||
s.require_paths = ['lib']
|
||||
s.summary = 'Hey crystal, what do you want to be when you grow up: I like pink and red, i wanna be a ruby'
|
||||
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.add_dependency 'parslet', '~> 1.6.1'
|
||||
end
|
||||
|
@ -7,7 +7,7 @@ module Ast
|
||||
context.current_class = clazz
|
||||
expressions.each do |expression|
|
||||
# check if it's a function definition and add
|
||||
# if not, execute it, but that does means we should be in crystal (executable), not ruby. ie throw an error for now
|
||||
# if not, execute it, but that does means we should be in sapphire (executable), not ruby. ie throw an error for now
|
||||
raise "only functions for now #{expression.inspect}" unless expression.is_a? Ast::FunctionExpression
|
||||
puts "compiling expression #{expression}"
|
||||
expression_value = expression.compile(context )
|
||||
|
@ -55,7 +55,7 @@ module Boot
|
||||
end
|
||||
[:putstring,:putint,:fibo,:exit].each do |f|
|
||||
#puts "Boot Kernel::#{f}"
|
||||
obj.add_method_definition Crystal::Kernel.send(f , @context)
|
||||
obj.add_method_definition Sapphire::Kernel.send(f , @context)
|
||||
end
|
||||
obj = get_or_create_class :String
|
||||
[: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,
|
||||
one of those chicken and egg things. C uses Assembler in this situation, we use Kernel function.
|
||||
|
||||
Slightly more here : http://crystal-vm.github.io/2014/06/10/more-clarity.html
|
||||
Slightly more here : http://sapphire-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.
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#integer related kernel functions
|
||||
module Crystal
|
||||
module Sapphire
|
||||
module Kernel
|
||||
# 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
|
||||
|
@ -1,4 +1,4 @@
|
||||
module Crystal
|
||||
module Sapphire
|
||||
module Kernel
|
||||
def self.putstring context
|
||||
function = Virtual::MethodDefinition.new(:putstring , [] )
|
||||
|
@ -1,4 +1,4 @@
|
||||
module Crystal
|
||||
module Sapphire
|
||||
module Kernel
|
||||
def self.exit context
|
||||
function = Virtual::MethodDefinition.new(:exit , [] , Virtual::Integer)
|
||||
|
@ -8,7 +8,7 @@ provides the stack glue. All the stuff a compiler would usually do.
|
||||
|
||||
Also all syscalls are abstracted as functions.
|
||||
|
||||
The Crystal Convention
|
||||
The Sapphire Convention
|
||||
----------------------
|
||||
|
||||
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
|
||||
# encode them into what-ever is neccessary, but this approach leaves more possibility to
|
||||
# optimize the actual instruction stream (not just the crystal instruction stream). Makes sense?
|
||||
# optimize the actual instruction stream (not just the sapphire instruction stream). Makes sense?
|
||||
|
||||
# We have basic classes (literally) of instructions
|
||||
# - Memory
|
||||
|
@ -7,7 +7,7 @@ module Ast
|
||||
context.current_class = clazz
|
||||
expressions.each do |expression|
|
||||
# check if it's a function definition and add
|
||||
# if not, execute it, but that does means we should be in crystal (executable), not ruby. ie throw an error for now
|
||||
# if not, execute it, but that does means we should be in sapphire (executable), not ruby. ie throw an error for now
|
||||
raise "only functions for now #{expression.inspect}" unless expression.is_a? Ast::FunctionExpression
|
||||
puts "compiling expression #{expression}"
|
||||
expression_value = expression.compile(context )
|
||||
|
@ -69,7 +69,7 @@ module Boot
|
||||
end
|
||||
[:utoa, :putstring,:putint,:fibo,:exit].each do |f|
|
||||
#puts "Boot Kernel::#{f}"
|
||||
obj.add_function Crystal::Kernel.send(f , @context)
|
||||
obj.add_function Sapphire::Kernel.send(f , @context)
|
||||
end
|
||||
obj = get_or_create_class :String
|
||||
[: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.
|
||||
|
||||
A work in progress that started from here : http://crystal-vm.github.io/2014/06/10/more-clarity.html
|
||||
A work in progress that started from here : http://sapphire-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 crystal
|
||||
# instead it is parsed by crystal to define part of the crystal that runs
|
||||
# this is not a "normal" ruby file, ie it is not required by sapphire
|
||||
# instead it is parsed by sapphire to define part of the sapphire that runs
|
||||
|
||||
class Array < BaseObject
|
||||
def initialize size
|
||||
|
@ -1,7 +1,7 @@
|
||||
require 'parslet'
|
||||
|
||||
require "elf/object_writer"
|
||||
require 'parser/crystal'
|
||||
require 'parser/sapphire'
|
||||
require 'parser/transform'
|
||||
require "virtual/machine"
|
||||
require "ast/all"
|
@ -17,7 +17,7 @@ module Fragments
|
||||
end
|
||||
|
||||
def parse
|
||||
parser = Parser::Crystal.new
|
||||
parser = Parser::Sapphire.new
|
||||
syntax = parser.parse_with_debug(@string_input)
|
||||
parts = Parser::Transform.new.apply(syntax)
|
||||
# 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
|
||||
@string_input = <<HERE
|
||||
"Hello Raisa, I am crystal".putstring()
|
||||
"Hello Raisa, I am sapphire".putstring()
|
||||
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]
|
||||
@output = "Hello Raisa, I am crystal "
|
||||
@output = "Hello Raisa, I am sapphire "
|
||||
@target = [:Object , :putstring]
|
||||
parse
|
||||
write "hello"
|
||||
|
@ -75,7 +75,7 @@ HERE
|
||||
end
|
||||
|
||||
def parse
|
||||
parser = Parser::Crystal.new
|
||||
parser = Parser::Sapphire.new
|
||||
syntax = parser.parse_with_debug(@string_input)
|
||||
parts = Parser::Transform.new.apply(syntax)
|
||||
# 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__), '..', 'test'))
|
||||
|
||||
require 'crystal'
|
||||
require 'sapphire'
|
||||
|
@ -19,7 +19,7 @@ class TestRunner < MiniTest::Test
|
||||
|
||||
def execute file
|
||||
string = File.read(file)
|
||||
parser = Parser::Crystal.new
|
||||
parser = Parser::Sapphire.new
|
||||
object_space = Vm::Program.new "Arm"
|
||||
syntax = parser.parse_with_debug(string)
|
||||
assert syntax
|
||||
|
@ -8,7 +8,7 @@ module VirtualHelper
|
||||
end
|
||||
|
||||
def check
|
||||
parser = Parser::Crystal.new
|
||||
parser = Parser::Sapphire.new
|
||||
syntax = parser.parse_with_debug(@string_input)
|
||||
parts = Parser::Transform.new.apply(syntax)
|
||||
machine = Virtual::Machine.new
|
||||
|
Loading…
Reference in New Issue
Block a user