Added --noGen option
This commit is contained in:
parent
3f0a4708d3
commit
887d1ce8f5
|
@ -70,6 +70,7 @@ Options
|
|||
-w, --warnings Turn warnings on or off (default: on). Acceptable values are
|
||||
yes/on and no/off
|
||||
--noWarn Disable a specific warning (example: --noWarn:UserWarning)
|
||||
--noGen Don't generate any code (i.e. stop at the typechecking stage)
|
||||
--showMismatches Show all mismatches when function dispatching fails (output is really verbose)
|
||||
--debugLexer Show the lexer's output
|
||||
--debugParser Show the parser's output
|
||||
|
|
|
@ -795,7 +795,7 @@ proc stringify*(self: TypeChecker, typ: TypedNode): string =
|
|||
of NodeKind.funDecl, varDecl, typeDecl:
|
||||
result = self.stringify(TypedDecl(typ).name.valueType)
|
||||
of binaryExpr, unaryExpr, identExpr, callExpr, lentExpr,
|
||||
constExpr, ptrExpr, refExpr:
|
||||
constExpr, ptrExpr, refExpr, genericExpr:
|
||||
result = self.stringify(TypedExpr(typ).kind)
|
||||
else:
|
||||
# TODO
|
||||
|
@ -1082,6 +1082,7 @@ proc replaceGenerics(self: TypeChecker, typ: Type, generics: TableRef[string, Ty
|
|||
of TypeKind.Generic:
|
||||
typ.fields[fieldName] = generics[fieldName]
|
||||
else:
|
||||
# Type is not a generic, replacement not necessary
|
||||
discard
|
||||
else:
|
||||
self.error(&"unable to perform generic instantiation for object of type {self.stringify(typ)}")
|
||||
|
|
15
src/main.nim
15
src/main.nim
|
@ -66,7 +66,7 @@ proc `$`(self: TypedNode): string =
|
|||
result = &"{self.node}: ? ({self.node.kind})"
|
||||
|
||||
|
||||
proc runFile(filename: string, fromString: bool = false, dump: bool = true, breakpoints: seq[uint64] = @[],
|
||||
proc runFile(filename: string, fromString: bool = false, dump: bool = true, generate: bool = true, breakpoints: seq[uint64] = @[],
|
||||
disabledWarnings: seq[WarningKind] = @[], mismatches: bool = false, run: bool = true,
|
||||
backend: PeonBackend = PeonBackend.Bytecode, output: string) =
|
||||
var
|
||||
|
@ -121,6 +121,8 @@ proc runFile(filename: string, fromString: bool = false, dump: bool = true, brea
|
|||
styledEcho fgGreen, &"\t{typedNode.node} (inner) -> {typeChecker.stringify(exprNode.kind)}\n"
|
||||
else:
|
||||
styledEcho fgGreen, &"\t{typedNode.node} -> {typeChecker.stringify(typedNode)}\n"
|
||||
if not generate:
|
||||
return
|
||||
case backend:
|
||||
of PeonBackend.Bytecode:
|
||||
var
|
||||
|
@ -270,11 +272,12 @@ when isMainModule:
|
|||
optParser = initOptParser(commandLineParams())
|
||||
file: string
|
||||
fromString: bool
|
||||
dump: bool = true
|
||||
dump = true
|
||||
warnings: seq[WarningKind] = @[]
|
||||
showMismatches: bool
|
||||
showMismatches = false
|
||||
#mode: CompileMode = CompileMode.Debug
|
||||
run: bool = true
|
||||
run = true
|
||||
generateCode = true
|
||||
backend: PeonBackend
|
||||
output: string
|
||||
breakpoints: seq[uint64]
|
||||
|
@ -303,6 +306,8 @@ when isMainModule:
|
|||
of "string":
|
||||
file = key
|
||||
fromString = true
|
||||
of "noGen":
|
||||
generateCode = false
|
||||
of "noDump":
|
||||
dump = false
|
||||
of "warnings":
|
||||
|
@ -400,4 +405,4 @@ when isMainModule:
|
|||
echo "Sorry, the REPL is broken :("
|
||||
# repl(warnings, showMismatches, backend, dump)
|
||||
else:
|
||||
runFile(file, fromString, dump, breakpoints, warnings, showMismatches, run, backend, output)
|
||||
runFile(file, fromString, dump, generateCode, breakpoints, warnings, showMismatches, run, backend, output)
|
Loading…
Reference in New Issue