added a new class variable declarator 'var' or 'variable'
supported | .. | style declartion at the class level. added the RDONLY flag to the object header wrote some code to support default values for class-level variables such as instance variables
This commit is contained in:
parent
a768bd8803
commit
4656bf128e
@ -133,6 +133,15 @@ class Apex(nil)
|
||||
method basicAt: index put: anObject
|
||||
{
|
||||
<primitive: #_basic_at_put>
|
||||
## TODO: proper error handling
|
||||
(*
|
||||
if (primitiveError == error(generic))
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
self index: index outOfRange: (self basicSize).
|
||||
}*)
|
||||
self index: index outOfRange: (self basicSize).
|
||||
}
|
||||
|
||||
@ -429,6 +438,11 @@ class Apex(nil)
|
||||
{
|
||||
^self class notImplemented: method_name
|
||||
}
|
||||
|
||||
method messageProhibited: method_name
|
||||
{
|
||||
^self class messageProhibited: method_name
|
||||
}
|
||||
|
||||
method cannotExceptionizeError
|
||||
{
|
||||
|
@ -4,7 +4,8 @@
|
||||
##
|
||||
class(#pointer) Class(Apex)
|
||||
{
|
||||
dcl spec selfspec superclass subclasses name modname instvars classvars classinstvars pooldics instmthdic classmthdic nsdic trsize.
|
||||
var spec, selfspec, superclass, subclasses, name, modname, instvars.
|
||||
var classvars, classinstvars, pooldics, instmthdic, classmthdic, nsdic, cdic, trsize, initv.
|
||||
|
||||
method(#class) basicNew
|
||||
{
|
||||
|
@ -164,7 +164,7 @@ class(#byte) ByteArray(Collection)
|
||||
|
||||
class Set(Collection)
|
||||
{
|
||||
dcl tally bucket.
|
||||
var tally, bucket.
|
||||
|
||||
method(#class) new: size
|
||||
{
|
||||
@ -550,7 +550,7 @@ extend Apex
|
||||
|
||||
class Link(Object)
|
||||
{
|
||||
dcl prev next value.
|
||||
var prev, next, value.
|
||||
|
||||
method(#class) new: value
|
||||
{
|
||||
@ -570,7 +570,7 @@ class Link(Object)
|
||||
|
||||
class LinkedList(Collection)
|
||||
{
|
||||
dcl first last tally.
|
||||
var first, last, tally.
|
||||
|
||||
method initialize
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
## TODO: move Pointe to a separate file
|
||||
class Point(Object)
|
||||
{
|
||||
dcl x y.
|
||||
var x, y.
|
||||
|
||||
method(#class) new
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
class(#pointer) Context(Apex)
|
||||
{
|
||||
dcl sender ip sp ntmprs.
|
||||
var sender, ip, sp, ntmprs.
|
||||
|
||||
method sender
|
||||
{
|
||||
@ -44,7 +44,7 @@ block context...
|
||||
|
||||
class(#pointer) MethodContext(Context)
|
||||
{
|
||||
dcl method receiver home origin.
|
||||
var method, receiver, home, origin.
|
||||
|
||||
method pc
|
||||
{
|
||||
@ -101,7 +101,7 @@ class(#pointer) MethodContext(Context)
|
||||
|
||||
class(#pointer) BlockContext(Context)
|
||||
{
|
||||
dcl nargs source home origin.
|
||||
var nargs, source, home, origin.
|
||||
|
||||
method vargCount
|
||||
{
|
||||
@ -328,8 +328,8 @@ class(#pointer) BlockContext(Context)
|
||||
|
||||
class(#pointer) CompiledMethod(Object)
|
||||
{
|
||||
## dcl owner name preamble preamble_data_1 preamble_data_2 ntmprs nargs code source.
|
||||
dcl owner name preamble preamble_data_1 preamble_data_2 ntmprs nargs source.
|
||||
## var owner, name, preamble, preamble_data_1, preamble_data_2, ntmprs, nargs, code, source.
|
||||
var owner, name, preamble, preamble_data_1, preamble_data_2, ntmprs, nargs, source.
|
||||
|
||||
method preamble
|
||||
{
|
||||
|
@ -6,7 +6,7 @@
|
||||
##
|
||||
class Exception(Apex)
|
||||
{
|
||||
dcl signalContext handlerContext messageText.
|
||||
var signalContext, handlerContext, messageText.
|
||||
|
||||
method(#class) signal
|
||||
{
|
||||
@ -383,6 +383,10 @@ class InvalidArgumentException(Exception)
|
||||
{
|
||||
}
|
||||
|
||||
class ProhibitedMessageException(Exception)
|
||||
{
|
||||
}
|
||||
|
||||
extend Apex
|
||||
{
|
||||
method(#class) primitiveFailed
|
||||
@ -428,6 +432,11 @@ ctx := thisContext.
|
||||
NotImplementedException signal: (method_name & ' not implemented by ' & (self name)).
|
||||
}
|
||||
|
||||
method(#class) messageProhibited: method_name
|
||||
{
|
||||
ProhibitedMessageException signal: (method_name & ' not allowed for ' & (self name)).
|
||||
}
|
||||
|
||||
method(#class) cannotExceptionizeError
|
||||
{
|
||||
## todo: accept the object
|
||||
|
@ -10,7 +10,7 @@ class _FFI(Object) from 'ffi'
|
||||
|
||||
class FFI(Object)
|
||||
{
|
||||
dcl name ffi funcs.
|
||||
var name, ffi, funcs.
|
||||
|
||||
method(#class) new: aString
|
||||
{
|
||||
|
@ -4,7 +4,7 @@ class Magnitude(Object)
|
||||
|
||||
class Association(Magnitude)
|
||||
{
|
||||
dcl key value.
|
||||
var key, value.
|
||||
|
||||
method(#class) key: key value: value
|
||||
{
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
class Mill(Object)
|
||||
{
|
||||
dcl registrar.
|
||||
dcl obj.
|
||||
var registrar.
|
||||
var obj.
|
||||
|
||||
method initialize
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
class(#pointer) Process(Object)
|
||||
{
|
||||
dcl initial_context current_context state sp prev next sem.
|
||||
var initial_context, current_context, state, sp, prev, next, sem.
|
||||
|
||||
method new
|
||||
{
|
||||
@ -99,7 +99,7 @@ class(#pointer) Process(Object)
|
||||
|
||||
class Semaphore(Object)
|
||||
{
|
||||
dcl count waiting_head waiting_tail heapIndex fireTimeSec fireTimeNsec ioIndex ioData ioMask.
|
||||
var count, waiting_head, waiting_tail, heapIndex, fireTimeSec, fireTimeNsec, ioIndex, ioData, ioMask.
|
||||
|
||||
method(#class) forMutualExclusion
|
||||
{
|
||||
@ -176,7 +176,7 @@ class Semaphore(Object)
|
||||
|
||||
class SemaphoreHeap(Object)
|
||||
{
|
||||
dcl arr size.
|
||||
var arr, size.
|
||||
|
||||
method initialize
|
||||
{
|
||||
@ -358,7 +358,7 @@ class SemaphoreHeap(Object)
|
||||
|
||||
class ProcessScheduler(Object)
|
||||
{
|
||||
dcl tally active runnable_head runnable_tail sem_heap.
|
||||
var tally, active, runnable_head, runnable_tail, sem_heap.
|
||||
|
||||
method new
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
class Stdio(Object) from 'stdio'
|
||||
{
|
||||
dcl(#class) in out err.
|
||||
var(#class) in, out, err.
|
||||
|
||||
method(#primitive) open(name, mode).
|
||||
method(#primitive) close.
|
||||
|
@ -6,18 +6,18 @@ class X11(Object) from 'x11'
|
||||
{
|
||||
(* The X11 class represents a X11 display *)
|
||||
|
||||
dcl(#class) default_display.
|
||||
var(#class) default_display.
|
||||
|
||||
dcl cid.
|
||||
dcl windows. ## all windows registered
|
||||
var cid.
|
||||
var windows. ## all windows registered
|
||||
|
||||
dcl event_loop_sem event_loop_proc.
|
||||
dcl ll_event_blocks.
|
||||
var event_loop_sem, event_loop_proc.
|
||||
var ll_event_blocks.
|
||||
|
||||
dcl expose_event.
|
||||
dcl key_event.
|
||||
dcl mouse_event.
|
||||
dcl mouse_wheel_event.
|
||||
var expose_event.
|
||||
var key_event.
|
||||
var mouse_event.
|
||||
var mouse_wheel_event.
|
||||
|
||||
method(#primitive) _connect.
|
||||
method(#primitive) _disconnect.
|
||||
@ -35,7 +35,7 @@ class X11.Exception(System.Exception)
|
||||
|
||||
class X11.Rectangle(Object)
|
||||
{
|
||||
dcl x y width height.
|
||||
var x, y, width, height.
|
||||
|
||||
method initialize
|
||||
{
|
||||
@ -79,6 +79,7 @@ pooldic X11.LLEvent
|
||||
LEAVE_NOTIFY := 8.
|
||||
EXPOSE := 12.
|
||||
VISIBILITY_NOTIFY := 15.
|
||||
DESTROY_NOTIFY := 17.
|
||||
CONFIGURE_NOTIFY := 22.
|
||||
CLIENT_MESSAGE := 33.
|
||||
}
|
||||
@ -87,36 +88,56 @@ class X11.Event(Object)
|
||||
{
|
||||
}
|
||||
|
||||
class X11.InputEvent(X11.Event)
|
||||
|
||||
class X11.KeyEvent(X11.Event)
|
||||
{
|
||||
}
|
||||
|
||||
class X11.KeyEvent(X11.InputEvent)
|
||||
pooldic X11.MouseButton
|
||||
{
|
||||
LEFT := 1.
|
||||
MIDDLE := 2.
|
||||
RIGHT := 3.
|
||||
}
|
||||
|
||||
class X11.MouseEvent(X11.InputEvent)
|
||||
class X11.MouseEvent(X11.Event)
|
||||
{
|
||||
dcl x y.
|
||||
var x, y, button.
|
||||
|
||||
method x { ^self.x }
|
||||
method y { ^self.y }
|
||||
method x { ^self.x }
|
||||
method y { ^self.y }
|
||||
method button { ^self.button } ## X11.MouseButton
|
||||
|
||||
method x: x y: y
|
||||
method initialize
|
||||
{
|
||||
self.x := 0.
|
||||
self.y := 0.
|
||||
self.button := 0.
|
||||
}
|
||||
|
||||
method x: x y: y button: button
|
||||
{
|
||||
self.x := x.
|
||||
self.y := y.
|
||||
self.button := button.
|
||||
}
|
||||
}
|
||||
|
||||
class X11.MouseWheelEvent(X11.InputEvent)
|
||||
class X11.MouseWheelEvent(X11.Event)
|
||||
{
|
||||
dcl x y amount.
|
||||
var x, y, amount.
|
||||
|
||||
method x { ^self.x }
|
||||
method y { ^self.y }
|
||||
method amount { ^self.amount }
|
||||
|
||||
method initialize
|
||||
{
|
||||
self.x := 0.
|
||||
self.y := 0.
|
||||
self.amount := 0.
|
||||
}
|
||||
|
||||
method x: x y: y amount: amount
|
||||
{
|
||||
self.x := x.
|
||||
@ -127,13 +148,21 @@ class X11.MouseWheelEvent(X11.InputEvent)
|
||||
|
||||
class X11.ExposeEvent(X11.Event)
|
||||
{
|
||||
dcl x y width height.
|
||||
var x, y, width, height.
|
||||
|
||||
method x { ^self.x }
|
||||
method y { ^self.y }
|
||||
method width { ^self.width }
|
||||
method height { ^self.height }
|
||||
|
||||
|
||||
method initialize
|
||||
{
|
||||
self.x := 0.
|
||||
self.y := 0.
|
||||
self.width := 0.
|
||||
self.height := 0.
|
||||
}
|
||||
|
||||
method x: x y: y width: width height: height
|
||||
{
|
||||
self.x := x.
|
||||
@ -143,11 +172,6 @@ class X11.ExposeEvent(X11.Event)
|
||||
}
|
||||
}
|
||||
|
||||
class X11.WindowEvent(X11.Event)
|
||||
{
|
||||
dcl width height.
|
||||
}
|
||||
|
||||
## ---------------------------------------------------------------------------
|
||||
## Graphics Context
|
||||
## ---------------------------------------------------------------------------
|
||||
@ -163,7 +187,7 @@ pooldic X11.GCAttr
|
||||
|
||||
class X11.GC(Object) from 'x11.gc'
|
||||
{
|
||||
dcl window id.
|
||||
var window, id.
|
||||
|
||||
method(#primitive) _make (display, window).
|
||||
method(#primitive) _kill.
|
||||
@ -215,7 +239,7 @@ class X11.GC(Object) from 'x11.gc'
|
||||
|
||||
class X11.Component(Object)
|
||||
{
|
||||
dcl parent.
|
||||
var parent.
|
||||
|
||||
method new
|
||||
{
|
||||
@ -268,8 +292,8 @@ class X11.Canvas(Component)
|
||||
|
||||
class X11.WindowedComponent(Component) from 'x11.win'
|
||||
{
|
||||
dcl(#class) geom.
|
||||
dcl wid bounds.
|
||||
var(#class) geom.
|
||||
var wid, bounds.
|
||||
|
||||
method(#primitive) _get_window_dwatom.
|
||||
method(#primitive) _get_window_id.
|
||||
@ -331,6 +355,11 @@ class X11.WindowedComponent(Component) from 'x11.win'
|
||||
}
|
||||
}
|
||||
|
||||
method cachedBounds
|
||||
{
|
||||
^self.bounds
|
||||
}
|
||||
|
||||
method bounds
|
||||
{
|
||||
self _get_window_geometry (self.bounds).
|
||||
@ -374,7 +403,7 @@ class X11.WindowedComponent(Component) from 'x11.win'
|
||||
}
|
||||
method mousePressed: event
|
||||
{
|
||||
('MOUSE PRESSED' & (self.wid asString) & ' ' & (event x asString) & ' ' & (event y asString)) dump.
|
||||
('MOUSE PRESSED' & (self.wid asString) & ' ' & (event x asString) & ' ' & (event y asString) & ' ' & (event button asString)) dump.
|
||||
}
|
||||
method mouseReleased: event
|
||||
{
|
||||
@ -388,7 +417,7 @@ class X11.WindowedComponent(Component) from 'x11.win'
|
||||
|
||||
class X11.Container(WindowedComponent)
|
||||
{
|
||||
dcl components.
|
||||
var components.
|
||||
|
||||
method initialize
|
||||
{
|
||||
@ -417,7 +446,7 @@ class X11.Container(WindowedComponent)
|
||||
|
||||
class X11.FrameWindow(Container)
|
||||
{
|
||||
dcl display.
|
||||
var display.
|
||||
|
||||
method display { ^self.display }
|
||||
method display: display { self.display := display }
|
||||
@ -528,6 +557,7 @@ extend X11
|
||||
at: X11.LLEvent.ENTER_NOTIFY put: #__handle_notify:;
|
||||
at: X11.LLEvent.LEAVE_NOTIFY put: #__handle_notify:;
|
||||
at: X11.LLEvent.EXPOSE put: #__handle_expose:;
|
||||
at: X11.LLEvent.DESTROY_NOTIFY put: #__handle_destroy_notify:;
|
||||
at: X11.LLEvent.CONFIGURE_NOTIFY put: #__handle_configure_notify:;
|
||||
at: X11.LLEvent.CLIENT_MESSAGE put: #__handle_client_message:.
|
||||
}
|
||||
@ -583,12 +613,9 @@ extend X11
|
||||
|
||||
while ((event := self _get_event) notNil)
|
||||
{
|
||||
## XCB_EXPOSE 12
|
||||
## XCB_DESTROY_WINDOW 4
|
||||
('EVENT================>' & event asString) dump.
|
||||
if (event isError)
|
||||
{
|
||||
'Error has occurred in ....' dump.
|
||||
System logNl: ('Error while getting a event from display ' & self.cid asString).
|
||||
ongoing := false.
|
||||
break.
|
||||
}
|
||||
@ -638,7 +665,6 @@ extend X11
|
||||
}
|
||||
else
|
||||
{
|
||||
('Performing ...' & mthname asString) dump.
|
||||
^self perform (mthname, event).
|
||||
##^self perform: mthname with: event.
|
||||
}
|
||||
@ -698,6 +724,7 @@ extend X11
|
||||
method __handle_button_event: event
|
||||
{
|
||||
(*
|
||||
typedef uint8_t xcb_button_t;
|
||||
typedef struct xcb_button_press_event_t {
|
||||
uint8_t response_type;
|
||||
xcb_button_t detail; // uint8_t
|
||||
@ -731,16 +758,10 @@ extend X11
|
||||
detail := event getUint8(1).
|
||||
if (detail >= 1 and: [detail <= 3])
|
||||
{
|
||||
(*
|
||||
self.mouse_event
|
||||
## TODO: encode detail also..
|
||||
x: System _getUint16(event, 24) ## event_x
|
||||
y: System _getUint16(event, 26). ## event_y
|
||||
*)
|
||||
self.mouse_event
|
||||
## TODO: encode detail also..
|
||||
x: event getUint16(24) ## event_x
|
||||
y: event getUint16(26). ## event_y
|
||||
x: event getUint16(24) ## event_x
|
||||
y: event getUint16(26) ## event_y
|
||||
button: detail.
|
||||
|
||||
if (type == X11.LLEvent.BUTTON_PRESS)
|
||||
{
|
||||
@ -755,12 +776,6 @@ extend X11
|
||||
{
|
||||
if (type == X11.LLEvent.BUTTON_RELEASE)
|
||||
{
|
||||
(*
|
||||
self.mouse_wheel_event
|
||||
x: System _getUint16(event, 24) ## event_x
|
||||
y: System _getUint16(event, 26) ## event_y
|
||||
amount: (if (detail == 4) { -1 } else { 1 }).
|
||||
*)
|
||||
self.mouse_wheel_event
|
||||
x: event getUint16(24) ## event_x
|
||||
y: event getUint16(26) ## event_y
|
||||
@ -775,6 +790,33 @@ extend X11
|
||||
}
|
||||
}
|
||||
|
||||
method __handle_destroy_notify: event
|
||||
{
|
||||
(*
|
||||
typedef struct xcb_destroy_notify_event_t {
|
||||
uint8_t response_type;
|
||||
uint8_t pad0;
|
||||
uint16_t sequence;
|
||||
xcb_window_t event;
|
||||
xcb_window_t window;
|
||||
} xcb_destroy_notify_event_t;
|
||||
*)
|
||||
|
||||
| wid window |
|
||||
|
||||
wid := System _getUint32(event, 4). ## event
|
||||
window := self.windows at: wid.
|
||||
|
||||
if (window notError)
|
||||
{
|
||||
'WINDOW DESTROYED....................' dump.
|
||||
}
|
||||
else
|
||||
{
|
||||
System logNl: ('Destroy notify event on unknown window - ' & wid asString).
|
||||
}
|
||||
}
|
||||
|
||||
method __handle_configure_notify: event
|
||||
{
|
||||
(*
|
||||
@ -805,7 +847,7 @@ extend X11
|
||||
{
|
||||
width := System _getUint16(event, 20).
|
||||
height := System _getUint16(event, 22).
|
||||
bounds := window bounds.
|
||||
bounds := window cachedBounds. ## old bounds before resizing.
|
||||
if (bounds width ~= width or: [bounds height ~= height]) { window windowResized }.
|
||||
}
|
||||
else
|
||||
@ -844,7 +886,6 @@ extend X11
|
||||
dw := event getUint32(12). ## data.data32[0]
|
||||
if (dw == window _get_window_dwatom)
|
||||
{
|
||||
## TODO: call close query callback???
|
||||
window close.
|
||||
}
|
||||
|
||||
@ -914,9 +955,9 @@ class MyButton(X11.Button)
|
||||
|
||||
class MyFrame(X11.FrameWindow)
|
||||
{
|
||||
dcl gc.
|
||||
dcl b1.
|
||||
dcl b2.
|
||||
var gc.
|
||||
var b1.
|
||||
var b2.
|
||||
|
||||
method windowOpened
|
||||
{
|
||||
|
@ -62,7 +62,7 @@ class MyObject(Object)
|
||||
') expected'
|
||||
'] expected'
|
||||
'. expected'
|
||||
' expected'
|
||||
', expected'
|
||||
'| expected'
|
||||
'> expected'
|
||||
':= expected'
|
||||
@ -75,14 +75,15 @@ class MyObject(Object)
|
||||
'contradictory class definition'
|
||||
'wrong class name'
|
||||
'non-pointer class inheriting superclass with trailer size set'
|
||||
'dcl not allowed'
|
||||
'variable declaration not allowed'
|
||||
'modifier expected'
|
||||
'wrong modifier'
|
||||
'disallowed modifier'
|
||||
'duplicate modifier'
|
||||
'wrong method name'
|
||||
'method name expected'
|
||||
'duplicate method name'
|
||||
'invalid variadic method definition'
|
||||
'variable name expected'
|
||||
'duplicate argument name'
|
||||
'duplicate temporary variable name'
|
||||
'duplicate variable name'
|
||||
|
952
moo/lib/comp.c
952
moo/lib/comp.c
File diff suppressed because it is too large
Load Diff
@ -88,7 +88,7 @@ static moo_ooch_t synerrstr_15[] = {'(',' ','e','x','p','e','c','t','e','d','\0'
|
||||
static moo_ooch_t synerrstr_16[] = {')',' ','e','x','p','e','c','t','e','d','\0'};
|
||||
static moo_ooch_t synerrstr_17[] = {']',' ','e','x','p','e','c','t','e','d','\0'};
|
||||
static moo_ooch_t synerrstr_18[] = {'.',' ','e','x','p','e','c','t','e','d','\0'};
|
||||
static moo_ooch_t synerrstr_19[] = {' ','e','x','p','e','c','t','e','d','\0'};
|
||||
static moo_ooch_t synerrstr_19[] = {',',' ','e','x','p','e','c','t','e','d','\0'};
|
||||
static moo_ooch_t synerrstr_20[] = {'|',' ','e','x','p','e','c','t','e','d','\0'};
|
||||
static moo_ooch_t synerrstr_21[] = {'>',' ','e','x','p','e','c','t','e','d','\0'};
|
||||
static moo_ooch_t synerrstr_22[] = {':','=',' ','e','x','p','e','c','t','e','d','\0'};
|
||||
@ -101,41 +101,42 @@ static moo_ooch_t synerrstr_28[] = {'d','u','p','l','i','c','a','t','e',' ','c',
|
||||
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_31[] = {'n','o','n','-','p','o','i','n','t','e','r',' ','c','l','a','s','s',' ','i','n','h','e','r','i','t','i','n','g',' ','s','u','p','e','r','c','l','a','s','s',' ','w','i','t','h',' ','t','r','a','i','l','e','r',' ','s','i','z','e',' ','s','e','t','\0'};
|
||||
static moo_ooch_t synerrstr_32[] = {'d','c','l',' ','n','o','t',' ','a','l','l','o','w','e','d','\0'};
|
||||
static moo_ooch_t synerrstr_32[] = {'v','a','r','i','a','b','l','e',' ','d','e','c','l','a','r','a','t','i','o','n',' ','n','o','t',' ','a','l','l','o','w','e','d','\0'};
|
||||
static moo_ooch_t synerrstr_33[] = {'m','o','d','i','f','i','e','r',' ','e','x','p','e','c','t','e','d','\0'};
|
||||
static moo_ooch_t synerrstr_34[] = {'w','r','o','n','g',' ','m','o','d','i','f','i','e','r','\0'};
|
||||
static moo_ooch_t synerrstr_35[] = {'d','i','s','a','l','l','o','w','e','d',' ','m','o','d','i','f','i','e','r','\0'};
|
||||
static moo_ooch_t synerrstr_36[] = {'d','u','p','l','i','c','a','t','e',' ','m','o','d','i','f','i','e','r','\0'};
|
||||
static moo_ooch_t synerrstr_37[] = {'w','r','o','n','g',' ','m','e','t','h','o','d',' ','n','a','m','e','\0'};
|
||||
static moo_ooch_t synerrstr_37[] = {'m','e','t','h','o','d',' ','n','a','m','e',' ','e','x','p','e','c','t','e','d','\0'};
|
||||
static moo_ooch_t synerrstr_38[] = {'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_39[] = {'i','n','v','a','l','i','d',' ','v','a','r','i','a','d','i','c',' ','m','e','t','h','o','d',' ','d','e','f','i','n','i','t','i','o','n','\0'};
|
||||
static moo_ooch_t synerrstr_40[] = {'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_41[] = {'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_42[] = {'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_43[] = {'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_44[] = {'u','n','d','e','c','l','a','r','e','d',' ','v','a','r','i','a','b','l','e','\0'};
|
||||
static moo_ooch_t synerrstr_45[] = {'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_46[] = {'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_47[] = {'a','m','b','i','g','u','o','u','s',' ','v','a','r','i','a','b','l','e','\0'};
|
||||
static moo_ooch_t synerrstr_48[] = {'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_49[] = {'t','o','o',' ','m','a','n','y',' ','t','e','m','p','o','r','a','r','i','e','s','\0'};
|
||||
static moo_ooch_t synerrstr_50[] = {'t','o','o',' ','m','a','n','y',' ','a','r','g','u','m','e','n','t','s','\0'};
|
||||
static moo_ooch_t synerrstr_51[] = {'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_52[] = {'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_53[] = {'t','o','o',' ','l','a','r','g','e',' ','b','l','o','c','k','\0'};
|
||||
static moo_ooch_t synerrstr_54[] = {'t','o','o',' ','l','a','r','g','e',' ','a','r','r','a','y',' ','e','x','p','r','e','s','s','i','o','n','\0'};
|
||||
static moo_ooch_t synerrstr_55[] = {'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_56[] = {'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_57[] = {'w','r','o','n','g',' ','p','r','i','m','i','t','i','v','e',' ','f','u','n','c','t','i','o','n',' ','a','r','g','u','m','e','n','t',' ','d','e','f','i','n','i','t','i','o','n','\0'};
|
||||
static moo_ooch_t synerrstr_58[] = {'w','r','o','n','g',' ','m','o','d','u','l','e',' ','n','a','m','e','\0'};
|
||||
static moo_ooch_t synerrstr_59[] = {'#','i','n','c','l','u','d','e',' ','e','r','r','o','r','\0'};
|
||||
static moo_ooch_t synerrstr_60[] = {'w','r','o','n','g',' ','n','a','m','e','s','p','a','c','e',' ','n','a','m','e','\0'};
|
||||
static moo_ooch_t synerrstr_61[] = {'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_62[] = {'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_63[] = {'l','i','t','e','r','a','l',' ','e','x','p','e','c','t','e','d','\0'};
|
||||
static moo_ooch_t synerrstr_64[] = {'b','r','e','a','k',' ','o','r',' ','c','o','n','t','i','n','u','e',' ','n','o','t',' ','w','i','t','h','i','n',' ','a',' ','l','o','o','p','\0'};
|
||||
static moo_ooch_t synerrstr_65[] = {'b','r','e','a','k',' ','o','r',' ','c','o','n','t','i','n','u','e',' ','w','i','t','h','i','n',' ','a',' ','b','l','o','c','k','\0'};
|
||||
static moo_ooch_t synerrstr_66[] = {'w','h','i','l','e',' ','e','x','p','e','c','t','e','d','\0'};
|
||||
static moo_ooch_t synerrstr_40[] = {'v','a','r','i','a','b','l','e',' ','n','a','m','e',' ','e','x','p','e','c','t','e','d','\0'};
|
||||
static moo_ooch_t synerrstr_41[] = {'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_42[] = {'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_43[] = {'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_44[] = {'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_45[] = {'u','n','d','e','c','l','a','r','e','d',' ','v','a','r','i','a','b','l','e','\0'};
|
||||
static moo_ooch_t synerrstr_46[] = {'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_47[] = {'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_48[] = {'a','m','b','i','g','u','o','u','s',' ','v','a','r','i','a','b','l','e','\0'};
|
||||
static moo_ooch_t synerrstr_49[] = {'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_50[] = {'t','o','o',' ','m','a','n','y',' ','t','e','m','p','o','r','a','r','i','e','s','\0'};
|
||||
static moo_ooch_t synerrstr_51[] = {'t','o','o',' ','m','a','n','y',' ','a','r','g','u','m','e','n','t','s','\0'};
|
||||
static moo_ooch_t synerrstr_52[] = {'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_53[] = {'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_54[] = {'t','o','o',' ','l','a','r','g','e',' ','b','l','o','c','k','\0'};
|
||||
static moo_ooch_t synerrstr_55[] = {'t','o','o',' ','l','a','r','g','e',' ','a','r','r','a','y',' ','e','x','p','r','e','s','s','i','o','n','\0'};
|
||||
static moo_ooch_t synerrstr_56[] = {'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_57[] = {'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_58[] = {'w','r','o','n','g',' ','p','r','i','m','i','t','i','v','e',' ','f','u','n','c','t','i','o','n',' ','a','r','g','u','m','e','n','t',' ','d','e','f','i','n','i','t','i','o','n','\0'};
|
||||
static moo_ooch_t synerrstr_59[] = {'w','r','o','n','g',' ','m','o','d','u','l','e',' ','n','a','m','e','\0'};
|
||||
static moo_ooch_t synerrstr_60[] = {'#','i','n','c','l','u','d','e',' ','e','r','r','o','r','\0'};
|
||||
static moo_ooch_t synerrstr_61[] = {'w','r','o','n','g',' ','n','a','m','e','s','p','a','c','e',' ','n','a','m','e','\0'};
|
||||
static moo_ooch_t synerrstr_62[] = {'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_63[] = {'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_64[] = {'l','i','t','e','r','a','l',' ','e','x','p','e','c','t','e','d','\0'};
|
||||
static moo_ooch_t synerrstr_65[] = {'b','r','e','a','k',' ','o','r',' ','c','o','n','t','i','n','u','e',' ','n','o','t',' ','w','i','t','h','i','n',' ','a',' ','l','o','o','p','\0'};
|
||||
static moo_ooch_t synerrstr_66[] = {'b','r','e','a','k',' ','o','r',' ','c','o','n','t','i','n','u','e',' ','w','i','t','h','i','n',' ','a',' ','b','l','o','c','k','\0'};
|
||||
static moo_ooch_t synerrstr_67[] = {'w','h','i','l','e',' ','e','x','p','e','c','t','e','d','\0'};
|
||||
static moo_ooch_t* synerrstr[] =
|
||||
{
|
||||
synerrstr_0, synerrstr_1, synerrstr_2, synerrstr_3, synerrstr_4, synerrstr_5, synerrstr_6, synerrstr_7,
|
||||
@ -146,7 +147,7 @@ static moo_ooch_t* synerrstr[] =
|
||||
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_56, synerrstr_57, synerrstr_58, synerrstr_59, synerrstr_60, synerrstr_61, synerrstr_62, synerrstr_63,
|
||||
synerrstr_64, synerrstr_65, synerrstr_66
|
||||
synerrstr_64, synerrstr_65, synerrstr_66, synerrstr_67
|
||||
};
|
||||
#endif
|
||||
/* END: GENERATED WITH generr.moo */
|
||||
|
@ -1638,6 +1638,14 @@ static moo_pfrc_t pf_basic_at_put (moo_t* moo, moo_ooi_t nargs)
|
||||
moo->errnum = MOO_EINVAL;
|
||||
return MOO_PF_FAILURE;
|
||||
}
|
||||
|
||||
if (MOO_OBJ_GET_FLAGS_RDONLY(rcv))
|
||||
{
|
||||
/* TODO: better error handlign */
|
||||
moo->errnum = MOO_EPERM;
|
||||
return MOO_PF_FAILURE;
|
||||
}
|
||||
|
||||
pos = MOO_STACK_GETARG(moo, nargs, 0);
|
||||
val = MOO_STACK_GETARG(moo, nargs, 1);
|
||||
|
||||
|
@ -68,7 +68,8 @@ void* moo_allocheapmem (moo_t* moo, moo_heap_t* heap, moo_oow_t size)
|
||||
/* check the heap size limit */
|
||||
if (heap->ptr >= heap->limit || heap->limit - heap->ptr < size)
|
||||
{
|
||||
MOO_LOG4 (moo, MOO_LOG_ERROR, "Cannot allocate %zd bytes from heap - ptr %p limit %p size %zd\n", size, heap->ptr, heap->limit, (moo_oow_t)(heap->limit - heap->ptr));
|
||||
MOO_DEBUG5 (moo, "Cannot allocate %zd bytes from heap - ptr %p limit %p size %zd free %zd\n",
|
||||
size, heap->ptr, heap->limit, (moo_oow_t)(heap->limit - heap->base), (moo_oow_t)(heap->limit - heap->ptr));
|
||||
moo->errnum = MOO_EOOMEM;
|
||||
return MOO_NULL;
|
||||
}
|
||||
|
@ -44,9 +44,13 @@
|
||||
* PUSH_CONTEXT, PUSH_INTLIT, PUSH_INTLIT, SEND_BLOCK_COPY */
|
||||
#define MOO_USE_MAKE_BLOCK
|
||||
|
||||
/* define this to limit the default values for instance variables
|
||||
* to simple values like numbers or characters */
|
||||
#define MOO_SIMPLE_INITV
|
||||
|
||||
#if !defined(NDEBUG)
|
||||
/* this is for gc debugging */
|
||||
/*#define MOO_DEBUG_GC*/
|
||||
#define MOO_DEBUG_GC
|
||||
#define MOO_DEBUG_COMPILER
|
||||
/*#define MOO_DEBUG_VM_PROCESSOR*/
|
||||
/*#define MOO_DEBUG_VM_EXEC*/
|
||||
@ -434,9 +438,6 @@ struct moo_compiler_t
|
||||
|
||||
moo_oop_class_t self_oop;
|
||||
moo_oop_t super_oop; /* this may be nil. so the type is moo_oop_t */
|
||||
#ifdef MTHDIC
|
||||
moo_oop_set_t mthdic_oop[2]; /* used when compiling a method definition */
|
||||
#endif
|
||||
moo_oop_set_t pooldic_oop; /* used when compiling a pooldic definition */
|
||||
moo_oop_set_t ns_oop;
|
||||
moo_oocs_t fqn;
|
||||
@ -453,15 +454,23 @@ struct moo_compiler_t
|
||||
moo_oocs_t modname; /* module name after 'from' */
|
||||
moo_oow_t modname_capa;
|
||||
|
||||
/* instance variable, class variable, class instance variable */
|
||||
moo_oocs_t vars[3];
|
||||
moo_oow_t vars_capa[3];
|
||||
/* instance variable, class variable, class instance variable
|
||||
* var[0] - named instance variables
|
||||
* var[1] - class variables
|
||||
* var[2] - class instance variables */
|
||||
struct
|
||||
{
|
||||
moo_oocs_t str; /* long string containing all variables declared delimited by a space */
|
||||
moo_oow_t str_capa;
|
||||
|
||||
/* var_count, unlike vars above, includes superclass counts as well.
|
||||
* var_count[0] - number of named instance variables
|
||||
* var_count[1] - number of class variables
|
||||
* var_count[2] - number of class instance variables */
|
||||
moo_oow_t var_count[3];
|
||||
moo_oow_t count; /* the number of variables declared in this class only */
|
||||
moo_oow_t total_count; /* the number of variables declared in this class and superclasses */
|
||||
|
||||
moo_oop_t* initv;
|
||||
moo_oow_t initv_capa;
|
||||
moo_oow_t initv_count;
|
||||
moo_oow_t initv_total_count;
|
||||
} var[3];
|
||||
|
||||
/* buffer to hold pooldic import declaration */
|
||||
moo_oocs_t pooldic;
|
||||
|
@ -326,6 +326,7 @@ typedef enum moo_obj_type_t moo_obj_type_t;
|
||||
* when full definition is available, it's set to 2.
|
||||
* moved: 0 or 1. used by GC. internal use only.
|
||||
* ngc: 0 or 1, used by GC. internal use only.
|
||||
* rdonly: 0 or 1. indicates that an object is immutable.
|
||||
* trailer: 0 or 1. indicates that there are trailing bytes
|
||||
* after the object payload. internal use only.
|
||||
*
|
||||
@ -360,6 +361,7 @@ typedef enum moo_obj_type_t moo_obj_type_t;
|
||||
#define MOO_OBJ_FLAGS_KERNEL_BITS 2
|
||||
#define MOO_OBJ_FLAGS_MOVED_BITS 1
|
||||
#define MOO_OBJ_FLAGS_NGC_BITS 1
|
||||
#define MOO_OBJ_FLAGS_RDONLY_BITS 1
|
||||
#define MOO_OBJ_FLAGS_TRAILER_BITS 1
|
||||
|
||||
#define MOO_OBJ_FLAGS_TYPE_SHIFT (MOO_OBJ_FLAGS_UNIT_BITS + MOO_OBJ_FLAGS_UNIT_SHIFT)
|
||||
@ -367,7 +369,8 @@ typedef enum moo_obj_type_t moo_obj_type_t;
|
||||
#define MOO_OBJ_FLAGS_EXTRA_SHIFT (MOO_OBJ_FLAGS_KERNEL_BITS + MOO_OBJ_FLAGS_KERNEL_SHIFT)
|
||||
#define MOO_OBJ_FLAGS_KERNEL_SHIFT (MOO_OBJ_FLAGS_MOVED_BITS + MOO_OBJ_FLAGS_MOVED_SHIFT)
|
||||
#define MOO_OBJ_FLAGS_MOVED_SHIFT (MOO_OBJ_FLAGS_NGC_BITS + MOO_OBJ_FLAGS_NGC_SHIFT)
|
||||
#define MOO_OBJ_FLAGS_NGC_SHIFT (MOO_OBJ_FLAGS_TRAILER_BITS + MOO_OBJ_FLAGS_TRAILER_SHIFT)
|
||||
#define MOO_OBJ_FLAGS_NGC_SHIFT (MOO_OBJ_FLAGS_RDONLY_BITS + MOO_OBJ_FLAGS_RDONLY_SHIFT)
|
||||
#define MOO_OBJ_FLAGS_RDONLY_SHIFT (MOO_OBJ_FLAGS_TRAILER_BITS + MOO_OBJ_FLAGS_TRAILER_SHIFT)
|
||||
#define MOO_OBJ_FLAGS_TRAILER_SHIFT (0)
|
||||
|
||||
#define MOO_OBJ_GET_FLAGS_TYPE(oop) MOO_GETBITS(moo_oow_t, (oop)->_flags, MOO_OBJ_FLAGS_TYPE_SHIFT, MOO_OBJ_FLAGS_TYPE_BITS)
|
||||
@ -376,6 +379,7 @@ typedef enum moo_obj_type_t moo_obj_type_t;
|
||||
#define MOO_OBJ_GET_FLAGS_KERNEL(oop) MOO_GETBITS(moo_oow_t, (oop)->_flags, MOO_OBJ_FLAGS_KERNEL_SHIFT, MOO_OBJ_FLAGS_KERNEL_BITS)
|
||||
#define MOO_OBJ_GET_FLAGS_MOVED(oop) MOO_GETBITS(moo_oow_t, (oop)->_flags, MOO_OBJ_FLAGS_MOVED_SHIFT, MOO_OBJ_FLAGS_MOVED_BITS)
|
||||
#define MOO_OBJ_GET_FLAGS_NGC(oop) MOO_GETBITS(moo_oow_t, (oop)->_flags, MOO_OBJ_FLAGS_NGC_SHIFT, MOO_OBJ_FLAGS_NGC_BITS)
|
||||
#define MOO_OBJ_GET_FLAGS_RDONLY(oop) MOO_GETBITS(moo_oow_t, (oop)->_flags, MOO_OBJ_FLAGS_RDONLY_SHIFT, MOO_OBJ_FLAGS_RDONLY_BITS)
|
||||
#define MOO_OBJ_GET_FLAGS_TRAILER(oop) MOO_GETBITS(moo_oow_t, (oop)->_flags, MOO_OBJ_FLAGS_TRAILER_SHIFT, MOO_OBJ_FLAGS_TRAILER_BITS)
|
||||
|
||||
#define MOO_OBJ_SET_FLAGS_TYPE(oop,v) MOO_SETBITS(moo_oow_t, (oop)->_flags, MOO_OBJ_FLAGS_TYPE_SHIFT, MOO_OBJ_FLAGS_TYPE_BITS, v)
|
||||
@ -384,6 +388,7 @@ typedef enum moo_obj_type_t moo_obj_type_t;
|
||||
#define MOO_OBJ_SET_FLAGS_KERNEL(oop,v) MOO_SETBITS(moo_oow_t, (oop)->_flags, MOO_OBJ_FLAGS_KERNEL_SHIFT, MOO_OBJ_FLAGS_KERNEL_BITS, v)
|
||||
#define MOO_OBJ_SET_FLAGS_MOVED(oop,v) MOO_SETBITS(moo_oow_t, (oop)->_flags, MOO_OBJ_FLAGS_MOVED_SHIFT, MOO_OBJ_FLAGS_MOVED_BITS, v)
|
||||
#define MOO_OBJ_SET_FLAGS_NGC(oop,v) MOO_SETBITS(moo_oow_t, (oop)->_flags, MOO_OBJ_FLAGS_NGC_SHIFT, MOO_OBJ_FLAGS_NGC_BITS, v)
|
||||
#define MOO_OBJ_SET_FLAGS_RDONLY(oop,v) MOO_SETBITS(moo_oow_t, (oop)->_flags, MOO_OBJ_FLAGS_RDONLY_SHIFT, MOO_OBJ_FLAGS_RDONLY_BITS, v)
|
||||
#define MOO_OBJ_SET_FLAGS_TRAILER(oop,v) MOO_SETBITS(moo_oow_t, (oop)->_flags, MOO_OBJ_FLAGS_TRAILER_SHIFT, MOO_OBJ_FLAGS_TRAILER_BITS, v)
|
||||
|
||||
#define MOO_OBJ_GET_SIZE(oop) ((oop)->_size)
|
||||
@ -480,7 +485,7 @@ struct moo_set_t
|
||||
moo_oop_oop_t bucket; /* Array */
|
||||
};
|
||||
|
||||
#define MOO_CLASS_NAMED_INSTVARS 14
|
||||
#define MOO_CLASS_NAMED_INSTVARS 16
|
||||
typedef struct moo_class_t moo_class_t;
|
||||
typedef struct moo_class_t* moo_oop_class_t;
|
||||
struct moo_class_t
|
||||
@ -509,8 +514,11 @@ struct moo_class_t
|
||||
moo_oop_set_t mthdic[MOO_METHOD_TYPE_COUNT];
|
||||
|
||||
moo_oop_set_t nsdic; /* dictionary used for namespacing */
|
||||
moo_oop_set_t cdic; /* constant dictionary */
|
||||
moo_oop_t trsize; /* trailer size for new instances */
|
||||
|
||||
moo_oop_t initv; /* instial values for new instances */
|
||||
|
||||
/* indexed part afterwards */
|
||||
moo_oop_t slot[1]; /* class instance variables and class variables. */
|
||||
};
|
||||
@ -1273,14 +1281,15 @@ enum moo_synerrnum_t
|
||||
MOO_SYNERR_CLASSCONTRA, /* contradictory class */
|
||||
MOO_SYNERR_CLASSNAMEINVAL, /* wrong class name */
|
||||
MOO_SYNERR_CLASSTRSIZE, /* non-pointer class inheriting a superclass with trailer size set */
|
||||
MOO_SYNERR_DCLBANNED, /* #dcl not allowed */
|
||||
MOO_SYNERR_VARDCLBANNED, /* variable declaration not allowed */
|
||||
MOO_SYNERR_MODIFIER, /* modifier expected */
|
||||
MOO_SYNERR_MODIFIERINVAL, /* wrong modifier */
|
||||
MOO_SYNERR_MODIFIERBANNED, /* modifier not allowed */
|
||||
MOO_SYNERR_MODIFIERDUPL, /* duplicate modifier */
|
||||
MOO_SYNERR_MTHNAME, /* wrong method name */
|
||||
MOO_SYNERR_MTHNAME, /* method name expected */
|
||||
MOO_SYNERR_MTHNAMEDUPL, /* duplicate method name */
|
||||
MOO_SYNERR_VARIADMTHINVAL, /* invalid variadic method definition */
|
||||
MOO_SYNERR_VARNAME, /* variable name expected */
|
||||
MOO_SYNERR_ARGNAMEDUPL, /* duplicate argument name */
|
||||
MOO_SYNERR_TMPRNAMEDUPL, /* duplicate temporary variable name */
|
||||
MOO_SYNERR_VARNAMEDUPL, /* duplicate variable name */
|
||||
|
@ -38,6 +38,12 @@ void* moo_allocbytes (moo_t* moo, moo_oow_t size)
|
||||
if (!ptr && moo->errnum == MOO_EOOMEM && !(moo->option.trait & MOO_NOGC))
|
||||
{
|
||||
moo_gc (moo);
|
||||
MOO_LOG4 (moo, MOO_LOG_INFO,
|
||||
"GC completed - current heap ptr %p limit %p size %zd free %zd\n",
|
||||
moo->curheap->ptr, moo->curheap->limit,
|
||||
(moo_oow_t)(moo->curheap->limit - moo->curheap->base),
|
||||
(moo_oow_t)(moo->curheap->limit - moo->curheap->ptr)
|
||||
);
|
||||
ptr = moo_allocheapmem (moo, moo->curheap, size);
|
||||
/* TODO: grow heap if ptr is still null. */
|
||||
}
|
||||
@ -266,6 +272,32 @@ moo_oop_t moo_instantiate (moo_t* moo, moo_oop_class_t _class, const void* vptr,
|
||||
/* both the fixed part(named instance variables) and
|
||||
* the variable part(indexed instance variables) are allowed. */
|
||||
oop = moo_allocoopobj (moo, alloclen);
|
||||
if (oop)
|
||||
{
|
||||
/* initialize named instance variables with default values */
|
||||
if (_class->initv != moo->_nil)
|
||||
{
|
||||
|
||||
moo_oow_t i = MOO_OBJ_GET_SIZE(_class->initv);
|
||||
|
||||
#if defined(MOO_SIMPLE_INITV)
|
||||
while (i > 0)
|
||||
{
|
||||
--i;
|
||||
((moo_oop_oop_t)oop)->slot[i] = ((moo_oop_oop_t)_class->initv)->slot[i];
|
||||
}
|
||||
#else
|
||||
moo_pushtmp (moo, (moo_oop_t*)&oop); tmp_count++;
|
||||
while (i > 0)
|
||||
{
|
||||
--i;
|
||||
/* TODO: deep copy the object so that the items can be modified without side-effects.... */
|
||||
((moo_oop_oop_t)oop)->slot[i] = ((moo_oop_oop_t)_class->initv)->slot[i];
|
||||
}
|
||||
moo_poptmp (moo); tmp_count--;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
MOO_ASSERT (moo, vptr == MOO_NULL);
|
||||
/*
|
||||
|
@ -132,8 +132,8 @@ static moo_oop_t find_or_make_symbol (moo_t* moo, const moo_ooch_t* ptr, moo_oow
|
||||
moo_oop_oop_t bucket;
|
||||
|
||||
/* TODO: make the growth policy configurable instead of growing
|
||||
it just before it gets full. The polcy can be grow it
|
||||
if it's 70% full */
|
||||
it just before it gets full. The polcy can be grow it
|
||||
if it's 70% full */
|
||||
|
||||
/* enlarge the symbol table before it gets full to
|
||||
* make sure that it has at least one free slot left
|
||||
|
Loading…
Reference in New Issue
Block a user