src/GroovyEvaluator.st
author vranyj1
Tue, 21 Aug 2012 17:54:21 +0000
branchjk_new_structure
changeset 1639 1397423bcd97
parent 1626 715cd7e0e518
child 1649 0af82006c0b2
permissions -rw-r--r--
Better error reporting in Groovy workspace
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
917
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
     1
"
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
     2
 COPYRIGHT (c) 1996-2011 by Claus Gittinger
1152
040cba55a7d2 Copyright fixes
vranyj1
parents: 1044
diff changeset
     3
1155
vranyj1
parents: 1152
diff changeset
     4
 New code and modifications done at SWING Research Group [1]:
1152
040cba55a7d2 Copyright fixes
vranyj1
parents: 1044
diff changeset
     5
917
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
     6
 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
     7
                            SWING Research Group, Czech Technical University in Prague
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
     8
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
     9
 This software is furnished under a license and may be used
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
    10
 only in accordance with the terms of that license and with the
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
    11
 inclusion of the above copyright notice.   This software may not
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
    12
 be provided or otherwise made available to, or used by, any
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
    13
 other person.  No title to or ownership of the software is
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
    14
 hereby transferred.
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
    15
1155
vranyj1
parents: 1152
diff changeset
    16
 [1] Code written at SWING Research Group contains a signature
vranyj1
parents: 1152
diff changeset
    17
     of one of the above copright owners. For exact set of such code,
vranyj1
parents: 1152
diff changeset
    18
     see the differences between this version and version stx:libjava
1152
040cba55a7d2 Copyright fixes
vranyj1
parents: 1044
diff changeset
    19
     as of 1.9.2010
917
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
    20
"
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
    21
"{ Package: 'stx:libjava' }"
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
    22
1370
0708027f69b0 oops, class rename failed. Fixed now
vranyj1
parents: 1368
diff changeset
    23
Object subclass:#GroovyEvaluator
1639
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
    24
	instanceVariableNames:'requestor source'
1044
84b7d94d9eb8 Java Workspace now share same binding (i.e., workspace variables are remembered)
vranyj1
parents: 1033
diff changeset
    25
	classVariableNames:'WorkspaceBinding'
917
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
    26
	poolDictionaries:''
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
    27
	category:'Languages-Java-Support'
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
    28
!
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
    29
1370
0708027f69b0 oops, class rename failed. Fixed now
vranyj1
parents: 1368
diff changeset
    30
!GroovyEvaluator class methodsFor:'documentation'!
917
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
    31
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
    32
copyright
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
    33
"
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
    34
 COPYRIGHT (c) 1996-2011 by Claus Gittinger
1152
040cba55a7d2 Copyright fixes
vranyj1
parents: 1044
diff changeset
    35
1155
vranyj1
parents: 1152
diff changeset
    36
 New code and modifications done at SWING Research Group [1]:
1152
040cba55a7d2 Copyright fixes
vranyj1
parents: 1044
diff changeset
    37
917
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
    38
 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
    39
                            SWING Research Group, Czech Technical University in Prague
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
    40
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
    41
 This software is furnished under a license and may be used
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
    42
 only in accordance with the terms of that license and with the
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
    43
 inclusion of the above copyright notice.   This software may not
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
    44
 be provided or otherwise made available to, or used by, any
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
    45
 other person.  No title to or ownership of the software is
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
    46
 hereby transferred.
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
    47
1155
vranyj1
parents: 1152
diff changeset
    48
 [1] Code written at SWING Research Group contains a signature
vranyj1
parents: 1152
diff changeset
    49
     of one of the above copright owners. For exact set of such code,
vranyj1
parents: 1152
diff changeset
    50
     see the differences between this version and version stx:libjava
1152
040cba55a7d2 Copyright fixes
vranyj1
parents: 1044
diff changeset
    51
     as of 1.9.2010
917
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
    52
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
    53
"
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
    54
! !
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
    55
1478
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1459
diff changeset
    56
