json code generation works again
This commit is contained in:
parent
5131b3cea4
commit
cb21fd4f8f
6 changed files with 17 additions and 14 deletions
|
|
@ -940,8 +940,8 @@ proc createVar(p: var TProc, typ: PType, indirect: bool): PRope =
|
||||||
result = putToSeq("0", indirect)
|
result = putToSeq("0", indirect)
|
||||||
of tyFloat..tyFloat128:
|
of tyFloat..tyFloat128:
|
||||||
result = putToSeq("0.0", indirect)
|
result = putToSeq("0.0", indirect)
|
||||||
of tyRange:
|
of tyRange, tyGenericInst:
|
||||||
result = createVar(p, typ.sons[0], indirect)
|
result = createVar(p, lastSon(typ), indirect)
|
||||||
of tySet:
|
of tySet:
|
||||||
result = toRope("{}")
|
result = toRope("{}")
|
||||||
of tyBool:
|
of tyBool:
|
||||||
|
|
@ -979,7 +979,7 @@ proc createVar(p: var TProc, typ: PType, indirect: bool): PRope =
|
||||||
of tyVar, tyPtr, tyRef:
|
of tyVar, tyPtr, tyRef:
|
||||||
if mapType(t) == etyBaseIndex: result = putToSeq("[null, 0]", indirect)
|
if mapType(t) == etyBaseIndex: result = putToSeq("[null, 0]", indirect)
|
||||||
else: result = putToSeq("null", indirect)
|
else: result = putToSeq("null", indirect)
|
||||||
of tySequence, tyString, tyCString, tyPointer:
|
of tySequence, tyString, tyCString, tyPointer, tyProc:
|
||||||
result = putToSeq("null", indirect)
|
result = putToSeq("null", indirect)
|
||||||
else:
|
else:
|
||||||
internalError("createVar: " & $t.kind)
|
internalError("createVar: " & $t.kind)
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ type
|
||||||
|
|
||||||
TFileModuleMap = seq[TFileModuleRec]
|
TFileModuleMap = seq[TFileModuleRec]
|
||||||
|
|
||||||
var compMods: TFileModuleMap = @ []
|
var compMods: TFileModuleMap = @[]
|
||||||
|
|
||||||
proc registerModule(filename: string, module: PSym) =
|
proc registerModule(filename: string, module: PSym) =
|
||||||
# all compiled modules
|
# all compiled modules
|
||||||
|
|
|
||||||
|
|
@ -1470,10 +1470,6 @@ type
|
||||||
filename: CString
|
filename: CString
|
||||||
len: int # length of slots (when not debugging always zero)
|
len: int # length of slots (when not debugging always zero)
|
||||||
|
|
||||||
when defined(ecmaScript):
|
|
||||||
var
|
|
||||||
framePtr {.compilerproc.}: PFrame
|
|
||||||
|
|
||||||
when not defined(ECMAScript):
|
when not defined(ECMAScript):
|
||||||
{.push stack_trace:off}
|
{.push stack_trace:off}
|
||||||
proc add*(x: var string, y: cstring) =
|
proc add*(x: var string, y: cstring) =
|
||||||
|
|
@ -1877,6 +1873,11 @@ elif defined(ecmaScript) or defined(NimrodVM):
|
||||||
proc alloc0(size: int): pointer = nil
|
proc alloc0(size: int): pointer = nil
|
||||||
proc realloc(p: Pointer, newsize: int): pointer = nil
|
proc realloc(p: Pointer, newsize: int): pointer = nil
|
||||||
|
|
||||||
|
proc allocShared(size: int): pointer = nil
|
||||||
|
proc allocShared0(size: int): pointer = nil
|
||||||
|
proc deallocShared(p: pointer) = nil
|
||||||
|
proc reallocShared(p: pointer, newsize: int): pointer = nil
|
||||||
|
|
||||||
when defined(ecmaScript):
|
when defined(ecmaScript):
|
||||||
include "system/ecmasys"
|
include "system/ecmasys"
|
||||||
elif defined(NimrodVM):
|
elif defined(NimrodVM):
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nimrod's Runtime Library
|
# Nimrod's Runtime Library
|
||||||
# (c) Copyright 2010 Andreas Rumpf
|
# (c) Copyright 2011 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
# distribution, for details about the copyright.
|
# distribution, for details about the copyright.
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
|
discard """
|
||||||
|
cmd: "nimrod js --hints:on $# $#"
|
||||||
|
"""
|
||||||
|
|
||||||
# This file tests the ECMAScript generator
|
# This file tests the ECMAScript generator
|
||||||
|
|
||||||
import
|
import
|
||||||
|
|
@ -9,11 +13,8 @@ var
|
||||||
inputElement {.importc: "document.form1.input1", nodecl.}: ref TElement
|
inputElement {.importc: "document.form1.input1", nodecl.}: ref TElement
|
||||||
|
|
||||||
proc OnButtonClick() {.exportc.} =
|
proc OnButtonClick() {.exportc.} =
|
||||||
#var x = parseInt($inputElement.value)
|
var x = parseInt($inputElement.value)
|
||||||
#echo($(x * x))
|
echo x*x
|
||||||
var input = $inputElement.value
|
|
||||||
echo "Test"
|
|
||||||
echo "Hi, ", input
|
|
||||||
|
|
||||||
proc OnLoad() {.exportc.} =
|
proc OnLoad() {.exportc.} =
|
||||||
echo "Welcome! Please take your time to fill in this formular!"
|
echo "Welcome! Please take your time to fill in this formular!"
|
||||||
|
|
|
||||||
|
|
@ -301,6 +301,7 @@ proc main(action: string) =
|
||||||
of "compile":
|
of "compile":
|
||||||
var compileRes = initResults()
|
var compileRes = initResults()
|
||||||
compile(compileRes, "tests/accept/compile/t*.nim", options)
|
compile(compileRes, "tests/accept/compile/t*.nim", options)
|
||||||
|
compile(compileRes, "tests/ecmas.nim", options)
|
||||||
writeResults(compileJson, compileRes)
|
writeResults(compileJson, compileRes)
|
||||||
of "examples":
|
of "examples":
|
||||||
var compileRes = readResults(compileJson)
|
var compileRes = readResults(compileJson)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue