Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
fa2b4bc
- TSP Working Version MiR 2022
MichaelMiR01 Jun 11, 2022
235e87d
- fix some minor bugs in type conversions
MichaelMiR01 Jun 23, 2022
4188631
- add #define TSP_REMOVABLE static inline to enable tcc dead code rem…
MichaelMiR01 Jul 1, 2022
29430f1
-added break on error to tsp::log // tsp::printLog
MichaelMiR01 Jul 6, 2022
44020c0
Added error handling for compilation
MichaelMiR01 Jul 6, 2022
7ba5cd7
added errorhandling to tsp::compile_package
MichaelMiR01 Jul 6, 2022
d11b26c
Update README.md
MichaelMiR01 Jul 6, 2022
fec23f4
add parser binaries
MichaelMiR01 Jul 6, 2022
bba0483
added binaries for tclParser
MichaelMiR01 Jul 6, 2022
be04a91
Update README.md
MichaelMiR01 Jul 6, 2022
3ca83f3
catched console show (for linux tclsh)
MichaelMiR01 Jul 6, 2022
8f4ef5f
fix undefined errorCode
MichaelMiR01 Jul 6, 2022
f58979f
Update README.md
MichaelMiR01 Jul 6, 2022
c70b817
Update tsp-lang-features.md
MichaelMiR01 Jul 6, 2022
8f1a97b
Update tsp-lang-features.md
MichaelMiR01 Jul 6, 2022
e237e9b
Update README.md
MichaelMiR01 Jul 6, 2022
304105c
Update tsp-lang-features.md
MichaelMiR01 Jul 6, 2022
474abde
Update README.md
MichaelMiR01 Jul 6, 2022
c4b0a3a
init_package renemaes proc to collect procdef underway
MichaelMiR01 Jul 6, 2022
f5ad853
Merge branch 'tsp4tcc' of https://github.com/MichaelMiR01/tsp into ts…
MichaelMiR01 Jul 6, 2022
719502e
added tcc4tcl_helper package as subdir for completeness
MichaelMiR01 Jul 7, 2022
4b260a0
Update compiler-usage.md
MichaelMiR01 Jul 7, 2022
d3c90c0
Update README.md
MichaelMiR01 Jul 7, 2022
77d3588
changed docs
MichaelMiR01 Jul 7, 2022
ec96fd1
add latest code from tsp-package_220717.tar.gz
tcllab Jul 21, 2022
ee51e7e
change parser version num to make pkgIndex and lib file agree
tcllab Jul 22, 2022
b51fab5
Remove cvs folder.
tcllab Jul 23, 2022
3883a73
Code cleaning
MichaelMiR01 Jul 26, 2022
538acca
Merge branch 'tsp4tcc' of https://github.com/MichaelMiR01/tsp into ts…
MichaelMiR01 Jul 26, 2022
5d0f320
Re-Updated docs
MichaelMiR01 Jul 26, 2022
69e0631
More code cleaning
MichaelMiR01 Jul 27, 2022
16059fe
Add module support for tcc4tcl
MichaelMiR01 Aug 25, 2022
21e5d4c
Code cleaning
MichaelMiR01 Aug 27, 2022
19e4b42
Add basic support for array indexing
MichaelMiR01 Oct 22, 2022
850be46
Changes affect only helper routines, not the TSP Core
MichaelMiR01 Apr 7, 2023
4c5315d
Some small changes, bugfixes and additional features
MichaelMiR01 Dec 2, 2024
d14300a
Some bugfixes regarding arrays and self referent strings
MichaelMiR01 Dec 21, 2024
e0e21d5
some small fixes
MichaelMiR01 Dec 30, 2024
227f819
Some bugfixes
MichaelMiR01 Jan 29, 2025
7ad2e60
some small bugfixes
MichaelMiR01 Feb 16, 2025
445e951
some bugfixes
MichaelMiR01 May 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,23 @@ invoked directly, bypassing the Tcl interpreter.

TSP is written entirely in Tcl, with support libraries written in C and Java.

Changes to original TSP
* limited Namespace support for proc names and variables (see [Features](./docs/tsp-lang-features.md))
* package support with ::tsp::init_package // ::tsp::finalize_package (see [Features](./docs/tsp-lang-features.md))
* #tsp::inlinec and #tsp::altTCL directives to include native c-code and alternative tcl-code (see [Compiler Usage](./docs/compiler-usage.md))
* some bugfixes I ran into