!GroovyEvaluator class methodsFor:'* As yet uncategorized *'!
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1459
diff changeset
    57
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1459
diff changeset
    58
evaluate: source in: context receiver: receiver  notifying: requestor logged: log ifFail: failblock
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1459
diff changeset
    59
    ^self new evaluate: source in: context receiver: receiver  notifying: requestor logged: log ifFail: failblock
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1459
diff changeset
    60
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1459
diff changeset
    61
    "Created: / 13-04-2012 / 17:24:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1459
diff changeset
    62
! !
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1459
diff changeset
    63
1370
0708027f69b0 oops, class rename failed. Fixed now
vranyj1
parents: 1368
diff changeset
    64
!GroovyEvaluator class methodsFor:'utilities'!
1204
6c2b887399e8 Few small fixes
vranyj1
parents: 1202
diff changeset
    65
6c2b887399e8 Few small fixes
vranyj1
parents: 1202
diff changeset
    66
flushWorkspaceBinding
6c2b887399e8 Few small fixes
vranyj1
parents: 1202
diff changeset
    67
6c2b887399e8 Few small fixes
vranyj1
parents: 1202
diff changeset
    68
    WorkspaceBinding := nil
6c2b887399e8 Few small fixes
vranyj1
parents: 1202
diff changeset
    69
6c2b887399e8 Few small fixes
vranyj1
parents: 1202
diff changeset
    70
    "Created: / 02-12-2011 / 23:23:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
6c2b887399e8 Few small fixes
vranyj1
parents: 1202
diff changeset
    71
! !
6c2b887399e8 Few small fixes
vranyj1
parents: 1202
diff changeset
    72
1581
70fbc03d2d82 Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents: 1478
diff changeset
    73
!GroovyEvaluator methodsFor:'accessing'!
1459
9e24f4337d78 Tests for finally
vranyj1
parents: 1370
diff changeset
    74
1581
70fbc03d2d82 Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents: 1478
diff changeset
    75
currentNameSpace: ns
1459
9e24f4337d78 Tests for finally
vranyj1
parents: 1370
diff changeset
    76
    ns notNil ifTrue:[
9e24f4337d78 Tests for finally
vranyj1
parents: 1370
diff changeset
    77
        self error:'Smalltalk namespaces not supported by Groovy'
9e24f4337d78 Tests for finally
vranyj1
parents: 1370
diff changeset
    78
    ].
9e24f4337d78 Tests for finally
vranyj1
parents: 1370
diff changeset
    79
1581
70fbc03d2d82 Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents: 1478
diff changeset
    80
    "Created: / 01-08-2012 / 11:18:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
70fbc03d2d82 Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents: 1478
diff changeset
    81
!
70fbc03d2d82 Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents: 1478
diff changeset
    82
70fbc03d2d82 Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents: 1478
diff changeset
    83
currentNamespace: ns
70fbc03d2d82 Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents: 1478
diff changeset
    84
    self currentNameSpace: ns
70fbc03d2d82 Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents: 1478
diff changeset
    85
1459
9e24f4337d78 Tests for finally
vranyj1
parents: 1370
diff changeset
    86
    "Created: / 07-04-2012 / 09:26:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9e24f4337d78 Tests for finally
vranyj1
parents: 1370
diff changeset
    87
! !
9e24f4337d78 Tests for finally
vranyj1
parents: 1370
diff changeset
    88
1370
0708027f69b0 oops, class rename failed. Fixed now
vranyj1
parents: 1368
diff changeset
    89
!GroovyEvaluator methodsFor:'compiler interface'!
917
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
    90
971
937ed5f288a7 added: #evaluate:
vranyj1
parents: 960
diff changeset
    91
evaluate:source 
937ed5f288a7 added: #evaluate:
vranyj1
parents: 960
diff changeset
    92
937ed5f288a7 added: #evaluate:
vranyj1
parents: 960
diff changeset
    93
    ^self evaluate:source in: nil receiver: nil notifying: nil logged: false ifFail: [self error:'Evaluation failed'].
