added 'reset' magic proc

This commit is contained in:
Araq
2011-03-25 01:49:42 +01:00
parent 032599c156
commit bd4f0b94ae
9 changed files with 73 additions and 12 deletions

View File

@@ -0,0 +1,10 @@
##
## can_inherit_generic Nimrod Module
##
## Created by Eric Doughty-Papassideris on 2011-02-16.
## Copyright (c) 2011 FWA. All rights reserved.
type
TGen[T] = object
TSpef[T] = object of TGen[T]

View File

@@ -0,0 +1,11 @@
##
## can_specialise_generic Nimrod Module
##
## Created by Eric Doughty-Papassideris on 2011-02-16.
## Copyright (c) 2011 FWA. All rights reserved.
type
TGen[T] = object
TSpef = object of TGen[string]

View File

@@ -0,0 +1,15 @@
##
## specialised_is_equivalent Nimrod Module
##
## Created by Eric Doughty-Papassideris on 2011-02-16.
## Copyright (c) 2011 FWA. All rights reserved.
type
TGen[T] = tuple[a: T]
TSpef = tuple[a: string]
var
a: TGen[string]
b: TSpef
a = b

View File

@@ -0,0 +1,19 @@
discard """
output: "after"
"""
import
macros, strutils
macro test_macro*(n: stmt): stmt =
result = newNimNode(nnkStmtList)
var ass : PNimrodNode = newNimNode(nnkAsgn)
add(ass, newIdentNode("str"))
add(ass, newStrLitNode("after"))
add(result, ass)
when isMainModule:
var str: string = "before"
test_macro(str):
var i : integer = 123
echo str