# Docs

1. [Introduction](https://github.com/tpoindex/tsp/blob/master/docs/introduction.md)
2. [Features](https://github.com/tpoindex/tsp/blob/master/docs/tsp-lang-features.md)
3. [Type System](https://github.com/tpoindex/tsp/blob/master/docs/type-system.md)
4. [Compiled Commands](https://github.com/tpoindex/tsp/blob/master/docs/compiled-commands.md)
5. [Runtime](https://github.com/tpoindex/tsp/blob/master/docs/runtime.md)
6. [Compiler Usage](https://github.com/tpoindex/tsp/blob/master/docs/compiler-usage.md)
7. [Future Improvements](https://github.com/tpoindex/tsp/blob/master/docs/future-improvements.md)
8. [Install](https://github.com/tpoindex/tsp/blob/master/docs/install.md)
9. [Misc.](https://github.com/tpoindex/tsp/blob/master/docs/misc.md)
1. [Introduction](./docs/introduction.md)
2. [Features](./docs/tsp-lang-features.md)
3. [Type System](./docs/type-system.md)
4. [Compiled Commands](./docs/compiled-commands.md)
5. [Runtime](./docs/runtime.md)
6. [Compiler Usage](./docs/compiler-usage.md)
7. [Future Improvements](./docs/future-improvements.md)
8. [Install](./docs/install.md)
9. [Misc.](./docs/misc.md)


Wiki (Q & A, discussion, other): http://wiki.tcl.tk/Tcl%20Static%20Prime
Empty file modified docs/compiled-commands.md
100644 → 100755
Empty file.
36 changes: 34 additions & 2 deletions docs/compiler-usage.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@ proc can also be specified with a single underscore **('_')**.
a convenience for `tsp::log _`


### `tsp::printLog` *?outfd? ?proc?*
### `tsp::printLog` *?outfd? ?proc? ?breakeval?*

`tsp::printLog` prints the compiler log. Optional outfd specifies a writable file handle, stderr
is the default. Optional proc is specified, only that log is returned. The most recent compiled
proc can also be specified with a single underscore **('_')**.

**breakeval** defaults to 1, so that TSP returns with an error, if there are any errors in transpilation.


## Annotations

Expand Down Expand Up @@ -100,7 +102,37 @@ vwait, etc.)
include tracing on variables and the return values. This can be useful to
isolate variable that may cause conversion errors. See the Tracing section below.


### `#tsp::inlinec`
`#tsp::inlinec` defines a pure c line, that will be put into the source code directly without changes, so it is possible to e.g. call other c-procs directly (given you know the calling conventions) etc.

### `#tsp::altTCL`
`#tsp::altTCL` is put into the generated tcl code (use if compilation/loading fails), so you can give alternate TCL versions of inlineC parts

```

#example
package require tsp

set handle $::tsp::TCC_HANDLE
$handle cproc t1 {int i} double {;#define a simple c procedure here -- it will be compile as c_t1 later
return i*0.5;
}
tsp::proc test {} {
#tsp::procdef double
#tsp::int i
#tsp::double l k
set k 1.0
for {set i 0} {$i<100000} {incr i} {;# $i will be decorated as __i in TSP, $l as __l and so on
#tsp::inlinec __l = c_t1(__i);
#tsp::altTCL set l [t1 $i]
#tsp::inlinec __k = __k+sqrt(__l*__l*0.33);
#tsp::altTCL set k [expr {$k+sqrt($l*$l*0.33)}]
}
return $k
}


```

## Trace compile type

Expand Down
Empty file modified docs/future-improvements.md
100644 → 100755
Empty file.
Empty file modified docs/install.md
100644 → 100755
Empty file.
Empty file modified docs/introduction.md
100644 → 100755
Empty file.
Empty file modified docs/misc.md
100644 → 100755
Empty file.
Empty file modified docs/outline.md
100644 → 100755
Empty file.
Empty file modified docs/runtime.md
100644 → 100755
Empty file.
83 changes: 80 additions & 3 deletions docs/tsp-lang-features.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,93 @@ a level of additional runtime interpretation.
lappend foo {*}$s ;# invalid: expansion syntax not allows
```

## Namespace not supported for proc names
## limited Namespace support for proc names and variables

Currently, procedures can only be defined in the global namespace.
Procedures can be defined in the global namespace. Namespace qualifiers in the proc name are invalid

```
tsp::proc ::pkg::foo {} { ;# invalid: namespace procname not allowed
tsp::proc ::pkg::foo {} { ;# invalid:
#tsp::procdef void
}
```

But you can define a project namespace with the variable tsp::PACKAGE_NAMESPACE; if defined, ALL procs will be rewritten to this namespace

```
set tsp::PACKAGE_NAMESPACE pkg
tsp::proc foo {} { ;# will be rewritten pkg::foo
#tsp::procdef void
#tsp::var v
variable v ;# will be connected to $pkg::v
}

```
## Package support
Package support depends on the package tcc4tcl_helper to work, someday it will be integrated here, meanwhile find it here https://github.com/MichaelMiR01/tccide/tree/main/subpackages

Package support (tsp_packagehelper.tcl) introduces two commands
* ::tsp::init_package {packagename {packagenamespace ""} {packageversion 1.0} {tclversion TCL_VERSION}}
* ::tsp::finalize_package {{packagedir ""} {compiler none}}

TSP will generate package code in the given packagedir (packagedir defaults to packagename).
It writes out

* packagename.c
* packagename.tclprocs.tcl
* packagename.puretcl.tcl
* pkgIndex.tcl
* packagename.dll

compiler can be **intern/memory** or **export**.

**intern** (eq memory) will compile to memory and immediatly install the compiled procs

**export** will build a shared lib (.so//.dll) an write it into the package dir as **packagename.dll // packagename.so**

* packagename.tclprocs.tcl contains all TSP procs defined as tcl-only and will be sourced, if loading the dll fails
* packagename.puretcl.tcl TSP collects all proc definitions between init_package and finalize_package and spits them here. This will be sourced from pkgIndex, so not only tsp and tcc proc are loaded, but tcl procs can also be defined as helpers

```
#example
package require tsp

::tsp::init_package tnop

set handle $tsp::TCC_HANDLE
$handle cproc cnop {Tcl_Interp* interp } char* {
// this is a pure c-function
return "cnop";
}
::tsp::proc tspnop {} {
#this is a transpiled function, its tcl code will go to tnop.tclprocs.tcl
#tsp::procdef void
puts "tspnop"
}
proc tclnop {} {
# this is a pure tcl function. its code will go to tnop.puretcl.tcl
puts "tclnop "
}
::tsp::printLog
::tsp::finalize_package tnop export
```

The exported package can now be loaded with package require packagename.

Furthermore, TSP will try to spit out some compiler directives for tcc/gcc you can use as boilerplate to recompile the sourcecode with an optimizing compiler.

Packages can be enriched with external libraries with the following directives:
```
proc ::tsp::add_tclinclude {fname}
# load tcls for additional sources, issues a source (fname) command into pkgIndex

proc ::tsp::add_bininclude {fname}
# load_dlls for dlls wich should be loaded into interp, issues a load (fname) command into pkgIndex

proc ::tsp::add_dllinclude {fname}
# external dlls wich are dependencies and do not get loaded into interp but linked to your c-code (like jpeg.dll)
# tries to copy fname.dll into [pwd], so tcl can find it and dload
```

## Limitation on proc name and variable names

Procedure names and variable names inside of procedures must follow strict naming conventions.
Expand Down
Empty file modified docs/tutorial.md
100644 → 100755
Empty file.
Empty file modified docs/type-system.md
100644 → 100755
Empty file.
11 changes: 9 additions & 2 deletions lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,20 @@ The following packages are required for use with C/Tcl.
JTcl does not require any external packages, as the required
packages 'hyde' and 'parser' are included in the JTcl distribution.

critcl-3.1.15
https://github.com/andreas-kupries/critcl/releases
critcl-3.1.15 is no longer needed for tsp4tcc uses tcc4tcl (tcc 0.9.27)

tcc4tcl (tcc 0.9.27) can be found here https://github.com/MichaelMiR01/tcc4tcl/releases

Precompiled binaries for tcc4tcl can be found here https://github.com/MichaelMiR01/tccide/

crtitcl can be found here, just in case https://github.com/andreas-kupries/critcl/releases


tclparser-1.4.1
Tclparser provides the 'parser' package. This package is extracted from
the TclPro open source project.

Precompiled binaries for win32 and linux64 are store in the subdir parser together with a pkgIndex.tcl

Original source: http://tclpro.cvs.sourceforge.net/viewvc/tclpro/tclparser/
License: BSD, see tclparser-1.4.1/license.terms
Loading