937ed5f288a7 added: #evaluate:
vranyj1
parents: 960
diff changeset
    94
937ed5f288a7 added: #evaluate:
vranyj1
parents: 960
diff changeset
    95
    "Created: / 02-09-2011 / 10:24:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
937ed5f288a7 added: #evaluate:
vranyj1
parents: 960
diff changeset
    96
!
937ed5f288a7 added: #evaluate:
vranyj1
parents: 960
diff changeset
    97
1639
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
    98
evaluate: sourceObj in: context receiver: receiver notifying: requestorObj logged: logged ifFail: fail 
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
    99
    | binding result wsForWorkspace |
918
73bd57f8d3b0 - fixes in natives (reflective support for fields)
vranyj1
parents: 917
diff changeset
   100
1033
a31de6a4cfa4 refactoringl, moved registry to JavaVM
hlopkmar
parents: 972
diff changeset
   101
    JavaVM booted ifFalse: [
959
1f3342b2e728 Fixes...
vranyj1
parents: 918
diff changeset
   102
        Java initialize.
1f3342b2e728 Fixes...
vranyj1
parents: 918
diff changeset
   103
        JavaVM initializeVM.
1f3342b2e728 Fixes...
vranyj1
parents: 918
diff changeset
   104
    ].
1639
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   105
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   106
    requestor := requestorObj.
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   107
    source := sourceObj.
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   108
    wsForWorkspace := requestor notNil and: [ requestor application isKindOf: WorkspaceApplication ].
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   109
    binding := (Java classForName: 'groovy.lang.Binding') new.
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   110
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   111
    wsForWorkspace ifTrue: [
1044
84b7d94d9eb8 Java Workspace now share same binding (i.e., workspace variables are remembered)
vranyj1
parents: 1033
diff changeset
   112
        WorkspaceBinding isNil ifTrue: [
84b7d94d9eb8 Java Workspace now share same binding (i.e., workspace variables are remembered)
vranyj1
parents: 1033
diff changeset
   113
            WorkspaceBinding := (JavaVM classForName: 'groovy.lang.Binding') new.
84b7d94d9eb8 Java Workspace now share same binding (i.e., workspace variables are remembered)
vranyj1
parents: 1033
diff changeset
   114
        ].
84b7d94d9eb8 Java Workspace now share same binding (i.e., workspace variables are remembered)
vranyj1
parents: 1033
diff changeset
   115
        binding := WorkspaceBinding
84b7d94d9eb8 Java Workspace now share same binding (i.e., workspace variables are remembered)
vranyj1
parents: 1033
diff changeset
   116
    ] ifFalse: [ 
1639
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   117
1612
ba527b3b17aa - fixes for Package.getPackage()
vranyj1
parents: 1581
diff changeset
   118
        binding setVariable: 'this' to: receiver.
ba527b3b17aa - fixes for Package.getPackage()
vranyj1
parents: 1581
diff changeset
   119
        binding setVariable: 'self' to: receiver.
ba527b3b17aa - fixes for Package.getPackage()
vranyj1
parents: 1581
diff changeset
   120
        context notNil ifTrue:[
1626
715cd7e0e518 - fixes in exception handling
vranyj1
parents: 1612
diff changeset
   121
            | pc |
715cd7e0e518 - fixes in exception handling
vranyj1
parents: 1612
diff changeset
   122
1612
ba527b3b17aa - fixes for Package.getPackage()
vranyj1
parents: 1581
diff changeset
   123
            binding setVariable: 'thisContext' to: context.
1626
715cd7e0e518 - fixes in exception handling
vranyj1
parents: 1612
diff changeset
   124
            pc := context pc.
715cd7e0e518 - fixes in exception handling
vranyj1
parents: 1612
diff changeset
   125
            context method localVariableTable do:[:entry|
715cd7e0e518 - fixes in exception handling
vranyj1
parents: 1612
diff changeset
   126
                (pc between: entry startPC and: entry endPC) ifTrue:[
715cd7e0e518 - fixes in exception handling
vranyj1
parents: 1612
diff changeset
   127
                    binding setVariable: entry name to: (context at: entry slot + 1)
715cd7e0e518 - fixes in exception handling
vranyj1
parents: 1612
diff changeset
   128
                ].
715cd7e0e518 - fixes in exception handling
vranyj1
parents: 1612
diff changeset
   129
            ].
1612
ba527b3b17aa - fixes for Package.getPackage()
vranyj1
parents: 1581
diff changeset
   130
        ]
ba527b3b17aa - fixes for Package.getPackage()
vranyj1
parents: 1581
diff changeset
   131
1044
84b7d94d9eb8 Java Workspace now share same binding (i.e., workspace variables are remembered)
vranyj1
parents: 1033
diff changeset
   132
    ].
