mfichman / jogo Goto Github PK
View Code? Open in Web Editor NEWHigh(er) performance compiled programming language with clean, powerful syntax
License: MIT License
High(er) performance compiled programming language with clean, powerful syntax
License: MIT License
Add version number to usage, add --version option.
Similar to Haskell data structures. For example, a union type could be:
Json::Value = Bool | Int | Float | String | Array[Json::Value] | Map[Json::Value]
A union type is a subtype of any of the types in the union. Also, any type in the union is a subtype of the union type. Thus assignments such as this are legal:
val Json::Value = true
int Int = val
If 'val' is not the requested type, nil or the default value is used. Also, the is
operator should be implemented:
if val is Bool {
bool Bool = val
}
The is
operator returns true if the tag is equal to the requested type. Every union has a tag that is equal to the vtable for the requested type:
struct Union {
Ptr _vtable;
Ptr _refcount;
T _val ?
};
If the Union is a primitive or value, then the value is embedded directly into _val. If Union is a reference object, Union is just a pointer to the reference object. When packing/unpacking Unions, the _vtable field is examined to determine the type. So an assignment with a Union looks like this (in C):
int Int = (val._vtable == Int__vtable) ? val_.val : 0;
string String = (val._vtable == String__vtable) ? val : 0;
Union types are reference objects.
match variable {
with 8:
Io::println('matched 8')
with 7:
Io::println('matched 7')
default:
Io::println('default')
}
Add asynchronous I/O using coroutines. Store the overlapped I/O structures in the coroutine structure.
Value parameters that are modified should automatically be copied once upon entry to the function. This may interact w/ the copier, but custom copiers are not yet allowed.
sample(vec Vec3) {
vec.x = 10
vec.mutate()
}
Possibility: Allow immutable types to be declared:
Vec3 < immutable Value {
x Float
y Float
z Float
}
Perform escape analysis to determine if heap allocations can be converted into stack allocations. A pointer 'escapes' a function if it is returned or assigned to a structure that is returned or passed into a function.
Make sure tests pass on Windows and Linux. Add calling convention for Windows.
Some places should have declaration semantics rather than declaration-assignment semantics. For instance, let
expressions:
let a = "hello" {
...
}
The above should always define a new variable a
. This also arises with local functions:
test() {
...
}
This should always declare a new function variable.
These are not necessary for value types allocated on the stack. Boxed value types can be allocated such that they do use a refcount/vtable field when allocated on the heap; this is a special case.
Also, investigate allowing value types to be used for generics, but only if Boxed. That may be a possible compromise.
Reserve a global (or thread-local) variable to store a pointer to the current exception. Analyze to determine if a function can throw an exception:
can_throw = false
initially (true
if there is a throw statement)can_throw
for child functionscan_throw = false
can_throw = true | false | undef
If a function can_throw
, then generate an if
block after the call to check if current_exception
is non-null. If it is, then cleanup, and jump to the finally
or catch
if there is one; otherwise, return garbage to rax
and leave current_exception
set.
Justification for this plan (vs. a table-driven exception handling scheme like C++ has):
if
blocks (just 1 extra instruction)To start, do not support try/throw/catch. Just mark yield
as 'can_throw', and then perform can_throw
analysis and add error-checking if
blocks.
Basically, the same a Gem; needs to pull from a URL down and install in a shared directory (which one?)
Should include: Strings, basic IO. Enough so that folks can start using the language. This won't include collection classes because that requires generics.
For example:
ret a < b
Since short-circuiting is used to eval boolean expressions, the result of an expression that has type "bool" needs to do special processing to get the boolean value into a register. This would also cause a problem:
func(a < b)
Make sure private methods are not callable from outside the class.
This involves rewriting the compiler (lexer, parser, semantic analysis, code generation), in Apollo. The basic standard library will still be implemented in C (I don't see a portable way around this that won't be extremely painful to implement).
The subtype analysis is complicated with generics. There needs to be an 'environment', i.e., a mapping between type parameters and their values. Right now, sub-typing doesn't work for generic interfaces.
When two types are being compared, a mapping between type parameters and their bound values need to be kept for each type. Since the structural type analysis is recursive, a stack must be used.
subtype(a, b)
Collection literals, i.e.: x = { 1, 2, 3 ... }
RPM, PKG, DEB, Win32
Attributes are not getting released in the destructor, iterate over them and fix refcounts.
Implement value types (but not value type generics, yet).
Returned temporaries should have a refcount of 0 if just constructed. Temporaries also need to have refcount_inc called on them; right now, this doesn't happen for temporaries.
Finish the graph-based register allocator and liveness analyzer.
There are some problems here, not all cases are covered:
obj.func() # Normal dispatch
obj.func # Value of expression is a function value
obj.value # This is a call to an accessor, e.g., value?()
func() # Dispatch on local var
func() # Call free func
func() # Dispatch on self
Create a file format for Apollo libraries. Most likely, this will be a folder containing the interface file (.api file) and the library for linking. The interface file needs to have entries for all classes, function prototypes, etc. so they can be loaded into a parse tree. The code does not need to be serialized.
In fact, it may be most effective to output the prototype information in plain text, and just combine all the info into one .api file for the library. That way, the parser can still be used. The type checker doesn't need to be run on the body of functions that came from a .api file, so that should be ok.
To start, implement match statements as simple if-then-else chains.
I have flex @2.5.35_0, bison @2.5_0, and the latest source but i get the following error on scons build. :P
(I just followed your instructions but didn't try to fix it) what do i do next Zeus?
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
g++ -o build/compiler/BasicBlockGenerator.o -c -g -Wall -Werror -pedantic -Wno-unused -Wno-sign-compare -Ibuild/compiler -Icompiler compiler/BasicBlockGenerator.cpp
g++ -o build/compiler/BasicBlockPrinter.o -c -g -Wall -Werror -pedantic -Wno-unused -Wno-sign-compare -Ibuild/compiler -Icompiler compiler/BasicBlockPrinter.cpp
g++ -o build/compiler/Environment.o -c -g -Wall -Werror -pedantic -Wno-unused -Wno-sign-compare -Ibuild/compiler -Icompiler compiler/Environment.cpp
g++ -o build/compiler/Feature.o -c -g -Wall -Werror -pedantic -Wno-unused -Wno-sign-compare -Ibuild/compiler -Icompiler compiler/Feature.cpp
g++ -o build/compiler/File.o -c -g -Wall -Werror -pedantic -Wno-unused -Wno-sign-compare -Ibuild/compiler -Icompiler compiler/File.cpp
g++ -o build/compiler/Intel64CodeGenerator.o -c -g -Wall -Werror -pedantic -Wno-unused -Wno-sign-compare -Ibuild/compiler -Icompiler compiler/Intel64CodeGenerator.cpp
g++ -o build/compiler/LivenessAnalyzer.o -c -g -Wall -Werror -pedantic -Wno-unused -Wno-sign-compare -Ibuild/compiler -Icompiler compiler/LivenessAnalyzer.cpp
g++ -o build/compiler/Location.o -c -g -Wall -Werror -pedantic -Wno-unused -Wno-sign-compare -Ibuild/compiler -Icompiler compiler/Location.cpp
g++ -o build/compiler/Options.o -c -g -Wall -Werror -pedantic -Wno-unused -Wno-sign-compare -Ibuild/compiler -Icompiler compiler/Options.cpp
g++ -o build/compiler/Parser.o -c -g -Wall -Werror -pedantic -Wno-unused -Wno-sign-compare -Ibuild/compiler -Icompiler compiler/Parser.cpp
g++ -o build/compiler/RegisterAllocator.o -c -g -Wall -Werror -pedantic -Wno-unused -Wno-sign-compare -Ibuild/compiler -Icompiler compiler/RegisterAllocator.cpp
g++ -o build/compiler/TreePrinter.o -c -g -Wall -Werror -pedantic -Wno-unused -Wno-sign-compare -Ibuild/compiler -Icompiler compiler/TreePrinter.cpp
g++ -o build/compiler/Type.o -c -g -Wall -Werror -pedantic -Wno-unused -Wno-sign-compare -Ibuild/compiler -Icompiler compiler/Type.cpp
g++ -o build/compiler/TypeChecker.o -c -g -Wall -Werror -pedantic -Wno-unused -Wno-sign-compare -Ibuild/compiler -Icompiler compiler/TypeChecker.cpp
bison --defines=build/compiler/Grammar.hpp --report=all -o build/compiler/Grammar.cc compiler/Grammar.yy
compiler/Grammar.yy:53.63-74: syntax error, unexpected type, expecting string or identifier
scons: *** [build/compiler/Grammar.cc] Error 1
scons: building terminated because of errors.
Basic idea:
JsonOutput < Functor {
@dispatch(obj Starship)
@dispatch(obj Asteroid)
}
Render < Functor {
@dispatch(obj Mesh)
@dispatch(obj Particles)
@dispatch(obj Quads)
@dispatch(obj Material)
@dispatch(obj Light)
}
Add enums, which are basically implemented as a set of integers inside a class scope. For example:
CarState < Enum {
ON
BROKEN
OFF
}
Another alternative syntax is:
CarState = ON | BROKEN | OFF
Similarly, union types have a similar syntax:
JsonValue = String | Int | Float
Or:
JsonValue < Union {
String
Int
Float
}
Haven't decided what to do with this yet. Probably something better than Java's templates, more along the lines of Haskell. The final version will try to avoid annoying type decls, possibly by using a special symbol to mean a generic var.
map(list List[:a], op Function[:a, :b]) :b {
out = List[:b]
for out in list {
ret.append(op(out))
}
ret out
}
This includes Algo, Struct, and Prelude.
Implement mixins, for interfaces and regular types. Mixins will basically just "paste" the mixin code into the body of the class. Debatable: Should mixins inherit from "Mixin?" I think yes, to make the compiler simpler and to distinguish between usable objects and Mixins, which are not standalone.
Conflict rules: victory goes to the method defined in the Object, or to the Mixin listed first in the mixin list.
Self: self-types should be usable in Mixins, and they should be bound to the type of the Object they are mixed into.
Implementation: just copy, or perform some kind of lookup? Should multiple functions be generated, or should the vtable forward to the mixin implementation? (need to worry about instance variables -- should they even be allowed in Mixins?)
Ruby-style regular expression literals, e.g.: /abc+/
Bison and Flex...causing trouble in Windows since '99
Two options for resolving this:
Basically, this includes libraries that are essential for many tasks, but not core. Most likely this will include:
Eventually there will also be 3D graphics bindings for OpenGL, and a game engine library :) but those are definitely not core.
The --make option should build all dependencies, starting with the input files.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.