changed the compiler to allow assignment to an argument in a method
This commit is contained in:
parent
7460ce819c
commit
2528dcdbe5
@ -123,11 +123,22 @@ class(#byte) ByteArray(Collection)
|
|||||||
class Set(Collection)
|
class Set(Collection)
|
||||||
{
|
{
|
||||||
dcl tally bucket.
|
dcl tally bucket.
|
||||||
|
|
||||||
|
method new: size
|
||||||
|
{
|
||||||
|
^self new initialize: size.
|
||||||
|
}
|
||||||
|
|
||||||
method initialize
|
method initialize
|
||||||
{
|
{
|
||||||
|
^self initialize: 128. (* TODO: default initial size *)
|
||||||
|
}
|
||||||
|
|
||||||
|
method initialize: size
|
||||||
|
{
|
||||||
|
(size <= 0) ifTrue: [size := 2].
|
||||||
self.tally := 0.
|
self.tally := 0.
|
||||||
self.bucket := Array new: 128. (* TODO: initial size *)
|
self.bucket := Array new: size.
|
||||||
}
|
}
|
||||||
|
|
||||||
method size
|
method size
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include 'Collect.moo'.
|
#include 'Collect.moo'.
|
||||||
#include 'Process.moo'.
|
#include 'Process.moo'.
|
||||||
|
|
||||||
|
(* -------------------------------------------------------------------------- *)
|
||||||
|
|
||||||
class FFI(Object)
|
class FFI(Object)
|
||||||
{
|
{
|
||||||
@ -78,9 +79,7 @@ f isNil ifTrue: [ self error: 'No such function' ].
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(* -------------------------------------------------------------------------- *)
|
||||||
|
|
||||||
#########################################################################################
|
|
||||||
|
|
||||||
#include 'Stdio.moo'.
|
#include 'Stdio.moo'.
|
||||||
#include 'Console.moo'.
|
#include 'Console.moo'.
|
||||||
|
@ -80,7 +80,6 @@ class MyObject(Object)
|
|||||||
'duplicate temporary variable name'
|
'duplicate temporary variable name'
|
||||||
'duplicate variable name'
|
'duplicate variable name'
|
||||||
'duplicate block argument name'
|
'duplicate block argument name'
|
||||||
'cannot assign to argument'
|
|
||||||
'undeclared variable'
|
'undeclared variable'
|
||||||
'unusable variable in compiled code'
|
'unusable variable in compiled code'
|
||||||
'inaccessible variable'
|
'inaccessible variable'
|
||||||
|
@ -4270,8 +4270,8 @@ static int compile_method_expression (moo_t* moo, int pop)
|
|||||||
if (compile_method_expression(moo, 0) <= -1) goto oops;
|
if (compile_method_expression(moo, 0) <= -1) goto oops;
|
||||||
|
|
||||||
/* compile_method_expression() is called after clone_assignee().
|
/* compile_method_expression() is called after clone_assignee().
|
||||||
* clone_assignee() may reallocate a single buffer to hold
|
* clone_assignee() may reallocate a single buffer that holds
|
||||||
* a series of assigness names. the pointer based operation is
|
* a series of assigness names. this pointer based operation is
|
||||||
* fragile as it can change. use the offset of the cloned
|
* fragile as it can change. use the offset of the cloned
|
||||||
* assignee to update the actual pointer after the recursive
|
* assignee to update the actual pointer after the recursive
|
||||||
* compile_method_expression() call */
|
* compile_method_expression() call */
|
||||||
@ -4280,11 +4280,7 @@ static int compile_method_expression (moo_t* moo, int pop)
|
|||||||
|
|
||||||
switch (var.type)
|
switch (var.type)
|
||||||
{
|
{
|
||||||
case VAR_ARGUMENT:
|
case VAR_ARGUMENT: /* TODO: consider if assigning to an argument should be disallowed */
|
||||||
/* assigning to an argument is not allowed */
|
|
||||||
set_syntax_error (moo, MOO_SYNERR_VARARG, &assignee_loc, &assignee);
|
|
||||||
goto oops;
|
|
||||||
|
|
||||||
case VAR_TEMPORARY:
|
case VAR_TEMPORARY:
|
||||||
{
|
{
|
||||||
#if defined(MOO_USE_CTXTEMPVAR)
|
#if defined(MOO_USE_CTXTEMPVAR)
|
||||||
|
@ -98,32 +98,31 @@ static moo_ooch_t synerrstr_27[] = {'u','n','d','e','f','i','n','e','d',' ','c',
|
|||||||
static moo_ooch_t synerrstr_28[] = {'d','u','p','l','i','c','a','t','e',' ','c','l','a','s','s','\0'};
|
static moo_ooch_t synerrstr_28[] = {'d','u','p','l','i','c','a','t','e',' ','c','l','a','s','s','\0'};
|
||||||
static moo_ooch_t synerrstr_29[] = {'c','o','n','t','r','a','d','i','c','t','o','r','y',' ','c','l','a','s','s',' ','d','e','f','i','n','i','t','i','o','n','\0'};
|
static moo_ooch_t synerrstr_29[] = {'c','o','n','t','r','a','d','i','c','t','o','r','y',' ','c','l','a','s','s',' ','d','e','f','i','n','i','t','i','o','n','\0'};
|
||||||
static moo_ooch_t synerrstr_30[] = {'w','r','o','n','g',' ','c','l','a','s','s',' ','n','a','m','e','\0'};
|
static moo_ooch_t synerrstr_30[] = {'w','r','o','n','g',' ','c','l','a','s','s',' ','n','a','m','e','\0'};
|
||||||
static moo_ooch_t synerrstr_31[] = {'#','d','c','l',' ','n','o','t',' ','a','l','l','o','w','e','d','\0'};
|
static moo_ooch_t synerrstr_31[] = {'d','c','l',' ','n','o','t',' ','a','l','l','o','w','e','d','\0'};
|
||||||
static moo_ooch_t synerrstr_32[] = {'w','r','o','n','g',' ','m','e','t','h','o','d',' ','n','a','m','e','\0'};
|
static moo_ooch_t synerrstr_32[] = {'w','r','o','n','g',' ','m','e','t','h','o','d',' ','n','a','m','e','\0'};
|
||||||
static moo_ooch_t synerrstr_33[] = {'d','u','p','l','i','c','a','t','e',' ','m','e','t','h','o','d',' ','n','a','m','e','\0'};
|
static moo_ooch_t synerrstr_33[] = {'d','u','p','l','i','c','a','t','e',' ','m','e','t','h','o','d',' ','n','a','m','e','\0'};
|
||||||
static moo_ooch_t synerrstr_34[] = {'d','u','p','l','i','c','a','t','e',' ','a','r','g','u','m','e','n','t',' ','n','a','m','e','\0'};
|
static moo_ooch_t synerrstr_34[] = {'d','u','p','l','i','c','a','t','e',' ','a','r','g','u','m','e','n','t',' ','n','a','m','e','\0'};
|
||||||
static moo_ooch_t synerrstr_35[] = {'d','u','p','l','i','c','a','t','e',' ','t','e','m','p','o','r','a','r','y',' ','v','a','r','i','a','b','l','e',' ','n','a','m','e','\0'};
|
static moo_ooch_t synerrstr_35[] = {'d','u','p','l','i','c','a','t','e',' ','t','e','m','p','o','r','a','r','y',' ','v','a','r','i','a','b','l','e',' ','n','a','m','e','\0'};
|
||||||
static moo_ooch_t synerrstr_36[] = {'d','u','p','l','i','c','a','t','e',' ','v','a','r','i','a','b','l','e',' ','n','a','m','e','\0'};
|
static moo_ooch_t synerrstr_36[] = {'d','u','p','l','i','c','a','t','e',' ','v','a','r','i','a','b','l','e',' ','n','a','m','e','\0'};
|
||||||
static moo_ooch_t synerrstr_37[] = {'d','u','p','l','i','c','a','t','e',' ','b','l','o','c','k',' ','a','r','g','u','m','e','n','t',' ','n','a','m','e','\0'};
|
static moo_ooch_t synerrstr_37[] = {'d','u','p','l','i','c','a','t','e',' ','b','l','o','c','k',' ','a','r','g','u','m','e','n','t',' ','n','a','m','e','\0'};
|
||||||
static moo_ooch_t synerrstr_38[] = {'c','a','n','n','o','t',' ','a','s','s','i','g','n',' ','t','o',' ','a','r','g','u','m','e','n','t','\0'};
|
static moo_ooch_t synerrstr_38[] = {'u','n','d','e','c','l','a','r','e','d',' ','v','a','r','i','a','b','l','e','\0'};
|
||||||
static moo_ooch_t synerrstr_39[] = {'u','n','d','e','c','l','a','r','e','d',' ','v','a','r','i','a','b','l','e','\0'};
|
static moo_ooch_t synerrstr_39[] = {'u','n','u','s','a','b','l','e',' ','v','a','r','i','a','b','l','e',' ','i','n',' ','c','o','m','p','i','l','e','d',' ','c','o','d','e','\0'};
|
||||||
static moo_ooch_t synerrstr_40[] = {'u','n','u','s','a','b','l','e',' ','v','a','r','i','a','b','l','e',' ','i','n',' ','c','o','m','p','i','l','e','d',' ','c','o','d','e','\0'};
|
static moo_ooch_t synerrstr_40[] = {'i','n','a','c','c','e','s','s','i','b','l','e',' ','v','a','r','i','a','b','l','e','\0'};
|
||||||
static moo_ooch_t synerrstr_41[] = {'i','n','a','c','c','e','s','s','i','b','l','e',' ','v','a','r','i','a','b','l','e','\0'};
|
static moo_ooch_t synerrstr_41[] = {'a','m','b','i','g','u','o','u','s',' ','v','a','r','i','a','b','l','e','\0'};
|
||||||
static moo_ooch_t synerrstr_42[] = {'a','m','b','i','g','u','o','u','s',' ','v','a','r','i','a','b','l','e','\0'};
|
static moo_ooch_t synerrstr_42[] = {'w','r','o','n','g',' ','e','x','p','r','e','s','s','i','o','n',' ','p','r','i','m','a','r','y','\0'};
|
||||||
static moo_ooch_t synerrstr_43[] = {'w','r','o','n','g',' ','e','x','p','r','e','s','s','i','o','n',' ','p','r','i','m','a','r','y','\0'};
|
static moo_ooch_t synerrstr_43[] = {'t','o','o',' ','m','a','n','y',' ','t','e','m','p','o','r','a','r','i','e','s','\0'};
|
||||||
static moo_ooch_t synerrstr_44[] = {'t','o','o',' ','m','a','n','y',' ','t','e','m','p','o','r','a','r','i','e','s','\0'};
|
static moo_ooch_t synerrstr_44[] = {'t','o','o',' ','m','a','n','y',' ','a','r','g','u','m','e','n','t','s','\0'};
|
||||||
static moo_ooch_t synerrstr_45[] = {'t','o','o',' ','m','a','n','y',' ','a','r','g','u','m','e','n','t','s','\0'};
|
static moo_ooch_t synerrstr_45[] = {'t','o','o',' ','m','a','n','y',' ','b','l','o','c','k',' ','t','e','m','p','o','r','a','r','i','e','s','\0'};
|
||||||
static moo_ooch_t synerrstr_46[] = {'t','o','o',' ','m','a','n','y',' ','b','l','o','c','k',' ','t','e','m','p','o','r','a','r','i','e','s','\0'};
|
static moo_ooch_t synerrstr_46[] = {'t','o','o',' ','m','a','n','y',' ','b','l','o','c','k',' ','a','r','g','u','m','e','n','t','s','\0'};
|
||||||
static moo_ooch_t synerrstr_47[] = {'t','o','o',' ','m','a','n','y',' ','b','l','o','c','k',' ','a','r','g','u','m','e','n','t','s','\0'};
|
static moo_ooch_t synerrstr_47[] = {'t','o','o',' ','l','a','r','g','e',' ','b','l','o','c','k','\0'};
|
||||||
static moo_ooch_t synerrstr_48[] = {'t','o','o',' ','l','a','r','g','e',' ','b','l','o','c','k','\0'};
|
static moo_ooch_t synerrstr_48[] = {'w','r','o','n','g',' ','p','r','i','m','i','t','i','v','e',' ','f','u','n','c','t','i','o','n',' ','n','u','m','b','e','r','\0'};
|
||||||
static moo_ooch_t synerrstr_49[] = {'w','r','o','n','g',' ','p','r','i','m','i','t','i','v','e',' ','f','u','n','c','t','i','o','n',' ','n','u','m','b','e','r','\0'};
|
static moo_ooch_t synerrstr_49[] = {'w','r','o','n','g',' ','p','r','i','m','i','t','i','v','e',' ','f','u','n','c','t','i','o','n',' ','i','d','e','n','t','i','f','i','e','r','\0'};
|
||||||
static moo_ooch_t synerrstr_50[] = {'w','r','o','n','g',' ','p','r','i','m','i','t','i','v','e',' ','f','u','n','c','t','i','o','n',' ','i','d','e','n','t','i','f','i','e','r','\0'};
|
static moo_ooch_t synerrstr_50[] = {'w','r','o','n','g',' ','m','o','d','u','l','e',' ','n','a','m','e','\0'};
|
||||||
static moo_ooch_t synerrstr_51[] = {'w','r','o','n','g',' ','m','o','d','u','l','e',' ','n','a','m','e','\0'};
|
static moo_ooch_t synerrstr_51[] = {'#','i','n','c','l','u','d','e',' ','e','r','r','o','r','\0'};
|
||||||
static moo_ooch_t synerrstr_52[] = {'#','i','n','c','l','u','d','e',' ','e','r','r','o','r','\0'};
|
static moo_ooch_t synerrstr_52[] = {'w','r','o','n','g',' ','n','a','m','e','s','p','a','c','e',' ','n','a','m','e','\0'};
|
||||||
static moo_ooch_t synerrstr_53[] = {'w','r','o','n','g',' ','n','a','m','e','s','p','a','c','e',' ','n','a','m','e','\0'};
|
static moo_ooch_t synerrstr_53[] = {'w','r','o','n','g',' ','p','o','o','l',' ','d','i','c','t','i','o','n','a','r','y',' ','n','a','m','e','\0'};
|
||||||
static moo_ooch_t synerrstr_54[] = {'w','r','o','n','g',' ','p','o','o','l',' ','d','i','c','t','i','o','n','a','r','y',' ','n','a','m','e','\0'};
|
static moo_ooch_t synerrstr_54[] = {'d','u','p','l','i','c','a','t','e',' ','p','o','o','l',' ','d','i','c','t','i','o','n','a','r','y',' ','n','a','m','e','\0'};
|
||||||
static moo_ooch_t synerrstr_55[] = {'d','u','p','l','i','c','a','t','e',' ','p','o','o','l',' ','d','i','c','t','i','o','n','a','r','y',' ','n','a','m','e','\0'};
|
static moo_ooch_t synerrstr_55[] = {'l','i','t','e','r','a','l',' ','e','x','p','e','c','t','e','d','\0'};
|
||||||
static moo_ooch_t synerrstr_56[] = {'l','i','t','e','r','a','l',' ','e','x','p','e','c','t','e','d','\0'};
|
|
||||||
static moo_ooch_t* synerrstr[] =
|
static moo_ooch_t* synerrstr[] =
|
||||||
{
|
{
|
||||||
synerrstr_0, synerrstr_1, synerrstr_2, synerrstr_3, synerrstr_4, synerrstr_5, synerrstr_6, synerrstr_7,
|
synerrstr_0, synerrstr_1, synerrstr_2, synerrstr_3, synerrstr_4, synerrstr_5, synerrstr_6, synerrstr_7,
|
||||||
@ -132,9 +131,9 @@ static moo_ooch_t* synerrstr[] =
|
|||||||
synerrstr_24, synerrstr_25, synerrstr_26, synerrstr_27, synerrstr_28, synerrstr_29, synerrstr_30, synerrstr_31,
|
synerrstr_24, synerrstr_25, synerrstr_26, synerrstr_27, synerrstr_28, synerrstr_29, synerrstr_30, synerrstr_31,
|
||||||
synerrstr_32, synerrstr_33, synerrstr_34, synerrstr_35, synerrstr_36, synerrstr_37, synerrstr_38, synerrstr_39,
|
synerrstr_32, synerrstr_33, synerrstr_34, synerrstr_35, synerrstr_36, synerrstr_37, synerrstr_38, synerrstr_39,
|
||||||
synerrstr_40, synerrstr_41, synerrstr_42, synerrstr_43, synerrstr_44, synerrstr_45, synerrstr_46, synerrstr_47,
|
synerrstr_40, synerrstr_41, synerrstr_42, synerrstr_43, synerrstr_44, synerrstr_45, synerrstr_46, synerrstr_47,
|
||||||
synerrstr_48, synerrstr_49, synerrstr_50, synerrstr_51, synerrstr_52, synerrstr_53, synerrstr_54, synerrstr_55,
|
synerrstr_48, synerrstr_49, synerrstr_50, synerrstr_51, synerrstr_52, synerrstr_53, synerrstr_54, synerrstr_55
|
||||||
synerrstr_56
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
/* END: GENERATED WITH generr.st */
|
/* END: GENERATED WITH generr.st */
|
||||||
|
|
||||||
|
@ -1104,7 +1104,6 @@ enum moo_synerrnum_t
|
|||||||
MOO_SYNERR_TMPRNAMEDUP, /* duplicate temporary variable name */
|
MOO_SYNERR_TMPRNAMEDUP, /* duplicate temporary variable name */
|
||||||
MOO_SYNERR_VARNAMEDUP, /* duplicate variable name */
|
MOO_SYNERR_VARNAMEDUP, /* duplicate variable name */
|
||||||
MOO_SYNERR_BLKARGNAMEDUP, /* duplicate block argument name */
|
MOO_SYNERR_BLKARGNAMEDUP, /* duplicate block argument name */
|
||||||
MOO_SYNERR_VARARG, /* cannot assign to argument */
|
|
||||||
MOO_SYNERR_VARUNDCL, /* undeclared variable */
|
MOO_SYNERR_VARUNDCL, /* undeclared variable */
|
||||||
MOO_SYNERR_VARUNUSE, /* unsuable variable in compiled code */
|
MOO_SYNERR_VARUNUSE, /* unsuable variable in compiled code */
|
||||||
MOO_SYNERR_VARINACC, /* inaccessible variable - e.g. accessing an instance variable from a class method is not allowed. */
|
MOO_SYNERR_VARINACC, /* inaccessible variable - e.g. accessing an instance variable from a class method is not allowed. */
|
||||||
|
Loading…
Reference in New Issue
Block a user