84b7d94d9eb8 Java Workspace now share same binding (i.e., workspace variables are remembered)
vranyj1
parents: 1033
diff changeset
   133
1639
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   134
    result := self evaluate: source withBinding: binding.
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   135
    ^ result class javaUnwrap: result.
918
73bd57f8d3b0 - fixes in natives (reflective support for fields)
vranyj1
parents: 917
diff changeset
   136
73bd57f8d3b0 - fixes in natives (reflective support for fields)
vranyj1
parents: 917
diff changeset
   137
    "Created: / 17-08-2011 / 08:54:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
73bd57f8d3b0 - fixes in natives (reflective support for fields)
vranyj1
parents: 917
diff changeset
   138
!
73bd57f8d3b0 - fixes in natives (reflective support for fields)
vranyj1
parents: 917
diff changeset
   139
1639
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   140
evaluate: source withBinding: binding
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   141
    "Given a binding, evaluates given a code"
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   142
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   143
    | shell result |
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   144
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   145
    [
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   146
        shell := (Java classForName: 'groovy.lang.GroovyShell') newCleared.
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   147
        shell perform: #'<init>(Lgroovy/lang/Binding;)V' with: binding.
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   148
        result := shell 
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   149
                    perform: #'evaluate(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Object;'
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   150
                    with: (Java as_String: source string)
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   151
                    with: (Java as_String: 'doIt')
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   152
    ] on: JAVA org codehaus groovy control CompilationFailedException do:[:ex|
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   153
        self syntaxError: ex.    
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   154
    ].
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   155
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   156
    ^ result class javaUnwrap: result.
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   157
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   158
    "Created: / 21-08-2012 / 14:08:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   159
!
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   160
917
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
   161
moreSharedPools: pools
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
   162
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
   163
    "Ignored for Java"
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
   164
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
   165
    "Created: / 16-08-2011 / 10:15:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
   166
! !
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
   167
1639
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   168
!GroovyEvaluator methodsFor:'error reporting'!
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   169
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   170
syntaxError: exception
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   171
    | error cause |
1202
7d9f24940ed5 - JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents: 1155
diff changeset
   172
1639
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   173
    error := exception getErrorCollector getError: 0.
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   174
    cause := error getCause.
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   175
    self syntaxError: exception cause: cause.
1202
7d9f24940ed5 - JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents: 1155
diff changeset
   176
1639
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   177
    "Created: / 21-08-2012 / 14:17:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   178
!
1202
7d9f24940ed5 - JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents: 1155
diff changeset
   179
1639
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   180
syntaxError:message atLine: line from: startCol to:endCol
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   181
    "Notify requestor of an error - if there is no requestor
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   182
     put it on the transcript. Requestor is typically the CodeView
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   183
     in which the accept/doIt was triggered, or the PositionableStream
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   184
     which does the fileIn. The requestor may decide how to highlight the
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   185
     error (and/or to abort the compile).
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   186
     Return the result passed back by the requestor."
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   187
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   188
    (Smalltalk isInitialized not and:[Smalltalk isStandAloneDebug]) ifTrue:[
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   189
        "/ error during startup, but sometimes we expect an error and want to supress it
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   190
        Parser parseWarningSignal query ~~ #ignore ifTrue:[
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   191
            thisContext fullPrintAll.
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   192
        ].
