Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rokucommunity/brighterscript
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.10.10
Choose a base ref
...
head repository: rokucommunity/brighterscript
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.11.0
Choose a head ref
  • 18 commits
  • 31 files changed
  • 4 contributors

Commits on Jun 14, 2020

  1. Copy the full SHA
    61b9c32 View commit details

Commits on Jun 29, 2020

  1. Copy the full SHA
    1eda31b View commit details
  2. Copy the full SHA
    1582e50 View commit details

Commits on Jun 30, 2020

  1. Fix transpile for empty conditional blocks. (#123)

    * Fix transpile for empty conditional blocks.
    Fixes #117
    
    * Fix lint issue
    
    * Fix issue with build.
    TwitchBronBron authored Jun 30, 2020
    Copy the full SHA
    de38ab9 View commit details
  2. Copy the full SHA
    9a7cf5c View commit details
  3. Copy the full SHA
    01d19a1 View commit details

Commits on Jul 2, 2020

  1. Copy the full SHA
    4d781d1 View commit details

Commits on Jul 3, 2020

  1. Fix simple log date bug.

    Fixes #128
    TwitchBronBron committed Jul 3, 2020
    Copy the full SHA
    77bed93 View commit details

Commits on Jul 6, 2020

  1. Copy the full SHA
    4ac7eca View commit details
  2. Copy the full SHA
    ca6bc4b View commit details
  3. 0.10.11

    TwitchBronBron committed Jul 6, 2020
    Copy the full SHA
    905f098 View commit details
  4. Template string implementation (#107)

    * adds template string implementation
    
    * simple tests for transpile
    
    * improves performance using, spread instead of concat in transpile function
    
    * fixes lexxer bug
    
    * adds TemplateStringExpression, to better handle multiline strings
    
    * Refactors template strings to keep the quasis and expressions separate and pump out a function call. We can handle concat and string repalce on the box)
    
    * adds nested case
    
    * unit test tweak
    
    * Fix lint issues and simplified some literal tests
    
    * bslib: added templateString and toString impl
    
    * lexer support multi-line token location tracking.Fix template literal transpile.
    
    * Fixed template string lexing.
    
    * Combine side-by-side quasis into single expression
    
    * Support escaping various chars in template strings
    
    * template string support for escaped unicode chars
    
    * Fixed incorrect template string char transpile in docs
    
    * template string capture quote marks
    
    * Add support for tagged template string expressions
    
    * more tagged template string tests.
    
    * Log uncaught errors in parser
    string template bugfixes
    
    * Fix template string docs.
    
    Co-authored-by: Bronley Plumb <bronley@gmail.com>
    georgejecook and TwitchBronBron authored Jul 6, 2020
    Copy the full SHA
    9be3c08 View commit details
  5. Source root (#134)

    * Working on source root
    
    * Add test
    
    * Fix sourcemap bug for non-bs files.
    
    * Fix spec to test bs and brs files
    
    * update docs for sourceRoot
    
    * fix lint issue.
    TwitchBronBron authored Jul 6, 2020
    Copy the full SHA
    e5b73ca View commit details
  6. Silence invalid "override" hints (#133)

    * When an import is redundant it generates "override" hints pointing to the same files, which is just noise.
    
    * fix tests
    
    Co-authored-by: Bronley Plumb <bronley@gmail.com>
    Philippe and TwitchBronBron authored Jul 6, 2020
    Copy the full SHA
    eab28e8 View commit details
  7. Source literals (#126)

    * added docs for source literals.
    
    * Create source literal tokens.
    
    * Add tests for source literals.
    
    * Fixed bug with pkgPath
    
    * Add support for sourceRoot for source literals.
    TwitchBronBron authored Jul 6, 2020
    Copy the full SHA
    3e0fb58 View commit details

Commits on Jul 7, 2020

  1. roku-deploy@3.2.0

    TwitchBronBron committed Jul 7, 2020
    Copy the full SHA
    580948e View commit details
  2. Copy the full SHA
    00d3b76 View commit details
  3. 0.11.0

    TwitchBronBron committed Jul 7, 2020
    Copy the full SHA
    ef0564f View commit details
1 change: 0 additions & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: benchmark
on: [push, pull_request]

jobs:
ci:
17 changes: 15 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -5,14 +5,26 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [0.11.0] - 2020-07-06
### Added
- [Source literals feature](https://github.com/rokucommunity/brighterscript/blob/master/docs/source-literals.md) which adds new literals such as `SOURCE_FILE_PATH`, `SOURCE_LINE_NUM`, `FUNCTION_NAME`, and more. ([#13](https://github.com/rokucommunity/brighterscript/issues/13))
- `sourceRoot` config option to fix sourcemap paths for projects that use a temporary staging folder before calling the BrighterScript compiler. ([#134](https://github.com/rokucommunity/brighterscript/commit/e5b73ca37016d5015a389257fb259573c4721e7a))
- [Template string feature](https://github.com/rokucommunity/brighterscript/blob/master/docs/template-strings.md) which brings template string support to BrighterScript. ([#98](https://github.com/rokucommunity/brighterscript/issues/98))
### Fixed
- Do not show BS1010 diagnostic `hint`s for the same script imported for parent and child. ([#113](https://github.com/rokucommunity/brighterscript/issues/113))

## [0.10.11] - 2020-07-05
- Fix bug that would fail to copy files to staging without explicitly specifying `stagingFolderpath`. [#129](https://github.com/rokucommunity/brighterscript/issues/129)



## [0.10.10]
## [0.10.10] - 2020-06-12
### Fixed
- include the missing `bslib.brs` file in the npm package which was causing errors during transpile.



## [0.10.9]
## [0.10.9] 2020-06-12
### Added
- bslib.brs gets copied to `pkg:/source` and added as an import to every component on transpile.
- several timing logs under the `"info"` log level.
@@ -363,6 +375,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0



[0.11.0]: https://github.com/rokucommunity/brighterscript/compare/v0.10.10...v0.11.0
[0.10.10]: https://github.com/rokucommunity/brighterscript/compare/v0.10.9...v0.10.10
[0.10.9]: https://github.com/rokucommunity/brighterscript/compare/v0.10.8...v0.10.9
[0.10.7]: https://github.com/rokucommunity/brighterscript/compare/v0.10.6...v0.10.7
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -180,6 +180,8 @@ These are the options available in the `bsconfig.json` file.
```
- **autoImportComponentScript**: `bool` - BrighterScript only: will automatically import a script at transpile-time for a component with the same name if it exists.
- **sourceRoot*: `string` - Override the root directory path where debugger should locate the source files. The location will be embedded in the source map to help debuggers locate the original source files. This only applies to files found within rootDir. This is useful when you want to preprocess files before passing them to BrighterScript, and want a debugger to open the original files. This option also affects the `SOURCE_FILE_PATH` and `SOURCE_LOCATION` source literals.
## Ignore errors and warnings on a per-line basis
In addition to disabling an entire class of errors in `bsconfig.json` by using `ignoreErrorCodes`, you may also disable errors for a subset of the complier rules within a file with the following comment flags:
4 changes: 4 additions & 0 deletions bsconfig.schema.json
Original file line number Diff line number Diff line change
@@ -183,6 +183,10 @@
"debug",
"trace"
]
},
"sourceRoot": {
"description": "Override the root directory path where debugger should locate the source files. The location will be embedded in the source map to help debuggers locate the original source files. This only applies to files found within rootDir. This is useful when you want to preprocess files before passing them to BrighterScript, and want a debugger to open the original files. This option also affects the `SOURCE_FILE_PATH` and `SOURCE_LOCATION` source literals.",
"type": "string"
}
}
}
25 changes: 24 additions & 1 deletion bslib.brs
Original file line number Diff line number Diff line change
@@ -1 +1,24 @@
' Utility functions for the BrighterScript language
' Utility functions for the BrighterScript language

'
' Convert a value into a string. For non-primitive values, this will return the type instead of its value in most cases.
' @param dynamic value - the value to be turned into a string.
' @return string - the string representation of `value`
'
function bslib_toString(value)
valueType = type(value)
'if the var supports `toStr()`
if valueType = "<uninitialized>" then
return valueType
else if value = invalid then
return "<invalid>"
else if GetInterface(value, "ifToStr") <> invalid then
return value.toStr()
else if valueType = "roSGNode"
return "Node(" + value.subType() + ")"
end if
'TODO add class name for objects once we have reflection implemented

'when all else fails, just return the type
return "<" + valueType + ">"
end function
2 changes: 2 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -7,3 +7,5 @@ See the following pages for more information
- [Imports](imports.md)
- [Namespaces](namespaces.md)
- [callfunc operator](callfunc-operator.md)
- [Source literals](source-literals.md)
- [Template strings (Template literals)](template-strings.md)
186 changes: 186 additions & 0 deletions docs/source-literals.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
# Source Literals
BrightScript provides the `LINE_NUM` literal, which represents the runtime 1-based line number of the current line of code. In a similar fashion, BrighterScript provides several more source literals.

These source literals are converted into inline variables at transpile-time, so keep in mind that any post-processing to the transpiled files could cause these values to be incorrect.

## SOURCE_FILE_PATH
The absolute path to the source file, including a leading `file:/` scheme indicator. i.e. `"file:/C:/projects/RokuApp/source/main.bs"`.

```BrighterScript
print SOURCE_FILE_PATH
```

transpiles to:

```BrightScript
print "file:/c:\projects\roku\brighterscript\scripts\rootDir\source\main.bs"
```

## SOURCE_LINE_NUM
The 1-based line number of the source file.

```BrighterScript
'I am line 1
print SOURCE_LINE_NUM 'I am line 2
```

transpiles to:

```BrightScript
'I am line 1
print 2 'I am line 2
```

## FUNCTION_NAME
### Basic
The name of the current function
```BrighterScript
function RunFromZombie()
print FUNCTION_NAME
end function
```

transpiles to:

```BrightScript
function RunFromZombie()
print "RunFromZombie"
end function
```

### Namespaced
if the function is contained in a namespace, that name will be included in the function name
```BrighterScript
namespace Human.Versus.Zombie
function RunFromZombie()
print FUNCTION_NAME
end function
end namespace
```

transpiles to:

```BrightScript
function Human_Versus_Zombie_RunFromZombie()
print "Human_Versus_Zombie_RunFromZombie"
end function
```
### Anonymous Functions
For anonymous functions, FUNCTION_NAME will include the enclosing function name, followed by `anon` and the index of the function in its parent. If there are multiple nested anonymous functions, each level will have its own `anon[index]` in the name. Function indexes start at 0 within each enclosing function.

```BrighterScript
function main()
zombieAttack = function()
print FUNCTION_NAME
end function
humanAttack = function()
useSword = function()
print FUNCTION_NAME
end function
useSword()
end function
end function
namespace Human.Versus.Zombie
function Eat()
print SOURCE_FUNCTION_NAME
findFood = function()
print FUNCTION_NAME
end function
end function
end namespace
```

transpiles to:

```BrightScript
function main()
zombieAttack = function()
print "main$anon0"
end function
humanAttack = function()
useSword = function()
print "main$anon1$anon0"
end function
useSword()
end function
end function
function Human_Versus_Zombie_Eat()
print "Human.Versus.Zombie.Eat"
findFood = function()
print "Human_Versus_Zombie_Eat$anon0"
end function
end function
```

## SOURCE_FUNCTION_NAME
This works the same as FUNCTION_NAME except that it will use a dot in namespace names instead of the transpiled underscores.


```BrighterScript
namespace Human.Versus.Zombie
function Eat()
print SOURCE_FUNCTION_NAME
findFood = function()
print SOURCE_FUNCTION_NAME
end function
end function
end namespace
```

transpiles to:

```BrightScript
function Human_Versus_Zombie_Eat()
print "Human.Versus.Zombie.Eat"
findFood = function()
print "Human.Versus.Zombie.Eat$anon0"
end function
end function
```

## SOURCE_LOCATION
A combination of SOURCE_FILE_PATH and SOURCE_LINE_NUM.

```BrighterScript
function main()
print SOURCE_LOCATION
end function
```

transpiles to:

```BrightScript
function main()
print "file:/c:\projects\roku\brighterscript\scripts\rootDir\source\main.bs:2"
end function
```

## PKG_PATH
The pkg path of the file.

```BrighterScript
function main()
print PKG_PATH
end function
```

transpiles to:

```BrightScript
function main()
print "pkg:/source/main.brs"
end function
```

## PKG_LOCATION
A combination of PKG_PATH and LINE_NUM. Keep in mind, LINE_NUM is a runtime variable provided by Roku.
```BrighterScript
print PKG_LOCATION
```

transpiles to:

```BrightScript
print "pkg:/source/main.brs:" + str(LINE_NUM)
```
Loading