Jean Privat [Mon, 22 Jun 2009 18:19:12 +0000 (14:19 -0400)]
syntax: while condition can now cast variable
Example:
var a = foo # foo gives a A
# Before the while, the base static type of a is set to A
while a isa B do
a.some_b_stuff # OK, since a isa B
a = foo # OK, since 'base' static type of a is A
end
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Mon, 22 Jun 2009 18:07:07 +0000 (14:07 -0400)]
syntax: variable assignment can bypass cast
Bypassing is allowed if it is conform to the 'base' type of the variable.
The 'base' type of the variable is set before while, for and closures.
Bypassing also means that casted type must propagate trough flow control.
Some tests are updated to avoid unexpected cast flow.
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Mon, 22 Jun 2009 16:07:50 +0000 (12:07 -0400)]
syntax: if_false_variable_ctx
Allow casts to be propagated in 'else' branches
Example:
if not a isa B then
a.only_b_can_do # Static error
else
a.only_b_can_do # OK since current static type of a is B here
end
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Mon, 22 Jun 2009 15:50:55 +0000 (11:50 -0400)]
syntax: add VariableContext::to_s
Used to debug.
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Fri, 19 Jun 2009 15:56:45 +0000 (11:56 -0400)]
syntax: var assignment can bypass casted type
If rvalue is conform with casted type then
variable remains casted
else if rvalue is conform with base type then
# It is the novelty
variable is (up)casted to its base type
else error
Example:
var x: T
x.u_only_method # error
assert x isa U
x.u_only_method # ok
x = a_t # ok
x.u_only_method # error
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Fri, 19 Jun 2009 14:24:00 +0000 (10:24 -0400)]
syntax: do_lvalue_typing do not do the final type check
Clients can now deals with the fact that in
x += 1
that is equivalent to
x_new = x_old + 1
the static type of x_old is different from the one accepted by x_new.
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Fri, 19 Jun 2009 14:05:33 +0000 (10:05 -0400)]
syntax: better internal VariableContex stype handling
Remove the sublcass CastVariableContex.
Add the method VariableContext::stype=
Current client does not need to be updated.
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Fri, 19 Jun 2009 06:03:54 +0000 (02:03 -0400)]
syntax: Move VariableContext and related to a new control_flow.nit
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Fri, 19 Jun 2009 05:58:04 +0000 (01:58 -0400)]
syntax: merge control_flow.nit in typing.nit
VariableContext is used instead of ControlFlowContext.
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Fri, 19 Jun 2009 05:48:22 +0000 (01:48 -0400)]
tests: update base_closure6.nit
Prevent potential error pollution by using uninitialized variables.
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Fri, 19 Jun 2009 05:32:00 +0000 (01:32 -0400)]
syntax: variable with () is not a variable
So do not try to continue and pretend things.
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Fri, 19 Jun 2009 05:29:10 +0000 (01:29 -0400)]
syntax: clean class VariableContext
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Fri, 19 Jun 2009 05:07:17 +0000 (01:07 -0400)]
tests: add base_var_assignment_flow.nit
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 18 Jun 2009 21:11:18 +0000 (17:11 -0400)]
metamodel: promote _filename to MMModule
Update inits and MMSrcModule.
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 18 Jun 2009 20:41:24 +0000 (16:41 -0400)]
syntax: warning for useless 'isa' and 'as' type checks
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 18 Jun 2009 20:39:16 +0000 (16:39 -0400)]
metamodel: new MMType::is_valid method
is_valid is used to discriminate fully build MMType from others.
Currently, only MMTypeFormal require it.
Previous behavior of returning null on invalid MMTypeFormal's methods is disabled.
syntax_base.nit is adapted to the new behavior.
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 18 Jun 2009 01:48:50 +0000 (21:48 -0400)]
syntax: update PExpr class to use _is_typed and cie.
PExpr::stype contracts are also enabled.
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 17 Jun 2009 20:38:07 +0000 (16:38 -0400)]
syntax: add PExpr:is_typed and PExpr::is_statement
Contracts are not enforced yet.
Update check_expr to profit from them.
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 18 Jun 2009 01:47:42 +0000 (21:47 -0400)]
tests: new base_var.nit
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Tue, 16 Jun 2009 20:33:54 +0000 (16:33 -0400)]
syntax: refactor AClosureCallExpr
Add a alternative in the grammar to profit from generated walkers.
Makes AClosureCallExpr a subclass of AAbsAbsSendExpr instead of ACallFormExpr.
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Tue, 16 Jun 2009 20:32:19 +0000 (16:32 -0400)]
syntax: new class AAbsAbsSendExpr
Like AAbsSendExpr but without property.
AAbsSendExpr is a subclass of AAbsAbsSendExpr.
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Tue, 16 Jun 2009 20:24:42 +0000 (16:24 -0400)]
parser: inits uses Collection instead of Array
This helps to generate them manually.
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Mon, 15 Jun 2009 21:08:09 +0000 (17:08 -0400)]
tests: bug to fix base_virtual_type_self.nit
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Mon, 15 Jun 2009 18:36:23 +0000 (14:36 -0400)]
metamodel: MMLocalClass::init takes the MMModule
Also remove the MMModule::add_local_class method
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Sat, 13 Jun 2009 03:42:47 +0000 (23:42 -0400)]
compile: clean class PrimitiveInfo
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Sat, 13 Jun 2009 03:42:15 +0000 (23:42 -0400)]
compile: clean CompilerVisitor constructor
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Fri, 12 Jun 2009 21:32:56 +0000 (17:32 -0400)]
compile: distinguish compile_expr_call and compile_stmt_call
This helps to clean the mess in compiling_methods.nit.
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Fri, 12 Jun 2009 20:20:08 +0000 (16:20 -0400)]
compile: new method compile_arguments_in
Factorize compilation of arguments.
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Fri, 12 Jun 2009 19:46:51 +0000 (15:46 -0400)]
compile: compile_stmt is a noop on null PExpr
This simplify the code.
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Fri, 12 Jun 2009 18:54:57 +0000 (14:54 -0400)]
syntax: new method use_if_true_variable_ctx
This simplify the use of the _if_true_variable_ctx attribute of expressions.
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Fri, 12 Jun 2009 18:43:09 +0000 (14:43 -0400)]
syntax: Split SubVariableContext and CastVariableContext
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Fri, 12 Jun 2009 14:46:23 +0000 (10:46 -0400)]
tests: add base_as_cast
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Fri, 12 Jun 2009 01:58:40 +0000 (21:58 -0400)]
syntax: new method check_conform_multiexpr
This method is used to check conformance among multiple expressions.
It is used to factorize code between AIfexprExpr, AArrayExpr and process_closure.
Tests are also updated to use the new error messages.
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 11 Jun 2009 16:44:17 +0000 (12:44 -0400)]
metamodel: PartialOrder::[] fail on wrong key
Alike stdlib Map::[] method, PartialOrder::[] aborts if key does not exists.
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 11 Jun 2009 19:03:47 +0000 (15:03 -0400)]
lib: Map:[] aborts if key is not found
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 11 Jun 2009 19:02:49 +0000 (15:02 -0400)]
metamodel: Check global_class existence instead of getting null
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 11 Jun 2009 18:58:33 +0000 (14:58 -0400)]
metamodel: MMLocalClass::[] aborts if no global class
Previous behavior was to return null.
Adapts existing clients by using the new MMLocalClass::has_global_property.
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 11 Jun 2009 18:54:53 +0000 (14:54 -0400)]
metamodel: new MMLocalClass::has_global_property
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 11 Jun 2009 15:45:43 +0000 (11:45 -0400)]
metamodel: fast-fail in getters
Instead of testing and returning null among getters, just do stuff and
abort if called methods abort.
syntax modules are adapted to use preventive methods (has_*).
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 11 Jun 2009 15:42:15 +0000 (11:42 -0400)]
lib: remove some explicit Object bounds
The default bound for generic formal parameter is already 'Object'.
And soon the default bound will be 'nullable Object'.
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 11 Jun 2009 13:26:26 +0000 (09:26 -0400)]
metamodel: fix and comment upcast_for
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 11 Jun 2009 12:34:42 +0000 (08:34 -0400)]
refactor: use Hash::has_key instead of getting null
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Tue, 9 Jun 2009 16:10:47 +0000 (12:10 -0400)]
compile: New function is_valid_variable
Used to improve ensure_var and compile_expr.
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Tue, 9 Jun 2009 19:23:17 +0000 (15:23 -0400)]
compile: Superstring compilation bug
Before:
var a = 5
var b = "{a}"
print(a == b) # => true, a was overwrite
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Tue, 9 Jun 2009 15:23:12 +0000 (11:23 -0400)]
compile: Store cvariable indexes instead of names
Variable names (strings) are stored in a 'once' dictionnary to avoid useless duplication.
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Tue, 9 Jun 2009 14:36:41 +0000 (10:36 -0400)]
compile: ccomments for get_var and ensure_var
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Tue, 9 Jun 2009 19:42:35 +0000 (15:42 -0400)]
compile: No systematic cvar for compile_constructor_call
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Tue, 9 Jun 2009 19:41:55 +0000 (15:41 -0400)]
Spelling: bloc -> block
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Tue, 9 Jun 2009 19:41:30 +0000 (15:41 -0400)]
syntax: New escape block management
New module syntax/escape.nit to handle escape context and structures.
Use it in syntax/typing.nit (thus removing many visitor attributes).
Remove duplicate break and continue errors from syntax/control_flow.nit now in escape.nit.
Remove useless ABlockControler & cie. from syntax/control_flow.nit.
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Tue, 9 Jun 2009 19:40:48 +0000 (15:40 -0400)]
compile: Simplify closure C structures
Use a common structure WBT_ and specific function types FWBT_*.
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 3 Jun 2009 17:22:24 +0000 (13:22 -0400)]
compile: C comments for each compiled stmt/expr
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 3 Jun 2009 13:47:35 +0000 (09:47 -0400)]
compile: Fix inlined return in closure
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 10 Jun 2009 14:00:28 +0000 (10:00 -0400)]
compile: Fix closure break marker resetting
Set the break marker each time the block is called, not at the top of the function.
Side-effect: this fix also remove a gcc warning.
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Tue, 7 Apr 2009 02:31:35 +0000 (22:31 -0400)]
compile: Extract closure code from ASendExpr::compile_expr
The new function is MMMethod::compile_call_and_closures.
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 10 Jun 2009 13:54:50 +0000 (09:54 -0400)]
tests: tests.sh returns 1 if some tests fails
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 3 Jun 2009 16:31:50 +0000 (12:31 -0400)]
tests: Add errlist
Failed tests names are stored in a errlist.
The errlist can then be used to feed next tests.
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 3 Jun 2009 15:32:01 +0000 (11:32 -0400)]
tests: remove broken HTML output
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 3 Jun 2009 16:37:22 +0000 (12:37 -0400)]
parser: Do not crash if last_loken is unset
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 20 May 2009 19:27:52 +0000 (15:27 -0400)]
parser: Add 'fun' and 'var'-as-attr keyword
New keywords are equivalent with the old 'meth' ant 'attr'.
The existing source Nit code is not adapted yet and keeps 'meth' and 'attr'.
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 20 May 2009 19:09:33 +0000 (15:09 -0400)]
parser: Remove ~nobra on type production
Why was it here?
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 20 May 2009 18:54:39 +0000 (14:54 -0400)]
parser: Remove tl_propdef* parser rules
Instead use parametrized propdef rules with ~toplevel
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Mon, 6 Apr 2009 22:20:59 +0000 (18:20 -0400)]
ast: Merge classes AForExpr and AForVardeclExpr
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 3 Jun 2009 16:55:34 +0000 (12:55 -0400)]
parser: Script for extended sablecc3 syntax
Move hacks from the Makefile to a new shell script (prescc.sh).
Propose a cleaner syntax with ~ and ! characters.
See doc in prescc.sh for details.
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Tue, 24 Mar 2009 14:23:04 +0000 (10:23 -0400)]
syntax: Do not inherit signatures with closures
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Tue, 24 Mar 2009 14:06:18 +0000 (10:06 -0400)]
syntax: Systematic signature conformance checks
These tests will catch errors that are not yet specifically handeled by working on the syntax tree.
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 26 Feb 2009 20:54:26 +0000 (15:54 -0500)]
compile: Implicit 'once' for literal strings
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 10 Jun 2009 13:29:20 +0000 (09:29 -0400)]
lib: Split collections into readable and writable
Map ->
MapRead (r)
Map (rw)
IndexedCollection ->
IndexedCollectionRead (r)
IndexedCollection (rw)
AbstractArray ->
AbstractArrayRead (r)
AbstractArray (rw)
String ->
String (ro)
Buffer (rw)
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 10 Jun 2009 13:04:55 +0000 (09:04 -0400)]
new c_src
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 26 Feb 2009 15:10:11 +0000 (10:10 -0500)]
Compile superstrings with an array.to_s
Jean Privat [Thu, 26 Feb 2009 11:31:52 +0000 (06:31 -0500)]
Move primitive method selection.
Move primitive method selection from compiling_methods to typing.
Jean Privat [Thu, 26 Feb 2009 10:21:10 +0000 (05:21 -0500)]
Remove unused macro symbols.
Jean Privat [Fri, 13 Feb 2009 20:01:44 +0000 (15:01 -0500)]
Some renaming and commenting for TableElts.
Jean Privat [Fri, 13 Feb 2009 19:13:07 +0000 (14:13 -0500)]
Group attributes and methods by local class in the module tables.
Jean Privat [Fri, 13 Feb 2009 18:01:48 +0000 (13:01 -0500)]
Remove now useless variables and attributes in compile_global
Jean Privat [Fri, 13 Feb 2009 16:57:28 +0000 (11:57 -0500)]
New method compile_macros in TableElts.
This simplify the way some C macros are generated.
Jean Privat [Fri, 13 Feb 2009 16:48:05 +0000 (11:48 -0500)]
Remove -attr-sim option (was broken) and related classes.
Jean Privat [Thu, 12 Feb 2009 02:02:58 +0000 (21:02 -0500)]
Do not use CALL macro directly.
Instead generate specific call macro for methods and use them.
Jean Privat [Fri, 6 Feb 2009 16:00:12 +0000 (11:00 -0500)]
Fix a Makefile dependence for rebootstrap
Allow a safe new bootstrap from a old Nit bootstrap.
Jean Privat [Fri, 6 Feb 2009 15:48:46 +0000 (10:48 -0500)]
Update gitignore
Jean Privat [Fri, 6 Feb 2009 15:45:26 +0000 (10:45 -0500)]
Update c_src to handle default closures.
Jean Privat [Fri, 6 Feb 2009 15:26:27 +0000 (10:26 -0500)]
Finish syntax analysis for default closure.
Jean Privat [Fri, 6 Feb 2009 15:24:30 +0000 (10:24 -0500)]
Distinguish no bloc vs. empty bloc
On empty bloc, a empty ABlocExpr is given instead of null.
Jean Privat [Fri, 6 Feb 2009 15:11:20 +0000 (10:11 -0500)]
New test suite for default blocs.
Jean Privat [Fri, 6 Feb 2009 14:42:38 +0000 (09:42 -0500)]
Generalize base_block in control_flow.
Jean Privat [Fri, 6 Feb 2009 14:39:37 +0000 (09:39 -0500)]
Generalize compilation of parameters.
Add a compile_parameters in PSignature that do the stuff.
Jean Privat [Fri, 30 Jan 2009 09:15:00 +0000 (04:15 -0500)]
Basic typing and compilation for default closures.
Jean Privat [Fri, 30 Jan 2009 08:36:38 +0000 (03:36 -0500)]
Enable default closure in syntax
Jean Privat [Wed, 28 Jan 2009 02:27:10 +0000 (21:27 -0500)]
Remove useless _abstract atribute
Jean Privat [Tue, 27 Jan 2009 19:51:55 +0000 (14:51 -0500)]
Update c_src.
Jean Privat [Tue, 27 Jan 2009 19:41:42 +0000 (14:41 -0500)]
Two new tests related to the BUGS file. No sav yet.
Jean Privat [Tue, 27 Jan 2009 19:37:05 +0000 (14:37 -0500)]
Fill BUGS file.
Jean Privat [Sat, 24 Jan 2009 04:50:43 +0000 (23:50 -0500)]
Finalizer for closures.
Closure calls can accept a closure defintion performed if the closure breaks or returns.
Jean Privat [Sat, 24 Jan 2009 01:58:24 +0000 (20:58 -0500)]
New function process_closures.
Extract closure processing from ASendExpr into a new function in AAbsSendExpr.
Add process_closures in do_typing.
Update tests since error message has changed.
Jean Privat [Sat, 24 Jan 2009 01:55:06 +0000 (20:55 -0500)]
Fix MMSignature::not_for_self
3 bugs:
* return value not correctly set
* closure badly managed
* vararg forgoten is any
Jean Privat [Thu, 22 Jan 2009 20:59:26 +0000 (15:59 -0500)]
Add break closure.
Break closure must break. They are great for error management.
Jean Privat [Thu, 22 Jan 2009 19:35:12 +0000 (14:35 -0500)]
New class MMClosure
Closure in signature are not only signature.
This commit prepare to add more metainfo like 'break' closure or optionality.
Jean Privat [Thu, 22 Jan 2009 14:46:24 +0000 (09:46 -0500)]
Update results for closure tests
Jean Privat [Thu, 22 Jan 2009 14:43:38 +0000 (09:43 -0500)]
Compile closure.
Jean Privat [Wed, 21 Jan 2009 16:00:36 +0000 (11:00 -0500)]
New test suite for closures
Jean Privat [Wed, 21 Jan 2009 15:28:31 +0000 (10:28 -0500)]
Type and check 'break' return values.
A small inference is done in case of multiple breaks.