mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-21 12:00:44 +00:00
@@ -555,10 +555,10 @@ proc genDeref(p: BProc, e: PNode, d: var TLoc) =
|
||||
putIntoDest(p, d, a.t.sons[0], ropef("(*$1)", [rdLoc(a)]))
|
||||
|
||||
proc genAddr(p: BProc, e: PNode, d: var TLoc) =
|
||||
var a: TLoc
|
||||
if mapType(e.sons[0].typ) == ctArray:
|
||||
expr(p, e.sons[0], d)
|
||||
else:
|
||||
var a: TLoc
|
||||
InitLocExpr(p, e.sons[0], a)
|
||||
putIntoDest(p, d, e.typ, addrLoc(a))
|
||||
|
||||
@@ -1634,7 +1634,8 @@ proc downConv(p: BProc, n: PNode, d: var TLoc) =
|
||||
var a: TLoc
|
||||
initLocExpr(p, n.sons[0], a)
|
||||
var r = rdLoc(a)
|
||||
if skipTypes(n.sons[0].typ, abstractInst).kind in {tyRef, tyPtr, tyVar}:
|
||||
if skipTypes(n.sons[0].typ, abstractInst).kind in {tyRef, tyPtr, tyVar} and
|
||||
n.sons[0].kind notin {nkHiddenAddr, nkAddr}:
|
||||
app(r, "->Sup")
|
||||
for i in countup(2, abs(inheritanceDiff(dest, src))): app(r, ".Sup")
|
||||
r = con("&", r)
|
||||
|
||||
@@ -86,14 +86,7 @@ Lexical elements
|
||||
|
||||
Let us look at Nimrod's lexical elements in more detail: like other
|
||||
programming languages Nimrod consists of (string) literals, identifiers,
|
||||
keywords, comments, operators, and other punctuation marks. Case is
|
||||
*insignificant* in Nimrod and even underscores are ignored:
|
||||
``This_is_an_identifier`` and ``ThisIsAnIdentifier`` are the same identifier.
|
||||
This feature enables you to use other
|
||||
people's code without bothering about a naming convention that conflicts with
|
||||
yours. A Nimrod-aware editor or IDE can show the identifiers as
|
||||
preferred. It also frees you from remembering the exact spelling of an
|
||||
identifier (was it ``parseURL`` or ``parseUrl`` or ``parse_URL``?).
|
||||
keywords, comments, operators, and other punctuation marks.
|
||||
|
||||
|
||||
String and character literals
|
||||
|
||||
52
tests/ccg/tmissingbracket.nim
Normal file
52
tests/ccg/tmissingbracket.nim
Normal file
@@ -0,0 +1,52 @@
|
||||
discard """
|
||||
output: '''Subobject test called
|
||||
5'''
|
||||
"""
|
||||
|
||||
type
|
||||
TClassOfTCustomObject {.pure, inheritable.} = object
|
||||
base* : ptr TClassOfTCustomObject
|
||||
className* : string
|
||||
TClassOfTobj = object of TClassOfTCustomObject
|
||||
nil
|
||||
TCustomObject = ref object {.inheritable.}
|
||||
class* : ptr TClassOfTCustomObject
|
||||
TObj = ref object of TCustomObject
|
||||
data: int
|
||||
|
||||
var ClassOfTObj: TClassOfTObj
|
||||
|
||||
proc initClassOfTObj() =
|
||||
ClassOfTObj.base = nil
|
||||
ClassOfTObj.className = "TObj"
|
||||
|
||||
initClassOfTObj()
|
||||
|
||||
proc initialize*(self: TObj) =
|
||||
self.class = addr ClassOfTObj
|
||||
# this generates wrong C code: && instead of &
|
||||
|
||||
proc newInstance(T: typedesc): T =
|
||||
mixin initialize
|
||||
new(result)
|
||||
initialize(result)
|
||||
|
||||
var o = TObj.newInstance()
|
||||
|
||||
type
|
||||
TestObj* = object of TObject
|
||||
t:int
|
||||
SubObject* = object of TestObj
|
||||
|
||||
method test*(t:var TestObj) =
|
||||
echo "test called"
|
||||
|
||||
method test*(t:var SubObject) =
|
||||
echo "Subobject test called"
|
||||
t.t= 5
|
||||
|
||||
var a: SubObject
|
||||
|
||||
a.test()
|
||||
echo a.t
|
||||
|
||||
@@ -359,6 +359,7 @@ proc main() =
|
||||
writeResults(rejectJson, r)
|
||||
of "compile":
|
||||
compile(r, "tests/compile/t*.nim", p.cmdLineRest.string)
|
||||
compile(r, "tests/ccg/t*.nim", p.cmdLineRest.string)
|
||||
compile(r, "tests/ecmas.nim", p.cmdLineRest.string)
|
||||
compileExample(r, "lib/pure/*.nim", p.cmdLineRest.string)
|
||||
compileExample(r, "examples/*.nim", p.cmdLineRest.string)
|
||||
|
||||
Reference in New Issue
Block a user