diff options
author | Araq <rumpf_a@web.de> | 2012-10-19 20:45:26 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2012-10-19 20:45:26 +0200 |
commit | 172b6aacf84a69a269073f2296db2b8a08a5c834 (patch) | |
tree | faba824b81a732ab399ff15c43634e6d2fb3ea45 | |
parent | b20663ce192ff8012b2d73113a5d506b8526ec62 (diff) | |
download | Nim-172b6aacf84a69a269073f2296db2b8a08a5c834.tar.gz |
fixes #230; fixes #227
-rwxr-xr-x | compiler/ccgexprs.nim | 5 | ||||
-rwxr-xr-x | doc/tut1.txt | 9 | ||||
-rw-r--r-- | tests/ccg/tmissingbracket.nim | 52 | ||||
-rwxr-xr-x | tests/tester.nim | 1 |
4 files changed, 57 insertions, 10 deletions
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index 72d95c4c7..abdfbd613 100755 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -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) diff --git a/doc/tut1.txt b/doc/tut1.txt index c6e4edb82..95d13ceb9 100755 --- a/doc/tut1.txt +++ b/doc/tut1.txt @@ -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 diff --git a/tests/ccg/tmissingbracket.nim b/tests/ccg/tmissingbracket.nim new file mode 100644 index 000000000..ba681ebda --- /dev/null +++ b/tests/ccg/tmissingbracket.nim @@ -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 + diff --git a/tests/tester.nim b/tests/tester.nim index 795c094b7..259330805 100755 --- a/tests/tester.nim +++ b/tests/tester.nim @@ -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) |