nit.git
14 years agotests: massive update of tests files
Jean Privat [Mon, 6 Jul 2009 18:24:57 +0000 (14:24 -0400)]
tests: massive update of tests files

Remove some obsolete tests.
Fix broken tests.
Add missing *.sav files
Add mal *.fail files.

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agotests: tests.sh counts errors
Jean Privat [Mon, 6 Jul 2009 17:29:48 +0000 (13:29 -0400)]
tests: tests.sh counts errors

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agotests: tests.sh compares results with expected buggy results
Jean Privat [Mon, 6 Jul 2009 17:29:26 +0000 (13:29 -0400)]
tests: tests.sh compares results with expected buggy results

New sav/*.fail files stores buggy results in order to track unfixed bugs
or planned regressions.

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agotests: add verbose option to tests.sh
Jean Privat [Mon, 6 Jul 2009 17:05:07 +0000 (13:05 -0400)]
tests: add verbose option to tests.sh

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agotests: add option handling to tests.sh
Jean Privat [Mon, 6 Jul 2009 16:59:21 +0000 (12:59 -0400)]
tests: add option handling to tests.sh

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agotests: add test_exec_ls
Jean Privat [Sat, 4 Jul 2009 13:39:13 +0000 (09:39 -0400)]
tests: add test_exec_ls

Since example_exec_ls was unverifiable.

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agotests: update base_primitive_null
Jean Privat [Sat, 4 Jul 2009 13:38:14 +0000 (09:38 -0400)]
tests: update base_primitive_null

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agotests: new base_int and base_int2
Jean Privat [Thu, 2 Jul 2009 14:26:04 +0000 (10:26 -0400)]
tests: new base_int and base_int2

Test basic integer operations.

Old base_int is trashed.

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agotests: base_closure11 complex stacked and nested closure
Jean Privat [Sat, 4 Jul 2009 02:54:45 +0000 (22:54 -0400)]
tests: base_closure11 complex stacked and nested closure

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agosyntax: bug to fix: specialize broken type
Jean Privat [Sat, 4 Jul 2009 02:52:02 +0000 (22:52 -0400)]
syntax: bug to fix: specialize broken type

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agosyntax: do not process erroneous formal types
Jean Privat [Sat, 4 Jul 2009 02:51:08 +0000 (22:51 -0400)]
syntax: do not process erroneous formal types

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agosyntax: do not processes erroneous signatures
Jean Privat [Sat, 4 Jul 2009 02:44:29 +0000 (22:44 -0400)]
syntax: do not processes erroneous signatures

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agosyntax: better error message for generic class arity error
Jean Privat [Sat, 4 Jul 2009 02:42:31 +0000 (22:42 -0400)]
syntax: better error message for generic class arity error

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agotests: add base_gen2.nit
Jean Privat [Sat, 4 Jul 2009 02:29:46 +0000 (22:29 -0400)]
tests: add base_gen2.nit

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agosyntax: add PType::is_typed
Jean Privat [Sat, 4 Jul 2009 02:19:31 +0000 (22:19 -0400)]
syntax: add PType::is_typed

Add tests to ensure that type errors do not crash the compiler.

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agosyntax: add some missing PExpr::is_typed.
Jean Privat [Fri, 3 Jul 2009 21:38:57 +0000 (17:38 -0400)]
syntax: add some missing PExpr::is_typed.

Add a quite complete test to ensure that expression errors do not crash
the compiler.

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agosyntax: move varctx initialization to the PClassdef
Jean Privat [Fri, 3 Jul 2009 21:34:11 +0000 (17:34 -0400)]
syntax: move varctx initialization to the PClassdef

variable 'self' can now be accessed (even implicitly) in default
attribute definition.

A test base_attr_init_val3 is added.

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agotests: add test for filter_stream
Jean-Sebastien Gelinas [Tue, 30 Jun 2009 13:27:48 +0000 (09:27 -0400)]
tests: add test for filter_stream

Signed-off-by: Jean-Sebastien Gelinas <calestar@gmail.com>
Signed-off-by: Jean Privat <jean@pryen.org>

14 years agolib: add 'close' in filter_stream
Jean-Sebastien Gelinas [Sat, 27 Jun 2009 01:35:09 +0000 (21:35 -0400)]
lib: add 'close' in filter_stream

Signed-off-by: Jean-Sebastien Gelinas <calestar@gmail.com>
Signed-off-by: Jean Privat <jean@pryen.org>

14 years agolib: fix nullable in filter_stream
Jean-Sebastien Gelinas [Sat, 27 Jun 2009 01:35:09 +0000 (21:35 -0400)]
lib: fix nullable in filter_stream

Signed-off-by: Jean-Sebastien Gelinas <calestar@gmail.com>
Signed-off-by: Jean Privat <jean@pryen.org>

14 years agolib: fix a bug with String::has_substring and related methods
Jean-Sebastien Gelinas [Tue, 16 Jun 2009 17:46:31 +0000 (13:46 -0400)]
lib: fix a bug with String::has_substring and related methods

Signed-off-by: Jean-Sebastien Gelinas <calestar@gmail.com>
Signed-off-by: Jean Privat <jean@pryen.org>

14 years agotools: more verbose information
Jean-Sebastien Gelinas [Tue, 23 Jun 2009 18:21:46 +0000 (14:21 -0400)]
tools: more verbose information

Signed-off-by: Jean-Sebastien Gelinas <calestar@gmail.com>
Signed-off-by: Jean Privat <jean@pryen.org>

14 years agotools: add 'verbose' options
Jean-Sebastien Gelinas [Wed, 24 Jun 2009 06:04:57 +0000 (02:04 -0400)]
tools: add 'verbose' options

Signed-off-by: Jean-Sebastien Gelinas <calestar@gmail.com>
Signed-off-by: Jean Privat <jean@pryen.org>

14 years agomisc: add vim syntax and indent files
Jean Privat [Fri, 26 Jun 2009 17:26:46 +0000 (13:26 -0400)]
misc: add vim syntax and indent files

14 years agosyntax: 'meth' -> 'fun', 'attr' -> 'var'
Jean Privat [Fri, 26 Jun 2009 14:40:54 +0000 (10:40 -0400)]
syntax: 'meth' -> 'fun', 'attr' -> 'var'

Tests results are updated to reflect the column change in error messages.

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agotools: generate version number and give it to tools
Jean Privat [Fri, 26 Jun 2009 04:55:52 +0000 (00:55 -0400)]
tools: generate version number and give it to tools

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agotools: programs know their names
Jean Privat [Fri, 26 Jun 2009 04:53:21 +0000 (00:53 -0400)]
tools: programs know their names

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agonullable: enforce static and dynamic rules.
Jean Privat [Thu, 25 Jun 2009 20:29:26 +0000 (16:29 -0400)]
nullable: enforce static and dynamic rules.

Switch warnings to errors.
Update tests to let them not produce errors. Note that:
 * base_nullable.nit have new error cases
 * test_isa.nit add some test cases
 * test_nil.nit is removed since it is to much outdated.

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agonullable: convert lib, tools and tests
Jean Privat [Thu, 25 Jun 2009 02:27:08 +0000 (22:27 -0400)]
nullable: convert lib, tools and tests

Add nullable, as(not null) and cie to libs, nitc, nitdoc and tests such
that they compile and run without nullable-related warnings.

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agoc_src: regenerate with soft nullable handling
Jean Privat [Thu, 25 Jun 2009 21:24:17 +0000 (17:24 -0400)]
c_src: regenerate with soft nullable handling

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agometamodel: fix MMType::is_valid for indirect types
Jean Privat [Thu, 25 Jun 2009 21:15:39 +0000 (17:15 -0400)]
metamodel: fix MMType::is_valid for indirect types

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agocompile: no default value for notnull primitive attributes.
Jean Privat [Wed, 24 Jun 2009 19:16:33 +0000 (15:16 -0400)]
compile: no default value for notnull primitive attributes.

However, instead of segfaulting, using an uninitialized attribute may
behave like if it was initialized to 0 (whatever it means).

Therefore the new test base_attr_nullable_int.nit makes more sense with -W to
activate non-lethal runtime warnings.

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agonullable: type, compile and test 'isset _attr'
Jean Privat [Wed, 24 Jun 2009 18:44:24 +0000 (14:44 -0400)]
nullable: type, compile and test 'isset _attr'

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agocompile: implicit isset for attribute read access
Jean Privat [Wed, 24 Jun 2009 08:57:45 +0000 (04:57 -0400)]
compile: implicit isset for attribute read access

Activated only if the program was compiled using -W and only display a
warning at run-time.
Therefore the new test base_attr_nullable.nit makes more sense with -W.

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agocompile: differentiate attribute read and write
Jean Privat [Wed, 24 Jun 2009 07:22:48 +0000 (03:22 -0400)]
compile: differentiate attribute read and write

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agosyntax: no isa/as warning for double nullable formal type
Jean Privat [Tue, 23 Jun 2009 21:22:11 +0000 (17:22 -0400)]
syntax: no isa/as warning for double nullable formal type

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agocompile: Check correct object construction
Jean Privat [Tue, 16 Jun 2009 13:45:23 +0000 (09:45 -0400)]
compile: Check correct object construction

Check that non nullable attributes are set at the end of the 'new'.
Activated only if the program was compiled using -W and only display a
warning at run-time.

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agosyntax: extends 'as' and 'isa' warning to nullable
Jean Privat [Thu, 18 Jun 2009 20:45:03 +0000 (16:45 -0400)]
syntax: extends 'as' and 'isa' warning to nullable

Example
  var x: nullable T
  var y = x.as(T) # Bad form
  var y = x.as(not null) # Good form
  if x isa T then ... # Bad form
  if x != null then ... # Good form

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agocompile: casts ('isa' and 'as') with nullable info
Jean Privat [Mon, 15 Jun 2009 20:54:57 +0000 (16:54 -0400)]
compile: casts ('isa' and 'as') with nullable info

Migration remark: considers that non-null objects can still contains null at runtime.

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agotests: base_nullable.nit and base_eq_null_notnull.nit
Jean Privat [Wed, 24 Jun 2009 19:54:22 +0000 (15:54 -0400)]
tests: base_nullable.nit and base_eq_null_notnull.nit

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agosyntax: "!= null" works like a "isa"
Jean Privat [Tue, 23 Jun 2009 17:48:46 +0000 (13:48 -0400)]
syntax: "!= null" works like a "isa"

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agotyping: warn when comparing null and not nullable
Jean Privat [Sat, 13 Jun 2009 04:42:08 +0000 (00:42 -0400)]
typing: warn when comparing null and not nullable

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agotests: nullable and array
Jean Privat [Mon, 15 Jun 2009 09:13:23 +0000 (05:13 -0400)]
tests: nullable and array

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agotyping: 'for' iterates on Collection[nullable Object]
Jean Privat [Fri, 12 Jun 2009 20:45:40 +0000 (16:45 -0400)]
typing: 'for' iterates on Collection[nullable Object]

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agonullable: type, compile and test 'as(not null)'
Jean Privat [Fri, 12 Jun 2009 14:59:28 +0000 (10:59 -0400)]
nullable: type, compile and test 'as(not null)'

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agosyntax: Update check_conform_multiexpr with nullables
Jean Privat [Fri, 12 Jun 2009 02:41:48 +0000 (22:41 -0400)]
syntax: Update check_conform_multiexpr with nullables

Add also some tests.

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agometamodel: add nullable static types
Jean Privat [Tue, 23 Jun 2009 17:54:47 +0000 (13:54 -0400)]
metamodel: add nullable static types

Syntax error on nullable type only display a warning

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agoparser: add nullables
Jean Privat [Wed, 10 Jun 2009 20:21:18 +0000 (16:21 -0400)]
parser: add nullables

add 'nullable' and 'isset' keywords.
add '.as(not null)' expression

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agotools: two -W promote warnings to errors
Jean Privat [Tue, 23 Jun 2009 19:13:44 +0000 (15:13 -0400)]
tools: two -W promote warnings to errors

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agolib/opt: add OptionCount
Jean Privat [Tue, 23 Jun 2009 19:11:50 +0000 (15:11 -0400)]
lib/opt: add OptionCount

An option count works like a OptionBool except it counts the number of
occurrences of the flag.

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agosrc: add nc0 and nc1 to test bootstrap from c_src
Jean Privat [Tue, 23 Jun 2009 14:39:52 +0000 (10:39 -0400)]
src: add nc0 and nc1 to test bootstrap from c_src

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agocompile: stop writing location of each node
Jean Privat [Tue, 23 Jun 2009 04:20:11 +0000 (00:20 -0400)]
compile: stop writing location of each node

So much runtime consuming.
Can always be reactivated in case of emergency.

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agocompile: clean compiling_global.nit
Jean Privat [Tue, 23 Jun 2009 04:10:02 +0000 (00:10 -0400)]
compile: clean compiling_global.nit

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agocompile: new class GlobalCompilerVisitor
Jean Privat [Tue, 23 Jun 2009 03:35:45 +0000 (23:35 -0400)]
compile: new class GlobalCompilerVisitor

Specialize CompilerVisitor to add global analysis information instead
of refininig it.

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agosyntax: fix OR if_false_var_ctx passing.
Jean Privat [Mon, 22 Jun 2009 20:05:00 +0000 (16:05 -0400)]
syntax: fix OR if_false_var_ctx passing.

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agosyntax: local variable assignment always cast
Jean Privat [Mon, 22 Jun 2009 18:53:02 +0000 (14:53 -0400)]
syntax: local variable assignment always cast

example:
  var a: A
  a = new B
  a.only_B_stuff # OK since the casted type of a is now B

Signed-off-by: Jean Privat <jean@pryen.org>

14 years agosyntax: while condition can now cast variable
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>

14 years agosyntax: variable assignment can bypass cast
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>

14 years agosyntax: if_false_variable_ctx
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>

14 years agosyntax: add VariableContext::to_s
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>

14 years agosyntax: var assignment can bypass casted type
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>

14 years agosyntax: do_lvalue_typing do not do the final type check
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>

14 years agosyntax: better internal VariableContex stype handling
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>

14 years agosyntax: Move VariableContext and related to a new control_flow.nit
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>

14 years agosyntax: merge control_flow.nit in typing.nit
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>

14 years agotests: update base_closure6.nit
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>

14 years agosyntax: variable with () is not a variable
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>

14 years agosyntax: clean class VariableContext
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>

14 years agotests: add base_var_assignment_flow.nit
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>

14 years agometamodel: promote _filename to MMModule
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>

14 years agosyntax: warning for useless 'isa' and 'as' type checks
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>

14 years agometamodel: new MMType::is_valid method
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>

14 years agosyntax: update PExpr class to use _is_typed and cie.
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>

14 years agosyntax: add PExpr:is_typed and PExpr::is_statement
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>

14 years agotests: new base_var.nit
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>

14 years agosyntax: refactor AClosureCallExpr
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>

14 years agosyntax: new class AAbsAbsSendExpr
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>

14 years agoparser: inits uses Collection instead of Array
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>

14 years agotests: bug to fix base_virtual_type_self.nit
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>

14 years agometamodel: MMLocalClass::init takes the MMModule
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>

14 years agocompile: clean class PrimitiveInfo
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>

14 years agocompile: clean CompilerVisitor constructor
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>

14 years agocompile: distinguish compile_expr_call and compile_stmt_call
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>

14 years agocompile: new method compile_arguments_in
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>

14 years agocompile: compile_stmt is a noop on null PExpr
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>

14 years agosyntax: new method use_if_true_variable_ctx
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>

14 years agosyntax: Split SubVariableContext and CastVariableContext
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>

14 years agotests: add base_as_cast
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>

14 years agosyntax: new method check_conform_multiexpr
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>

14 years agometamodel: PartialOrder::[] fail on wrong key
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>

14 years agolib: Map:[] aborts if key is not found
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>

14 years agometamodel: Check global_class existence instead of getting null
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>

14 years agometamodel: MMLocalClass::[] aborts if no global class
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>

14 years agometamodel: new MMLocalClass::has_global_property
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>

14 years agometamodel: fast-fail in getters
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>

14 years agolib: remove some explicit Object bounds
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>

14 years agometamodel: fix and comment upcast_for
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>

14 years agorefactor: use Hash::has_key instead of getting null
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>

14 years agocompile: New function is_valid_variable v0.2.1
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>

14 years agocompile: Superstring compilation bug
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>