1202
7d9f24940ed5 - JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents: 1155
diff changeset
   193
    ].
7d9f24940ed5 - JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents: 1155
diff changeset
   194
1639
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   195
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   196
    "/ backward compatibility - will vanish eventually (use a handler, Luke)
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   197
    (requestor notNil and:[requestor isTextView]) ifTrue:[
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   198
        | sourceStream lineStart |
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   199
        sourceStream := source string readStream.
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   200
        line - 1 timesRepeat:[ sourceStream nextLine ].
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   201
        lineStart := sourceStream position - 1.
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   202
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   203
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   204
        requestor error:message position: lineStart + startCol to: lineStart + endCol from: self.
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   205
        ^ self
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   206
    ].
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   207
    Parser::ParseError isHandled ifTrue:[
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   208
        Parser::ParseError new
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   209
            errorMessage:message startPosition:startCol endPosition:endCol;
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   210
            parameter:self;
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   211
            lineNumber:line;
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   212
            raiseRequest.
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   213
    ].
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   214
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   215
    "Created: / 21-08-2012 / 16:57:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   216
!
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   217
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   218
syntaxError:message cause: cause
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   219
    "Notify requestor of an error - if there is no requestor
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   220
     put it on the transcript. Requestor is typically the CodeView
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   221
     in which the accept/doIt was triggered, or the PositionableStream
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   222
     which does the fileIn. The requestor may decide how to highlight the
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   223
     error (and/or to abort the compile).
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   224
     Return the result passed back by the requestor."
1202
7d9f24940ed5 - JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents: 1155
diff changeset
   225
1639
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   226
    | sourceStream startCol endCol |
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   227
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   228
    (Smalltalk isInitialized not and:[Smalltalk isStandAloneDebug]) ifTrue:[
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   229
        "/ error during startup, but sometimes we expect an error and want to supress it
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   230
        Parser parseWarningSignal query ~~ #ignore ifTrue:[
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   231
            thisContext fullPrintAll.
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   232
        ].
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   233
    ].
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   234
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   235
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   236
    "/ backward compatibility - will vanish eventually (use a handler, Luke)
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   237
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   238
    sourceStream := source string readStream.
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   239
    cause getLine - 1 timesRepeat:[ sourceStream nextLine ].
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   240
    startCol := sourceStream position - 1 + cause getStartColumn.
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   241
    endCol := sourceStream position - 1 + cause getEndColumn.
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   242
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   243
    (requestor notNil and:[requestor isTextView]) ifTrue:[
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   244
        requestor error: cause getOriginalMessage position: startCol to: endCol from: self.
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   245
        ^ self
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   246
    ].
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   247
    Parser::ParseError isHandled ifTrue:[
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   248
        Parser::ParseError new
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   249
            errorMessage: cause getOriginalMessage startPosition:startCol endPosition:endCol;
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   250
            parameter:self;
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   251
            lineNumber:cause getLine;
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   252
            raiseRequest.
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   253
    ].
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   254
1397423bcd97 Better error reporting in Groovy workspace
vranyj1
parents: 1626
diff changeset
   255
    "Created: / 21-08-2012 / 17:10:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1202
7d9f24940ed5 - JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents: 1155
diff changeset
   256
! !
7d9f24940ed5 - JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents: 1155
diff changeset
   257
1370
0708027f69b0 oops, class rename failed. Fixed now
vranyj1
parents: 1368
diff changeset
   258
!GroovyEvaluator class methodsFor:'documentation'!
917
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
   259
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
   260
version_SVN
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
   261
    ^ '$Id$'
ecd1a00132f1 - added JavaEvaluator
vranyj1
parents:
diff changeset
   262
! !