diff --git a/.gitignore b/.gitignore
index bf471ea..16a85d5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,6 @@ test-results
*.userprefs
*.pidb
/bin
+build
+.gradle
+lib
diff --git a/LICENSE b/LICENSE
index 48215f8..c19769b 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2010 Rodrigo B. de Oliveira (rbo@acm.org)
+Copyright (c) 2004, 2008, 2010 Rodrigo B. de Oliveira (rbo@acm.org)
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
diff --git a/README b/README
deleted file mode 100644
index 8e05ddf..0000000
--- a/README
+++ /dev/null
@@ -1,22 +0,0 @@
-UnityScript
-========
-
-A JavaScript implementation based on the Boo programming language.
-
-Building the MonoDevelop addin
-=======================
-
-Create a build.properties file and configure the md.bin.dir property to
-point to the directory containing the MonoDevelop binaries. For instance:
-
-
-
-
-
-
-And then:
-
- nant md
-
-This will build and copy the required assemblies to ~/.config/MonoDevelop/addins/UnityScript.
-
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..c4b2a09
--- /dev/null
+++ b/README.md
@@ -0,0 +1,33 @@
+# UnityScript #
+
+A JavaScript implementation based on the Boo programming language.
+
+## Building ##
+
+Checkout boo side-by-side with unityscript.
+
+Build boo:
+
+ pushd ../boo
+ nant
+ popd
+
+Build unityscript (and run the tests):
+
+ nant test
+
+If the build script can't automatically detect the location of nunit.framework.dll
+create a build.properties file in the boo directory with something like:
+
+```xml
+
+
+
+```
+
+With *nunit.framework.dll* pointing to the location of nunit.framework.dll in your system.
+
+
+
+
+
diff --git a/build.gradle b/build.gradle
new file mode 100755
index 0000000..cabf3c1
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,113 @@
+
+buildscript {
+ repositories {
+ ivy { url '../repository' }
+ ivy { url 'http://unity-technologies.github.com/kaizen/repositories/unstable' }
+ mavenCentral()
+ }
+ dependencies {
+ classpath 'kaizen:kaizen:0.2.6'
+ }
+}
+
+apply plugin: 'kaizen-bundle'
+apply plugin: 'nunit'
+apply plugin: 'idea'
+
+allprojects {
+ group = 'unityscript'
+ version = '0.1.4'
+
+ repositories {
+ ivy { url 'http://unity-technologies.github.com/kaizen/repositories/unstable' }
+ }
+}
+
+configurations {
+ boo
+}
+
+ext {
+ booVersion = '0.9.7'
+}
+
+dependencies {
+ boo "boo:boo:$booVersion"
+ boo "boo:RetargetAssembly:0.2.1"
+ 'default' project(':us'), project(':UnityScript'), project(':UnityScript.Lang')
+}
+
+unity.mono.booc.executable = file('lib/Boo/booc.exe')
+
+project(':us') {
+ dependencies {
+ 'default' project(':UnityScript'), project(':UnityScript.Lang')
+ 'default' "boo:Boo.Lang.Useful:$booVersion"
+ }
+ assembly {
+ target = 'exe'
+ }
+}
+
+project(':UnityScript') {
+ dependencies {
+ 'default' project(':UnityScript.Lang')
+ ['Boo.Lang.Extensions', 'Boo.Lang.Parser', 'Boo.Lang.Compiler', 'Boo.Lang.PatternMatching', 'Boo.Lang.Useful'].each {
+ 'default' "boo:$it:$booVersion"
+ }
+ }
+}
+
+project(':UnityScript.Lang') {
+ configurations {
+ windowsPhone8
+ }
+ dependencies {
+ 'default' "boo:Boo.Lang:$booVersion"
+ //windowsPhone8 group: 'boo', name: 'Boo.Lang', version: booVersion, configuration: 'windowsPhone8'
+ }
+ tasks.compileWindowsPhone8 {
+ doLast {
+ rootProject.exec {
+ executable rootProject.extensions.unity.monoBleedingEdge.cli
+ args 'lib/Boo/RetargetAssembly.exe'
+ args assemblyFile
+ }
+ }
+ }
+}
+
+project(':UnityScript.Tests.CSharp') {
+ dependencies {
+ 'default' "boo:Boo.Lang:$booVersion"
+ }
+}
+
+project(':UnityScript.Tests') {
+ apply plugin: 'nunit-assembly'
+
+ afterEvaluate {
+ testDefault {
+ exclude 'FailsOnMono'
+ }
+ }
+
+ dependencies {
+ [':UnityScript', ':UnityScript.Lang', ':us', ':UnityScript.Tests.CSharp'].each {
+ 'default' project(it)
+ }
+ }
+}
+
+def allCompileTasks = subprojects.collectMany { it.tasks }.findAll { it.name.startsWith('compile') }
+def booCompileTasks = allCompileTasks.findAll { it.assembly.language == 'boo' }
+booCompileTasks.each {
+ logger.info "Configuring boo dependencies on $it"
+ it.dependsOn rootProject.configurations.boo
+ it.dependsOn rootProject.tasks.updateBoo
+}
+
+task publish {
+ dependsOn configurations['default'].dependencies*.dependencyProject.uploadArchives
+}
+
diff --git a/default.build b/default.build
index 06ca6fd..56edff2 100755
--- a/default.build
+++ b/default.build
@@ -4,21 +4,34 @@
-
+
-
+
+
-
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
@@ -28,7 +41,26 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -61,15 +93,18 @@
-
-
+
-
+
+
+
+
+
@@ -106,9 +141,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -198,20 +186,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100755
index 0000000..7f1e239
Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100755
index 0000000..c14d177
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Thu Sep 27 09:13:56 BRT 2012
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=http\://services.gradle.org/distributions/gradle-1.2-bin.zip
diff --git a/gradlew b/gradlew
new file mode 100755
index 0000000..e61422d
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,164 @@
+#!/bin/bash
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+ echo "$*"
+}
+
+die ( ) {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+esac
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched.
+if $cygwin ; then
+ [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+fi
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/"
+APP_HOME="`pwd -P`"
+cd "$SAVED"
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+ JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100755
index 0000000..aec9973
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/nunit.inc b/nunit.inc
deleted file mode 100644
index d62ab3f..0000000
--- a/nunit.inc
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/refresh-tests.boo b/refresh-tests.boo
index 998350d..5e96518 100755
--- a/refresh-tests.boo
+++ b/refresh-tests.boo
@@ -1,126 +1,91 @@
#!/usr/bin/env booi
"""
Generates test fixtures from files under tests/
+
+First line of test case can specify a nunit attribute to go with it:
+ * "// ignore reason" for [Ignore("reason")]
+ * "// category name" for [Category("name")]
"""
import System
import System.IO
+import Boo.Lang.PatternMatching
-//def MapPath(path):
-// return Path.Combine(Project.BaseDirectory, path)
+def Main():
+ GenerateProjectTestFixture("src/UnityScript.Tests/ProjectIntegrationTestFixture.Generated.boo", """
+namespace UnityScript.Tests
-def GetTestCaseName(fname as string):
- return Path.GetFileNameWithoutExtension(fname).Replace("-", "_")
-
-def WriteTestCases(writer as TextWriter, baseDir as string):
- count = 0
- for fname in Directory.GetFiles(baseDir):
- continue unless fname.EndsWith(".js")
- ++count
- ignoreAttribute = IgnoreAttributeFor(fname)
- writer.Write("""
- [Test]${ignoreAttribute}
- def ${GetTestCaseName(fname)}():
- RunTestCase("${fname.Replace('\\', '/')}")
- """)
- print("${count} test cases found in ${baseDir}.")
-
-def IgnoreAttributeFor(testFile as string):
-"""
-If the first line of the test case file starts with // ignore
-then return a suitable [Ignore()] attribute.
-"""
- m = /\/\/\s*ignore\s+(.*)/.Match(FirstLineOf(testFile))
- if not m.Success: return string.Empty
- reason = m.Groups[1].Value.Trim()
- return """[Ignore("${reason}")]"""
-
-def FirstLineOf(fname as string):
- using reader=File.OpenText(fname):
- return reader.ReadLine()
+import NUnit.Framework
-def GenerateTestFixture(srcDir as string, targetFile as string, header as string):
- contents = GenerateTestFixtureSource(srcDir, header)
- if ShouldReplaceContent(targetFile, contents):
- WriteAllText(targetFile, contents)
-
-def ShouldReplaceContent(fname as string, contents as string):
- if not File.Exists(fname): return true
- return ns(ReadAllText(fname)) != ns(contents)
-
-def ReadAllText(fname as string):
- using reader=File.OpenText(fname):
- return reader.ReadToEnd()
-
-def WriteAllText(fname as string, contents as string):
- using writer=StreamWriter(fname):
- writer.Write(contents)
-
-def ns(s as string):
-"""
-Normalize string.
-"""
- return s.Trim().Replace("\r\n", Environment.NewLine)
-
-def GenerateTestFixtureSource(srcDir as string, header as string):
- writer=StringWriter()
- writer.Write(header)
- WriteTestCases(writer, srcDir)
- return writer.ToString()
+partial class ProjectIntegrationTestFixture:
+""", "tests/projects")
-GenerateTestFixture("tests/parser", "src/UnityScript.Tests/ParserTestFixture.Generated.boo", """
+ GenerateTestFixture("src/UnityScript.Tests/ParserTestFixture.Generated.boo", """
namespace UnityScript.Tests
import NUnit.Framework
partial class ParserTestFixture:
-""")
+""", "tests/parser")
-GenerateTestFixture("tests/semantics", "src/UnityScript.Tests/SemanticsTestFixture.boo", """
+ GenerateTestFixture("src/UnityScript.Tests/SemanticsTestFixture.boo", """
namespace UnityScript.Tests
import NUnit.Framework
[TestFixture]
class SemanticsTestFixture(AbstractSemanticsTestFixture):
-""")
+""", "tests/semantics")
+
+ GenerateTestFixture("src/UnityScript.Tests/StrictIntegrationTestFixture.Generated.boo", """
+namespace UnityScript.Tests
+
+import NUnit.Framework
+
+[TestFixture]
+partial class StrictIntegrationTestFixture(AbstractIntegrationTestFixture):
+
+""", "tests/integration")
-GenerateTestFixture("tests/integration", "src/UnityScript.Tests/IntegrationTestFixture.boo", """
+ GenerateTestFixture("src/UnityScript.Tests/DuckyIntegrationTestFixture.boo", """
namespace UnityScript.Tests
import NUnit.Framework
[TestFixture]
-class IntegrationTestFixture(AbstractIntegrationTestFixture):
-""")
+class DuckyIntegrationTestFixture(AbstractIntegrationTestFixture):
+ override def SetCompilationOptions():
+ super()
+ Parameters.Strict = false
+""", "tests/integration", "tests/ducky")
-GenerateTestFixture("tests/pragma", "src/UnityScript.Tests/PragmaTestFixture.boo", """
+ GenerateTestFixture("src/UnityScript.Tests/PragmaTestFixture.boo", """
namespace UnityScript.Tests
import NUnit.Framework
[TestFixture]
class PragmaTestFixture(AbstractIntegrationTestFixture):
-""")
+""", "tests/pragma")
-GenerateTestFixture("tests/generics", "src/UnityScript.Tests/GenericsTestFixture.Generated.boo", """
+ GenerateTestFixture("src/UnityScript.Tests/GenericsTestFixture.Generated.boo", """
namespace UnityScript.Tests
import NUnit.Framework
[TestFixture]
class GenericsTestFixture(AbstractIntegrationTestFixture):
-""")
+""", "tests/generics")
-GenerateTestFixture("tests/eval", "src/UnityScript.Tests/EvalTestFixture.boo", """
+ GenerateTestFixture("src/UnityScript.Tests/EvalTestFixture.boo", """
namespace UnityScript.Tests
import NUnit.Framework
[TestFixture]
class EvalTestFixture(AbstractIntegrationTestFixture):
-""")
+""", "tests/eval")
-GenerateTestFixture("tests/expando", "src/UnityScript.Tests/ExpandoTestFixture.boo", """
+ GenerateTestFixture("src/UnityScript.Tests/ExpandoTestFixture.boo", """
namespace UnityScript.Tests
import NUnit.Framework
@@ -128,26 +93,92 @@ import NUnit.Framework
[TestFixture]
class ExpandoTestFixture(AbstractIntegrationTestFixture):
- override def CreateCompiler():
- compiler = super()
- compiler.Parameters.Expando = true
- return compiler
-""")
+ override def SetCompilationOptions():
+ super()
+ Parameters.Expando = true
+""", "tests/expando")
-
-GenerateTestFixture("tests/error-messages", "src/UnityScript.Tests/ErrorMessagesTestFixture.Generated.boo", """
+ GenerateTestFixture("src/UnityScript.Tests/ErrorMessagesTestFixture.Generated.boo", """
namespace UnityScript.Tests
import NUnit.Framework
partial class ErrorMessagesTestFixture:
-""")
+""", "tests/error-messages")
-GenerateTestFixture("tests/stacktrace", "src/UnityScript.Tests/StackTraceTestFixture.Generated.boo", """
+ GenerateTestFixture("src/UnityScript.Tests/StackTraceTestFixture.Generated.boo", """
namespace UnityScript.Tests
import NUnit.Framework
partial class StackTraceTestFixture:
-""")
+""", "tests/stacktrace")
+
+def GetTestCaseName(fname as string):
+ return Path.GetFileNameWithoutExtension(fname).Replace("-", "_").Replace(".", "_")
+
+def CategoryAttributeFor(testFile as string):
+"""
+If the first line of the test case file starts with // category CategoryName
+then return a suitable [CategoryName()] attribute.
+"""
+ match FirstLineOf(testFile):
+ case /\/\/\s*ignore\s+(?.*)/:
+ return "[Ignore(\"${reason[0].Value.Trim()}\")]"
+ case /\/\/\s*category\s+(?.*)/:
+ return "[Category(\"${name[0].Value.Trim()}\")]"
+ otherwise:
+ return ""
+
+def FirstLineOf(fname as string):
+ using reader=File.OpenText(fname):
+ return reader.ReadLine()
+
+def GenerateTestFixture(targetFile as string, header as string, *srcDirs as (string)):
+ contents = GenerateTestFixtureSource(header, srcDirs, JavascriptFilesIn, CategoryAttributeFor)
+ WriteFileIfChanged(targetFile, contents)
+
+def GenerateProjectTestFixture(targetFile as string, header as string, *srcDirs as (string)):
+ contents = GenerateTestFixtureSource(header, srcDirs, { dir | Directory.GetDirectories(dir) }, { dir | "" })
+ WriteFileIfChanged(targetFile, contents)
+
+def WriteFileIfChanged(targetFile as string, contents as string):
+ if ShouldReplaceContent(targetFile, contents):
+ File.WriteAllText(targetFile, contents)
+
+def ShouldReplaceContent(fname as string, contents as string):
+ if not File.Exists(fname): return true
+ return ns(File.ReadAllText(fname)) != ns(contents)
+
+def ns(s as string):
+"""
+Normalize string.
+"""
+ return s.Trim().Replace("\r\n", Environment.NewLine)
+
+def GenerateTestFixtureSource(
+ header as string,
+ srcDirs as string*,
+ testCaseProducer as callable(string) as string*,
+ categoryProducer as callable(string) as string):
+
+ writer=StringWriter()
+ writer.Write(header)
+ for srcDir in srcDirs:
+ count = 0
+ for testCase in testCaseProducer(srcDir):
+ ++count
+ categoryAttribute = categoryProducer(testCase)
+ writer.Write("""
+ $categoryAttribute
+ [Test] def ${GetTestCaseName(testCase)}():
+ RunTestCase("${testCase.Replace('\\', '/')}")
+ """)
+ print "\t$count test cases found in $srcDir."
+ return writer.ToString()
+
+def JavascriptFilesIn(dir as string):
+ jsFiles = array(fname for fname in Directory.GetFiles(dir) if fname.EndsWith(".js"))
+ Array.Sort(jsFiles, StringComparer.Ordinal)
+ return jsFiles
diff --git a/resources/function-call-performance.js b/resources/function-call-performance.js
index 8323d30..c4ea3d5 100755
--- a/resources/function-call-performance.js
+++ b/resources/function-call-performance.js
@@ -2,12 +2,12 @@ import System;
class Foo {
public var counter = 0;
- function Bar() { ++counter; }
+ final function Bar() { ++counter; }
}
class VirtualFoo {
public var counter = 0;
- virtual function Bar() { ++counter; }
+ function Bar() { ++counter; }
}
class VirtualFoo2 extends VirtualFoo {
diff --git a/run b/run
index e0c9ee5..c2251b7 100755
--- a/run
+++ b/run
@@ -1,2 +1,2 @@
#!/bin/sh
-mono --debug bin/us.exe -x -verbose -t:library -r:bin/UnityScript.Tests.CSharp.dll -r:bin/UnityScript.Tests.dll -b:UnityScript.Tests.MonoBehaviour -m:Awake "$@"
+mono --debug bin/us.exe -x -t:library -r:bin/UnityScript.Tests.CSharp.dll -r:bin/UnityScript.Tests.dll -b:UnityScript.Tests.MonoBehaviour -m:Awake "$@"
diff --git a/settings.gradle b/settings.gradle
new file mode 100755
index 0000000..be6b57e
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1,12 @@
+rootProject.name = 'bundle'
+
+def srcDir = file('src')
+srcDir.listFiles({ it.isDirectory() } as FileFilter).each {
+ settings.include it.name
+}
+
+rootProject.children.each {
+ it.projectDir = new File(srcDir, it.name)
+ it.buildFileName = "${it.name}.gradle"
+}
+
diff --git a/src/UnityScript.Lang/Array.boo b/src/UnityScript.Lang/Array.boo
index a27bd7f..baa6f01 100755
--- a/src/UnityScript.Lang/Array.boo
+++ b/src/UnityScript.Lang/Array.boo
@@ -84,11 +84,11 @@ class Array(CollectionBase, Boo.Lang.Runtime.ICoercible):
# How do i allow the vararg only for ICollections?
def Concat(value as ICollection, *items):
- return ConcatImpl(value, items);
-
+ return ConcatImpl(value, items)
+
# How do i allow the vararg only for ICollections?
def concat(value as ICollection, *items):
- return ConcatImpl(value, items);
+ return ConcatImpl(value, items)
# Pop last and return
def Pop():
@@ -119,10 +119,12 @@ class Array(CollectionBase, Boo.Lang.Runtime.ICoercible):
# Returns array with elements removed
def Slice(start as int, end as int):
- return Array(InnerList.GetRange(start, end - start));
+ normalStart = NormalizeIndex(start)
+ normalEnd = NormalizeIndex(end)
+ return Array(InnerList.GetRange(normalStart, normalEnd - normalStart))
def Slice(start as int):
- return self.Slice(start, self.InnerList.Count - start);
+ return self.Slice(start, self.InnerList.Count)
def slice(start as int, end as int):
return self.Slice(start, end)
@@ -132,7 +134,7 @@ class Array(CollectionBase, Boo.Lang.Runtime.ICoercible):
# Revert
def Reverse() as Array:
- self.InnerList.Reverse();
+ self.InnerList.Reverse()
return self
def reverse() as Array:
@@ -209,8 +211,8 @@ class Array(CollectionBase, Boo.Lang.Runtime.ICoercible):
self.InnerList.InsertRange(index, items)
private def ConcatImpl(value as ICollection, [required] items as IEnumerable):
- arr = Array (self.InnerList);
- arr.InnerList.AddRange(value);
+ arr = Array (self.InnerList)
+ arr.InnerList.AddRange(value)
for item as ICollection in items:
arr.InnerList.AddRange(item)
@@ -221,3 +223,7 @@ class Array(CollectionBase, Boo.Lang.Runtime.ICoercible):
return if capacity < Count
for i in range(capacity-self.Count):
InnerList.Add(null)
+
+ private def NormalizeIndex(index as int):
+ return index if index >= 0
+ return index + InnerList.Count
diff --git a/src/UnityScript.Lang/ExpandoServices.boo b/src/UnityScript.Lang/ExpandoServices.boo
index db5309b..91dfbab 100755
--- a/src/UnityScript.Lang/ExpandoServices.boo
+++ b/src/UnityScript.Lang/ExpandoServices.boo
@@ -1,12 +1,12 @@
namespace UnityScript.Lang
import System
-import System.Collections
+import System.Collections.Generic
internal class Expando:
_target as WeakReference
- _attributes = Hashtable()
+ _attributes = Dictionary[of string, object]()
def constructor(target):
_target = WeakReference(target)
@@ -14,9 +14,8 @@ internal class Expando:
Target:
get: return _target.Target
- Item[key]:
- get:
- return _attributes[key]
+ Item[key as string]:
+ get: return _attributes[key]
set:
if value is null:
@@ -26,7 +25,7 @@ internal class Expando:
static class ExpandoServices:
- _expandos = List()
+ _expandos = List[of Expando]()
def GetExpandoProperty(target, name as string):
expando = GetExpandoFor(target)
diff --git a/src/UnityScript.Lang/Extensions.boo b/src/UnityScript.Lang/Extensions.boo
old mode 100644
new mode 100755
index 1a15099..cfdfe98
--- a/src/UnityScript.Lang/Extensions.boo
+++ b/src/UnityScript.Lang/Extensions.boo
@@ -1,33 +1,31 @@
namespace UnityScript.Lang
-class Extensions:
+static class Extensions:
[Extension]
- static def op_Equality(lhs as System.Char, rhs as System.String):
+ def op_Equality(lhs as System.Char, rhs as System.String):
return 1 == len(rhs) and lhs == rhs[0]
[Extension]
- static def op_Equality(lhs as System.String, rhs as System.Char):
+ def op_Equality(lhs as System.String, rhs as System.Char):
return rhs == lhs
[Extension]
- static def op_Inequality(lhs as System.Char, rhs as System.String):
+ def op_Inequality(lhs as System.Char, rhs as System.String):
return 1 != len(rhs) or lhs != rhs[0]
[Extension]
- static def op_Inequality(lhs as System.String, rhs as System.Char):
+ def op_Inequality(lhs as System.String, rhs as System.Char):
return rhs != lhs
[Extension]
- static length[a as System.Array]:
- get:
- return a.Length
+ length[a as System.Array]:
+ get: return a.Length
[Extension]
- static length[s as string]:
- get:
- return s.Length
+ length[s as string]:
+ get: return s.Length
[Extension]
- static def op_Implicit(e as System.Enum) as bool:
- return cast(System.IConvertible, e).ToInt32(null) != 0
+ def op_Implicit(e as System.Enum) as bool:
+ return (e cast System.IConvertible).ToInt32(null) != 0
diff --git a/src/UnityScript.Lang/UnityBuiltins.boo b/src/UnityScript.Lang/UnityBuiltins.boo
index 3f626a1..65878c0 100755
--- a/src/UnityScript.Lang/UnityBuiltins.boo
+++ b/src/UnityScript.Lang/UnityBuiltins.boo
@@ -1,24 +1,30 @@
namespace UnityScript.Lang
-class UnityBuiltins:
+static class UnityBuiltins:
- static def eval(code as string):
- return null
+ def eval(code as string) as object:
+ raise System.NotImplementedException()
- static def parseInt (value as System.String) as int:
+ def parseInt (value as System.String) as int:
return int.Parse(value)
- static def parseInt (value as single) as int:
+ def parseInt (value as single) as int:
+ return value
+
+ def parseInt (value as double) as int:
return value
- static def parseInt (value as int) as int:
+ def parseInt (value as int) as int:
return value
- static def parseFloat (value as System.String) as single:
+ def parseFloat (value as System.String) as single:
return single.Parse(value)
- static def parseFloat (value as single) as single:
+ def parseFloat (value as single) as single:
+ return value
+
+ def parseFloat (value as double) as single:
return value
- static def parseFloat (value as int) as single:
+ def parseFloat (value as int) as single:
return value
diff --git a/src/UnityScript.Lang/UnityRuntimeServices.boo b/src/UnityScript.Lang/UnityRuntimeServices.boo
index 66ac733..fc6636d 100755
--- a/src/UnityScript.Lang/UnityRuntimeServices.boo
+++ b/src/UnityScript.Lang/UnityRuntimeServices.boo
@@ -55,9 +55,12 @@ class UnityRuntimeServices:
return true
static def GetEnumerator(obj) as System.Collections.IEnumerator:
- if obj is null: return (,).GetEnumerator()
- if IsValueTypeArray(obj) or obj isa UnityScript.Lang.Array:
- return ListUpdateableEnumerator(obj)
+ if obj is null: return EmptyEnumerator
+ if IsValueTypeArray(obj) or obj isa UnityScript.Lang.Array: return ListUpdateableEnumerator(obj)
+ #require for proper linq support as linq enumerables also implement IEnumerator
+ #but fail to enumerate if accessed as IEnumerator
+ enumerable = obj as System.Collections.IEnumerable
+ if enumerable is not null: return enumerable.GetEnumerator()
enumerator = obj as System.Collections.IEnumerator
if enumerator is not null: return enumerator
return Boo.Lang.Runtime.RuntimeServices.GetEnumerable(obj).GetEnumerator()
diff --git a/src/UnityScript.Lang/UnityScript.Lang.booproj b/src/UnityScript.Lang/UnityScript.Lang.booproj
index 9702cae..0c11462 100755
--- a/src/UnityScript.Lang/UnityScript.Lang.booproj
+++ b/src/UnityScript.Lang/UnityScript.Lang.booproj
@@ -1 +1,47 @@
-
Debug
AnyCPU
9.0.21022
2.0
{2784E7F4-5206-4BF9-99CD-96B1D94D0E19}
Library
UnityScript.Lang
false
UnityScript.Lang
v3.5
true
full
bin\Debug
prompt
false
false
none
bin\Release
prompt
false
false
\ No newline at end of file
+
+
+
+ Debug
+ AnyCPU
+ 9.0.21022
+ 2.0
+ {2784E7F4-5206-4BF9-99CD-96B1D94D0E19}
+ Library
+ UnityScript.Lang
+ false
+ UnityScript.Lang
+ v3.5
+
+
+ true
+ full
+ bin\Debug
+ prompt
+ false
+
+ false
+ false
+
+
+ none
+ bin\Release
+ prompt
+ false
+
+ false
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/UnityScript.MonoDevelop/.monolipse b/src/UnityScript.MonoDevelop/.monolipse
deleted file mode 100644
index 9aa3d35..0000000
--- a/src/UnityScript.MonoDevelop/.monolipse
+++ /dev/null
@@ -1,29 +0,0 @@
-
- boo
- library
-
-
- /UnityScript/src/UnityScript.Lang
-
-
- /UnityScript/src/UnityScript
-
-
- /MonoDevelop/bin/MonoDevelop.Core.dll
-
-
- /MonoDevelop/bin/MonoDevelop.Ide.dll
-
-
- /MonoDevelop/bin/MonoDevelop.Projects.dll
-
-
- /MonoDevelop/bin/Mono.TextEditor.dll
-
-
- /MonoDevelop/AddIns/MonoDevelop.SourceEditor2.dll
-
-
- /UnityScript/bin
-
-
\ No newline at end of file
diff --git a/src/UnityScript.MonoDevelop/CommandHandlers/withAtomicUndoOn.boo b/src/UnityScript.MonoDevelop/CommandHandlers/withAtomicUndoOn.boo
deleted file mode 100644
index 21b8728..0000000
--- a/src/UnityScript.MonoDevelop/CommandHandlers/withAtomicUndoOn.boo
+++ /dev/null
@@ -1,14 +0,0 @@
-namespace UnityScript.MonoDevelop.CommandHandlers
-
-import Boo.Lang.Compiler
-import Boo.Lang.Compiler.Ast
-import Boo.Lang.PatternMatching
-
-macro withAtomicUndoOn(buffer as Expression):
- yield [| $buffer.BeginAtomicUndo() |]
- yield [|
- try:
- $(withAtomicUndoOn.Body)
- ensure:
- $buffer.EndAtomicUndo()
- |]
diff --git a/src/UnityScript.MonoDevelop/Completion/CompletionFinder.boo b/src/UnityScript.MonoDevelop/Completion/CompletionFinder.boo
deleted file mode 100644
index 2264b5b..0000000
--- a/src/UnityScript.MonoDevelop/Completion/CompletionFinder.boo
+++ /dev/null
@@ -1,29 +0,0 @@
-namespace UnityScript.MonoDevelop.Completion
-
-import UnityScript
-
-import Boo.Lang.Compiler
-import Boo.Lang.Compiler.Steps
-import Boo.Lang.Compiler.Ast
-import Boo.Lang.Compiler.IO
-import Boo.Lang.Compiler.TypeSystem
-
-class CompletionFinder(DepthFirstVisitor):
-
- public static final CompletionToken = "__complete_me__"
-
- _type as IType
-
- def FindCompletionTypeFor(node as Node):
- VisitAllowingCancellation(node)
- return _type
-
- override def LeaveMemberReferenceExpression(node as MemberReferenceExpression):
- if node.Name != CompletionToken:
- return
-
- Found(node.Target.ExpressionType)
-
- protected def Found(type):
- _type = type
- Cancel()
\ No newline at end of file
diff --git a/src/UnityScript.MonoDevelop/Completion/ResolveMonoBehaviourType.boo b/src/UnityScript.MonoDevelop/Completion/ResolveMonoBehaviourType.boo
deleted file mode 100644
index 1dc8a8c..0000000
--- a/src/UnityScript.MonoDevelop/Completion/ResolveMonoBehaviourType.boo
+++ /dev/null
@@ -1,23 +0,0 @@
-namespace UnityScript.MonoDevelop.Completion
-
-import UnityScript
-
-import Boo.Lang.Compiler
-import Boo.Lang.Compiler.Steps
-import Boo.Lang.Compiler.Ast
-import Boo.Lang.Compiler.IO
-import Boo.Lang.Compiler.TypeSystem
-
-class ResolveMonoBehaviourType(AbstractCompilerStep):
- override def Run():
- type = FindReferencedType("UnityEngine.MonoBehaviour")
- (Parameters as UnityScriptCompilerParameters).ScriptBaseType = type or object
-
- def FindReferencedType(typeName as string):
- for reference in Parameters.References:
- assemblyRef = reference as Boo.Lang.Compiler.TypeSystem.Reflection.IAssemblyReference
- if assemblyRef is null:
- continue
- type = assemblyRef.Assembly.GetType(typeName)
- if type is not null:
- return type
diff --git a/src/UnityScript.MonoDevelop/Completion/UnityScriptEditorCompletion.boo b/src/UnityScript.MonoDevelop/Completion/UnityScriptEditorCompletion.boo
deleted file mode 100644
index 2d6bae3..0000000
--- a/src/UnityScript.MonoDevelop/Completion/UnityScriptEditorCompletion.boo
+++ /dev/null
@@ -1,158 +0,0 @@
-namespace UnityScript.MonoDevelop.Completion
-
-import System
-import System.Collections.Generic
-
-import UnityScript
-import UnityScript.MonoDevelop
-import UnityScript.MonoDevelop.ProjectModel
-
-import MonoDevelop.Core
-import MonoDevelop.Projects
-import MonoDevelop.Projects.Dom.Parser
-import MonoDevelop.Ide.Gui
-import MonoDevelop.Ide.Gui.Content
-import MonoDevelop.Ide.CodeCompletion
-
-import Boo.Lang.Compiler
-import Boo.Lang.Compiler.Steps
-import Boo.Lang.Compiler.Ast
-import Boo.Lang.Compiler.IO
-import Boo.Lang.Compiler.TypeSystem
-import Boo.Lang.PatternMatching
-
-class UnityScriptEditorCompletion(CompletionTextEditorExtension):
-
- _dom as ProjectDom
- _resolver as UnityScriptTypeResolver
- _project as DotNetProject
-
- override def Initialize():
- super()
- _dom = ProjectDomService.GetProjectDom(Document.Project) or ProjectDomService.GetFileDom(Document.FileName)
- InstallUnityScriptSyntaxModeIfNeeded()
- _resolver = UnityScriptTypeResolver()
- _project = Document.Project as DotNetProject
- InitializeProjectReferences()
-
- def InitializeProjectReferences():
- if _project is null:
- return
-
- for reference in _project.References:
- if ReferenceType.Project != reference.ReferenceType:
- _resolver.AddReference(reference.Reference)
-
- def InstallUnityScriptSyntaxModeIfNeeded():
- view = Document.GetContent[of MonoDevelop.SourceEditor.SourceEditorView]()
- return if view is null
-
- mimeType = UnityScriptParser.MimeType
- return if view.Document.SyntaxMode.MimeType == mimeType
-
- mode = Mono.TextEditor.Highlighting.SyntaxModeService.GetSyntaxMode(mimeType)
- if mode is not null:
- view.Document.SyntaxMode = mode
- else:
- LoggingService.LogWarning(GetType() + " could not get SyntaxMode for mimetype '" + mimeType + "'.")
-
- override def ExtendsEditor(doc as MonoDevelop.Ide.Gui.Document, editor as IEditableTextBuffer):
- return IsUnityScriptFile(doc.Name)
-
- override def HandleCodeCompletion(context as CodeCompletionContext, completionChar as char):
-# print "HandleCodeCompletion(${context.ToString()}, ${completionChar.ToString()})"
-
- match completionChar.ToString():
- case ' ':
- lineText = GetLineText(context.TriggerLine).TrimStart()
- if not lineText.StartsWith("import "):
- return null
-
- return ImportCompletionDataFor('')
-
- case '.':
- lineText = GetLineText(context.TriggerLine)
- lineLength = lineText.Length
- lineText = lineText.TrimStart()
- trimmedLength = lineLength - lineText.Length
- if lineText.StartsWith("import "):
- nameSpace = lineText[len("import "):context.TriggerLineOffset-(2+trimmedLength)].Trim()
- return ImportCompletionDataFor(nameSpace)
-
- result = null as CompletionDataList
- text = string.Format ("{0}{1} {2}", Document.TextEditor.GetText (0, context.TriggerOffset),
- CompletionFinder.CompletionToken,
- Document.TextEditor.GetText (context.TriggerOffset, Document.TextEditor.TextLength))
- # print text
- _resolver.Input.Clear()
- _resolver.Input.Add(StringInput("completion text", text))
-
- result = CompletionDataList()
- resultHash = Dictionary[of string,string]()
-
- _resolver.ResolveAnd() do (type as IType):
- # print type
- domType = _dom.GetType(type.FullName)
- if (null != domType):
- for member in domType.Members:
- resultHash[SanitizeMemberName(type,member.Name)] = member.StockIcon
- else:
- for member in type.GetMembers():
- # print member
- resultHash[SanitizeMemberName(type,member.Name)] = GetIconForMember(member)
-
- for pair in resultHash:
- valid = not string.IsNullOrEmpty(pair.Key)
- for prefix as string in ["get_","set_","add_","remove_"]:
- if (pair.Key.StartsWith(prefix, StringComparison.Ordinal) and \
- resultHash.ContainsKey(pair.Key[prefix.Length:])):
- valid = false
- if (valid):
- result.Add(pair.Key, pair.Value)
-
- return result
-
- otherwise:
- return null
-
- def ImportCompletionDataFor(nameSpace as string):
-# print "ImportCompletionDataFor(${nameSpace})"
-
- result = CompletionDataList()
- for member in _dom.GetNamespaceContents(nameSpace, true, true):
- result.Add(member.Name, member.StockIcon)
- return result
-
- def GetLineText(line as int):
- return Document.TextEditor.GetLineText(line)
-
-
- def GetIconForMember(member as IEntity):
- match member.EntityType:
- case EntityType.BuiltinFunction:
- return Stock.Method
- case EntityType.Constructor:
- return Stock.Method
- case EntityType.Method:
- return Stock.Method
- case EntityType.Local:
- return Stock.Field
- case EntityType.Field:
- return Stock.Field
- case EntityType.Property:
- return Stock.Property
- case EntityType.Event:
- return Stock.Event
- otherwise:
- return Stock.Literal
-
- def SanitizeMemberName(type as IType,memberName as string) as string:
- name = memberName
- if (0 <= (lastDot = name.LastIndexOf('.'))):
- name = name[lastDot+1:]
- if ("constructor" == name or "ctor" == name):
- name = type.Name
- if (name.StartsWith("internal_", StringComparison.OrdinalIgnoreCase) or name.StartsWith("op_", StringComparison.Ordinal)):
- name = string.Empty
- return name
-
diff --git a/src/UnityScript.MonoDevelop/Completion/UnityScriptEditorCompletion.boo.orig b/src/UnityScript.MonoDevelop/Completion/UnityScriptEditorCompletion.boo.orig
deleted file mode 100644
index 330543e..0000000
--- a/src/UnityScript.MonoDevelop/Completion/UnityScriptEditorCompletion.boo.orig
+++ /dev/null
@@ -1,110 +0,0 @@
-namespace UnityScript.MonoDevelop.Completion
-
-import System.Collections.Generic
-
-import UnityScript
-import UnityScript.MonoDevelop
-import UnityScript.MonoDevelop.ProjectModel
-
-import MonoDevelop.Core
-import MonoDevelop.Projects
-import MonoDevelop.Projects.Dom.Parser
-import MonoDevelop.Ide.Gui.Content
-import MonoDevelop.Ide.CodeCompletion
-
-import Boo.Lang.Compiler
-import Boo.Lang.Compiler.Steps
-import Boo.Lang.Compiler.Ast
-import Boo.Lang.Compiler.IO
-import Boo.Lang.Compiler.TypeSystem
-import Boo.Lang.PatternMatching
-
-class UnityScriptEditorCompletion(CompletionTextEditorExtension):
-
- _dom as ProjectDom
- _resolver as UnityScriptTypeResolver
- _project as DotNetProject
-
- override def Initialize():
- super()
- _dom = ProjectDomService.GetProjectDom(Document.Project) or ProjectDomService.GetFileDom(Document.FileName)
- InstallUnityScriptSyntaxModeIfNeeded()
- _resolver = UnityScriptTypeResolver()
- _project = Document.Project as DotNetProject
- for reference in _project.References:
- if ReferenceType.Project != reference.ReferenceType:
- _resolver.AddReference(reference.Reference)
-
- def InstallUnityScriptSyntaxModeIfNeeded():
- view = Document.GetContent[of MonoDevelop.SourceEditor.SourceEditorView]()
- return if view is null
-
- mimeType = UnityScriptParser.MimeType
- return if view.Document.SyntaxMode.MimeType == mimeType
-
- mode = Mono.TextEditor.Highlighting.SyntaxModeService.GetSyntaxMode(mimeType)
- if mode is not null:
- view.Document.SyntaxMode = mode
- else:
- LoggingService.LogWarning(GetType() + " could not get SyntaxMode for mimetype '" + mimeType + "'.")
-
- override def ExtendsEditor(doc as MonoDevelop.Ide.Gui.Document, editor as IEditableTextBuffer):
- return IsUnityScriptFile(doc.Name)
-
- override def HandleCodeCompletion(context as CodeCompletionContext, completionChar as char):
-# print "HandleCodeCompletion(${context.ToString()}, ${completionChar.ToString()})"
-
- match completionChar.ToString():
- case ' ':
- lineText = GetLineText(context.TriggerLine)
- if not lineText.StartsWith("import "):
- return null
-
- return ImportCompletionDataFor('')
-
- case '.':
- # lineText = GetLineText(context.TriggerLine)
- # if not lineText.StartsWith("import "):
- # return null
-
- # nameSpace = lineText[len("import "):context.TriggerLineOffset-2].Trim()
- # return ImportCompletionDataFor(nameSpace)
- result = null as CompletionDataList
- text = string.Format ("{0}{1} {2}", Document.TextEditor.GetText (0, context.TriggerOffset),
- CompletionFinder.CompletionToken,
- Document.TextEditor.GetText (context.TriggerOffset, Document.TextEditor.TextLength))
- print text
- _resolver.Input.Clear()
- _resolver.Input.Add(StringInput("completion text", text))
-
- ast = _resolver.Run()
- print ast.ToCodeString()
-
- finder = CompletionFinder()
- type = finder.FindCompletionTypeFor(ast)
- print type
- if (null != type):
- result = CompletionDataList()
- resultHash = Dictionary[of string,string]()
- for member in type.GetMembers():
- print member
- resultHash[member.Name] = member.Name
- result.AddRange(resultHash.Keys)
-
- return result
-
- otherwise:
- return null
-
- def ImportCompletionDataFor(nameSpace as string):
-# print "ImportCompletionDataFor(${nameSpace})"
-
- result = CompletionDataList()
- for member in _dom.GetNamespaceContents(nameSpace, true, true):
- result.Add(member.Name, member.StockIcon)
- return result
-
- def GetLineText(line as int):
- return Document.TextEditor.GetLineText(line)
-
-
\ No newline at end of file
diff --git a/src/UnityScript.MonoDevelop/Completion/UnityScriptEditorCompletion.boo.rej b/src/UnityScript.MonoDevelop/Completion/UnityScriptEditorCompletion.boo.rej
deleted file mode 100644
index e7cc541..0000000
--- a/src/UnityScript.MonoDevelop/Completion/UnityScriptEditorCompletion.boo.rej
+++ /dev/null
@@ -1,18 +0,0 @@
-***************
-*** 31,36 ****
- InstallUnityScriptSyntaxModeIfNeeded()
- _resolver = UnityScriptTypeResolver()
- _project = Document.Project as DotNetProject
-
- def InstallUnityScriptSyntaxModeIfNeeded():
- view = Document.GetContent[of MonoDevelop.SourceEditor.SourceEditorView]()
---- 32,40 ----
- InstallUnityScriptSyntaxModeIfNeeded()
- _resolver = UnityScriptTypeResolver()
- _project = Document.Project as DotNetProject
-+ for reference in _project.References:
-+ if ReferenceType.Project != reference.ReferenceType:
-+ _resolver.AddReference(reference.Reference)
-
- def InstallUnityScriptSyntaxModeIfNeeded():
- view = Document.GetContent[of MonoDevelop.SourceEditor.SourceEditorView]()
diff --git a/src/UnityScript.MonoDevelop/Completion/UnityScriptTypeResolver.boo b/src/UnityScript.MonoDevelop/Completion/UnityScriptTypeResolver.boo
deleted file mode 100644
index daab522..0000000
--- a/src/UnityScript.MonoDevelop/Completion/UnityScriptTypeResolver.boo
+++ /dev/null
@@ -1,55 +0,0 @@
-namespace UnityScript.MonoDevelop.Completion
-
-import UnityScript
-
-import System
-
-import Boo.Lang.Environments
-import Boo.Lang.Compiler
-import Boo.Lang.Compiler.Steps
-import Boo.Lang.Compiler.Ast
-import Boo.Lang.Compiler.IO
-import Boo.Lang.Compiler.TypeSystem
-
-class UnityScriptTypeResolver:
-
- _compiler = UnityScriptCompiler()
-
- def constructor():
- pipeline = UnityScriptCompiler.Pipelines.AdjustBooPipeline(Boo.Lang.Compiler.Pipelines.Compile())
- pipeline.InsertAfter(UnityScript.Steps.Parse, ResolveMonoBehaviourType())
- pipeline.BreakOnErrors = false
-
- _compiler.Parameters.ScriptMainMethod = "Awake"
- _compiler.Parameters.Pipeline = pipeline
- imports = _compiler.Parameters.Imports
- imports.Add("UnityEngine")
- imports.Add("System.Collections")
-
- Input:
- get: return Parameters.Input
-
- References:
- get: return Parameters.References
-
- Parameters:
- private get: return _compiler.Parameters
-
- def AddReference(reference as string):
- References.Add(Parameters.LoadAssembly(reference, true))
-
- def ResolveAnd(action as Action of IType):
- context = _compiler.Run()
- #DumpErrors(context.Errors)
-
- Environments.With(context) do:
- finder = CompletionFinder()
- type = finder.FindCompletionTypeFor(context.CompileUnit)
- if type is null:
- return
- action(type)
-
- private def DumpErrors(errors as CompilerErrorCollection):
- for error in errors:
- print error
-
\ No newline at end of file
diff --git a/src/UnityScript.MonoDevelop/Icons/UnityScriptFile128.png b/src/UnityScript.MonoDevelop/Icons/UnityScriptFile128.png
deleted file mode 100644
index 599c4ed..0000000
Binary files a/src/UnityScript.MonoDevelop/Icons/UnityScriptFile128.png and /dev/null differ
diff --git a/src/UnityScript.MonoDevelop/Icons/UnityScriptFile32.png b/src/UnityScript.MonoDevelop/Icons/UnityScriptFile32.png
deleted file mode 100644
index fda9a0d..0000000
Binary files a/src/UnityScript.MonoDevelop/Icons/UnityScriptFile32.png and /dev/null differ
diff --git a/src/UnityScript.MonoDevelop/Icons/UnityScriptProject.png b/src/UnityScript.MonoDevelop/Icons/UnityScriptProject.png
deleted file mode 100644
index 7d1690d..0000000
Binary files a/src/UnityScript.MonoDevelop/Icons/UnityScriptProject.png and /dev/null differ
diff --git a/src/UnityScript.MonoDevelop/Icons/UnityScriptProject32.png b/src/UnityScript.MonoDevelop/Icons/UnityScriptProject32.png
deleted file mode 100644
index 4a3d2b4..0000000
Binary files a/src/UnityScript.MonoDevelop/Icons/UnityScriptProject32.png and /dev/null differ
diff --git a/src/UnityScript.MonoDevelop/ProjectModel/DomConversionVisitor.boo b/src/UnityScript.MonoDevelop/ProjectModel/DomConversionVisitor.boo
deleted file mode 100644
index 6ee0dfd..0000000
--- a/src/UnityScript.MonoDevelop/ProjectModel/DomConversionVisitor.boo
+++ /dev/null
@@ -1,244 +0,0 @@
-namespace UnityScript.MonoDevelop.ProjectModel
-
-import Boo.Lang.Compiler.Ast
-import MonoDevelop.Projects.Dom as MD
-import Boo.Lang.PatternMatching
-
-class DomConversionVisitor(DepthFirstVisitor):
-
- _result as MD.CompilationUnit
- _currentType as MD.DomType
- _namespace as string
-
- def constructor(result as MD.CompilationUnit):
- _result = result
-
- override def OnModule(node as Module):
- _namespace = null
- Visit(node.Namespace)
- Visit(node.Members)
-
- override def OnNamespaceDeclaration(node as NamespaceDeclaration):
- _namespace = node.Name
- region = BodyRegionOf(node.ParentNode)
- domUsing = MD.DomUsing(IsFromNamespace: true, Region: region)
- domUsing.Add(_namespace)
- _result.Add(domUsing)
-
- override def OnImport(node as Import):
- region = BodyRegionOf(node)
- domUsing = MD.DomUsing(Region: region)
- domUsing.Add(node.Namespace)
- _result.Add(domUsing)
-
- override def OnClassDefinition(node as ClassDefinition):
- OnTypeDefinition(node, MD.ClassType.Class)
-
- override def OnInterfaceDefinition(node as InterfaceDefinition):
- OnTypeDefinition(node, MD.ClassType.Interface)
-
- override def OnStructDefinition(node as StructDefinition):
- OnTypeDefinition(node, MD.ClassType.Struct)
-
- override def OnEnumDefinition(node as EnumDefinition):
- OnTypeDefinition(node, MD.ClassType.Enum)
-
- def OnTypeDefinition(node as TypeDefinition, classType as MD.ClassType):
- converted = MD.DomType(
- Name: node.Name,
- ClassType: classType,
- Location: LocationOf(node),
- BodyRegion: BodyRegionOf(node),
- DeclaringType: _currentType,
- Modifiers: ModifiersFrom(node))
-
- WithCurrentType converted:
- Visit(node.Members)
-
- AddType(converted)
-
- override def OnCallableDefinition(node as CallableDefinition):
- parameters = System.Collections.Generic.List[of MD.IParameter]()
- for p in node.Parameters: parameters.Add(ParameterFrom(null, p))
-
- converted = MD.DomType.CreateDelegate(_result, node.Name, LocationOf(node), ReturnTypeFrom(node.ReturnType), parameters)
- converted.Modifiers = ModifiersFrom(node)
- converted.DeclaringType = _currentType
- converted.BodyRegion = BodyRegionOf(node)
-
- for p in parameters: p.DeclaringMember = converted
-
- AddType(converted)
-
- override def OnField(node as Field):
- if _currentType is null: return
-
- _currentType.Add(MD.DomField(
- Name: node.Name,
- ReturnType: ParameterTypeFrom(node.Type),
- Location: LocationOf(node),
- BodyRegion: BodyRegionOf(node),
- DeclaringType: _currentType,
- Modifiers: ModifiersFrom(node)))
-
- override def OnProperty(node as Property):
- if _currentType is null: return
-
- converted = MD.DomProperty(
- Name: node.Name,
- ReturnType: ParameterTypeFrom(node.Type),
- Location: LocationOf(node),
- BodyRegion: BodyRegionOf(node),
- DeclaringType: _currentType,
- Modifiers: ModifiersFrom(node))
- if node.Getter is not null:
- converted.PropertyModifier |= MD.PropertyModifier.HasGet
- converted.GetRegion = BodyRegionOf(node.Getter)
- if node.Setter is not null:
- converted.PropertyModifier |= MD.PropertyModifier.HasSet
- converted.SetRegion = BodyRegionOf(node.Setter)
-
- _currentType.Add(converted)
-
- override def OnEnumMember(node as EnumMember):
- if _currentType is null: return
-
- _currentType.Add(MD.DomField(
- Name: node.Name,
- ReturnType: MD.DomReturnType(_currentType),
- Location: LocationOf(node),
- DeclaringType: _currentType,
- Modifiers: MD.Modifiers.Public | MD.Modifiers.Static | MD.Modifiers.Final))
-
- override def OnConstructor(node as Constructor):
- OnMethod(node, MD.MethodModifier.IsConstructor)
-
- override def OnDestructor(node as Destructor):
- OnMethod(node, MD.MethodModifier.IsFinalizer)
-
- override def OnMethod(node as Method):
- OnMethod(node, MD.MethodModifier.None)
-
- def OnMethod(node as Method, methodModifier as MD.MethodModifier):
- if _currentType is null: return
-
- converted = MD.DomMethod(
- Name: node.Name,
- Location: LocationOf(node),
- BodyRegion: BodyRegionOf(node),
- DeclaringType: _currentType,
- ReturnType: (MethodReturnTypeFrom(node) if IsRegularMethod(methodModifier) else null),
- Modifiers: ModifiersFrom(node),
- MethodModifier: methodModifier)
-
- for parameter in node.Parameters:
- converted.Add(ParameterFrom(converted, parameter))
-
- _currentType.Add(converted)
-
- def IsRegularMethod(modifier as MD.MethodModifier):
- match modifier:
- case MD.MethodModifier.IsConstructor | MD.MethodModifier.IsFinalizer:
- return false
- otherwise:
- return true
-
- def ModifiersFrom(node as TypeMember):
- modifiers = MD.Modifiers.None
- modifiers |= MD.Modifiers.Public if node.IsPublic
- modifiers |= MD.Modifiers.Private if node.IsPrivate
- modifiers |= MD.Modifiers.Protected if node.IsProtected
- modifiers |= MD.Modifiers.Internal if node.IsInternal
- modifiers |= MD.Modifiers.Static if node.IsStatic
- modifiers |= MD.Modifiers.Virtual if node.IsVirtual
- modifiers |= MD.Modifiers.Abstract if node.IsAbstract
- modifiers |= MD.Modifiers.Override if node.IsOverride
- modifiers |= MD.Modifiers.Final if node.IsFinal
- return modifiers
-
- def ParameterFrom(declaringMember as MD.IMember, parameter as ParameterDeclaration):
- return MD.DomParameter(
- DeclaringMember: declaringMember,
- Name: parameter.Name,
- ReturnType: ParameterTypeFrom(parameter.Type),
- Location: LocationOf(parameter))
-
- virtual def MethodReturnTypeFrom(method as Method):
- if method.ReturnType is not null:
- return ReturnTypeFrom(method.ReturnType)
-
- match ReturnTypeDetector().Detect(method):
- case ReturnTypeDetector.Result.Yields:
- return MD.DomReturnType("System.Collections.IEnumerator")
- case ReturnTypeDetector.Result.Returns:
- return DefaultReturnType()
- otherwise:
- return MD.DomReturnType("void")
-
- class ReturnTypeDetector(DepthFirstVisitor):
- enum Result:
- Returns
- Yields
- None
-
- _result = Result.None
-
- def Detect(node as Method):
- VisitAllowingCancellation(node)
- return _result
-
- override def OnBlockExpression(node as BlockExpression):
- pass // skip over closures
-
- override def OnReturnStatement(node as ReturnStatement):
- if node.Expression is null: return
- _result = Result.Returns
- Cancel()
-
- override def OnYieldStatement(node as YieldStatement):
- _result = Result.Yields
- Cancel()
-
- virtual def ParameterTypeFrom(typeRef as TypeReference):
- if typeRef is null: return DefaultReturnType()
- return ReturnTypeFrom(typeRef)
-
- virtual def ReturnTypeFrom(typeRef as TypeReference) as MD.DomReturnType:
- match typeRef:
- case SimpleTypeReference(Name: name):
- return MD.DomReturnType(name)
- case ArrayTypeReference(ElementType: elementType):
- type = ReturnTypeFrom(elementType)
- type.ArrayDimensions = 1
- type.SetDimension(0, 1)
- return type
- otherwise:
- return MD.DomReturnType("void")
-
- def AddType(type as MD.DomType):
- if _currentType is not null:
- _currentType.Add(type)
- else:
- type.Namespace = _namespace
- _result.Add(type)
-
- def WithCurrentType(type as MD.DomType, block as callable()):
- saved = _currentType
- _currentType = type
- try:
- block()
- ensure:
- _currentType = saved
-
- def BodyRegionOf(node as Node):
- return MD.DomRegion(DomLocationFrom(node.LexicalInfo), DomLocationFrom(node.EndSourceLocation))
-
- def LocationOf(node as Node):
- location = node.LexicalInfo
- return DomLocationFrom(location)
-
- def DomLocationFrom(location as SourceLocation):
- return MD.DomLocation(location.Line, location.Column)
-
- def DefaultReturnType():
- return MD.DomReturnType("Object")
\ No newline at end of file
diff --git a/src/UnityScript.MonoDevelop/ProjectModel/UnityScriptCodeDomProvider.boo b/src/UnityScript.MonoDevelop/ProjectModel/UnityScriptCodeDomProvider.boo
deleted file mode 100644
index 3deb87a..0000000
--- a/src/UnityScript.MonoDevelop/ProjectModel/UnityScriptCodeDomProvider.boo
+++ /dev/null
@@ -1,19 +0,0 @@
-namespace UnityScript.MonoDevelop.ProjectModel
-
-import System
-import System.CodeDom.Compiler
-
-class UnityScriptCodeDomProvider(CodeDomProvider):
-
- override FileExtension:
- get: return "js"
-
- override def CreateCompiler():
- raise NotImplementedException()
-
- override def CreateGenerator():
- return UnityScriptCodeGenerator()
-
- override def GetConverter(type as Type) as System.ComponentModel.TypeConverter:
- raise NotImplementedException()
-
diff --git a/src/UnityScript.MonoDevelop/ProjectModel/UnityScriptCodeGenerator.boo b/src/UnityScript.MonoDevelop/ProjectModel/UnityScriptCodeGenerator.boo
deleted file mode 100644
index 92c7f5a..0000000
--- a/src/UnityScript.MonoDevelop/ProjectModel/UnityScriptCodeGenerator.boo
+++ /dev/null
@@ -1,14 +0,0 @@
-namespace UnityScript.MonoDevelop.ProjectModel
-
-import System.CodeDom.Compiler
-
-class UnityScriptCodeGenerator(CodeGenerator):
-
- override def Supports(supports as GeneratorSupport):
- return false
-
- override def CreateEscapedIdentifier(value as string):
- return value
-
- override def CreateValidIdentifier(value as string):
- return value
\ No newline at end of file
diff --git a/src/UnityScript.MonoDevelop/ProjectModel/UnityScriptCompilationParameters.boo b/src/UnityScript.MonoDevelop/ProjectModel/UnityScriptCompilationParameters.boo
deleted file mode 100644
index c360b3f..0000000
--- a/src/UnityScript.MonoDevelop/ProjectModel/UnityScriptCompilationParameters.boo
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace UnityScript.MonoDevelop.ProjectModel
-
-import MonoDevelop.Projects
-
-class UnityScriptCompilationParameters(ConfigurationParameters):
- pass
\ No newline at end of file
diff --git a/src/UnityScript.MonoDevelop/ProjectModel/UnityScriptCompiler.boo b/src/UnityScript.MonoDevelop/ProjectModel/UnityScriptCompiler.boo
deleted file mode 100644
index b912859..0000000
--- a/src/UnityScript.MonoDevelop/ProjectModel/UnityScriptCompiler.boo
+++ /dev/null
@@ -1,103 +0,0 @@
-namespace UnityScript.MonoDevelop.ProjectModel
-
-import MonoDevelop.Core
-import MonoDevelop.Projects
-
-import System.IO
-
-import Boo.Lang.PatternMatching
-
-class UnityScriptCompiler:
-
- _config as DotNetProjectConfiguration
- _selector as ConfigurationSelector
- _projectItems as ProjectItemCollection
- _compilationParameters as UnityScriptCompilationParameters
- _projectParameters as UnityScriptProjectParameters
-
- def constructor(
- config as DotNetProjectConfiguration,
- selector as ConfigurationSelector,
- projectItems as ProjectItemCollection,
- progressMonitor as IProgressMonitor):
-
- _config = config
- _selector = selector
- _projectItems = projectItems
- _compilationParameters = config.CompilationParameters or UnityScriptCompilationParameters()
- _projectParameters = config.ProjectParameters or UnityScriptProjectParameters()
-
- def Run() as BuildResult:
- responseFileName = Path.GetTempFileName()
- try:
- WriteOptionsToResponseFile(responseFileName)
- compiler = MapPath("bin/net-2.0/us.exe")
- compilerOutput = ExecuteProcess(compiler, "@${responseFileName}")
- return ParseBuildResult(compilerOutput)
- ensure:
- FileService.DeleteFile(responseFileName)
-
- private def WriteOptionsToResponseFile(responseFileName as string):
- commandLine = StringWriter()
-
- commandLine.WriteLine("-base:System.Object")
- commandLine.WriteLine("-method:Awake")
- commandLine.WriteLine("-debug+")
- commandLine.WriteLine("-t:exe")
- commandLine.WriteLine("-out:${_config.CompiledOutputName}")
-
- projectFiles = item as ProjectFile for item in _projectItems if item isa ProjectFile
- for file in projectFiles:
- continue if file.Subtype == Subtype.Directory
-
- match file.BuildAction:
- case "Compile":
- commandLine.WriteLine("\"${file.Name}\"")
- otherwise:
- print "Unrecognized build action:", file.BuildAction
-
- commandLineString = commandLine.ToString()
- print commandLineString
- File.WriteAllText(responseFileName, commandLineString)
-
- private def MapPath(path as string):
- return Path.Combine(Path.GetDirectoryName(GetType().Assembly.Location), path)
-
- private def ExecuteProcess(executable as string, commandLine as string):
- startInfo = System.Diagnostics.ProcessStartInfo(executable, commandLine,
- UseShellExecute: false,
- RedirectStandardOutput: true,
- RedirectStandardError: true)
-
- using process = Runtime.SystemAssemblyService.CurrentRuntime.ExecuteAssembly(startInfo, _config.TargetFramework):
- process.WaitForExit()
- return process.StandardOutput.ReadToEnd() + System.Environment.NewLine + process.StandardError.ReadToEnd()
-
- private def ParseBuildResult(stdout as string):
-
- result = BuildResult()
-
- for line in StringReader(stdout):
- match line:
- case /(?.+)\((?\d+),(?\d+)\):\s+(?.+?):\s+(?.+)/:
- result.Append(BuildError(
- FileName: fileName[0].Value,
- Line: int.Parse(lineNumber[0].Value),
- Column: int.Parse(column[0].Value),
- IsWarning: code[0].Value.StartsWith("BCW"),
- ErrorNumber: code[0].Value,
- ErrorText: message[0].Value))
-
- case /(?.+):\s+(?.+)/:
- result.Append(
- BuildError(
- ErrorNumber: code[0].Value,
- ErrorText: message[0].Value))
-
- otherwise:
- unrecognized = len(line) > 0 \
- and not line.StartsWith("Successfully compiled '")
-
- if unrecognized: print "Unrecognized compiler output:", line
-
- return result
diff --git a/src/UnityScript.MonoDevelop/ProjectModel/UnityScriptLanguageBinding.boo b/src/UnityScript.MonoDevelop/ProjectModel/UnityScriptLanguageBinding.boo
deleted file mode 100644
index 7c27971..0000000
--- a/src/UnityScript.MonoDevelop/ProjectModel/UnityScriptLanguageBinding.boo
+++ /dev/null
@@ -1,54 +0,0 @@
-namespace UnityScript.MonoDevelop.ProjectModel
-
-import MonoDevelop.Core
-import MonoDevelop.Projects
-import System.Xml
-
-import UnityScript.MonoDevelop
-
-class UnityScriptLanguageBinding(IDotNetLanguageBinding):
-
- ProjectStockIcon:
- get: return "md-unityscript-project"
-
- SingleLineCommentTag:
- get: return "//"
-
- BlockCommentStartTag:
- get: return "/*"
-
- BlockCommentEndTag:
- get: return "*/"
-
- Refactorer:
- get: return null
-
- Parser:
- get: return null
-
- Language:
- get: return "UnityScript"
-
- def IsSourceCodeFile(fileName as string):
- return IsUnityScriptFile(fileName)
-
- def GetFileName(baseName as string):
- return baseName + ".us"
-
- def GetCodeDomProvider():
- return UnityScriptCodeDomProvider()
-
- def CreateProjectParameters(projectOptions as XmlElement):
- return UnityScriptProjectParameters()
-
- def CreateCompilationParameters(projectOptions as XmlElement):
- return UnityScriptCompilationParameters()
-
- def GetSupportedClrVersions():
- return (ClrVersion.Net_1_1, ClrVersion.Net_2_0, ClrVersion.Clr_2_1, ClrVersion.Net_4_0)
-
- def Compile(items as ProjectItemCollection,
- config as DotNetProjectConfiguration,
- selector as ConfigurationSelector,
- progressMonitor as IProgressMonitor):
- return UnityScriptCompiler(config, selector, items, progressMonitor).Run()
diff --git a/src/UnityScript.MonoDevelop/ProjectModel/UnityScriptParser.boo b/src/UnityScript.MonoDevelop/ProjectModel/UnityScriptParser.boo
deleted file mode 100644
index 0c75a80..0000000
--- a/src/UnityScript.MonoDevelop/ProjectModel/UnityScriptParser.boo
+++ /dev/null
@@ -1,37 +0,0 @@
-namespace UnityScript.MonoDevelop.ProjectModel
-
-import System.IO
-
-import MonoDevelop.Projects.Dom
-import MonoDevelop.Projects.Dom.Parser
-
-import UnityScript.MonoDevelop
-
-class UnityScriptParser(AbstractParser):
-
- public static final MimeType = "text/x-unityscript"
-
- def constructor():
- super("UnityScript", MimeType)
-
- override def CanParse(fileName as string):
- return IsUnityScriptFile(fileName)
-
- override def Parse(dom as ProjectDom, fileName as string, content as string):
- result = ParseUnityScript(fileName, content)
-
- document = ParsedDocument(fileName)
- document.CompilationUnit = CompilationUnit(fileName)
-
- result.CompileUnit.Accept(DomConversionVisitor(document.CompilationUnit))
-
- return document
-
-def ParseUnityScript(fileName as string, content as string):
- compiler = UnityScript.UnityScriptCompiler()
- compiler.Parameters.ScriptMainMethod = "Awake"
- compiler.Parameters.ScriptBaseType = object
- compiler.Parameters.Pipeline = UnityScript.UnityScriptCompiler.Pipelines.Parse()
- compiler.Parameters.Input.Add(Boo.Lang.Compiler.IO.StringInput(fileName, content))
- return compiler.Run()
-
\ No newline at end of file
diff --git a/src/UnityScript.MonoDevelop/ProjectModel/UnityScriptProjectParameters.boo b/src/UnityScript.MonoDevelop/ProjectModel/UnityScriptProjectParameters.boo
deleted file mode 100644
index 5b29e5b..0000000
--- a/src/UnityScript.MonoDevelop/ProjectModel/UnityScriptProjectParameters.boo
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace UnityScript.MonoDevelop.ProjectModel
-
-import MonoDevelop.Projects
-
-class UnityScriptProjectParameters(ProjectParameters):
- pass
\ No newline at end of file
diff --git a/src/UnityScript.MonoDevelop/Templates/ConsoleProject.xpt.xml b/src/UnityScript.MonoDevelop/Templates/ConsoleProject.xpt.xml
deleted file mode 100644
index f374759..0000000
--- a/src/UnityScript.MonoDevelop/Templates/ConsoleProject.xpt.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
-
- <_Name>Console Project
- <_Category>UnityScript
- md-project-console|res:UnityScriptProject32.png
- UnityScript
- <_Description>Creates a new UnityScript console project.
-
-
-
-
-
-
-
-
-
-
- ${ProjectName}
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/UnityScript.MonoDevelop/Templates/EmptyUnityScriptFile.xft.xml b/src/UnityScript.MonoDevelop/Templates/EmptyUnityScriptFile.xft.xml
deleted file mode 100644
index 8074708..0000000
--- a/src/UnityScript.MonoDevelop/Templates/EmptyUnityScriptFile.xft.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
- <_Name>Empty File
- md-unityscript-file
- <_Category>General
- UnityScript
- <_Description>Creates an empty UnityScript file.
-
-
-
-
-
-
-
-
-
-
diff --git a/src/UnityScript.MonoDevelop/UnityScript.MonoDevelop.addin.xml b/src/UnityScript.MonoDevelop/UnityScript.MonoDevelop.addin.xml
deleted file mode 100644
index fc09d71..0000000
--- a/src/UnityScript.MonoDevelop/UnityScript.MonoDevelop.addin.xml
+++ /dev/null
@@ -1,88 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/UnityScript.MonoDevelop/UnityScript.MonoDevelop.booproj b/src/UnityScript.MonoDevelop/UnityScript.MonoDevelop.booproj
deleted file mode 100644
index a88607c..0000000
--- a/src/UnityScript.MonoDevelop/UnityScript.MonoDevelop.booproj
+++ /dev/null
@@ -1,72 +0,0 @@
-
-
-
- Debug
- AnyCPU
- 8.0.50727
- 2.0
- {FCFE96D7-4BDB-4EE9-BD11-E3E263E1DE38}
- Library
- UnityScript.MonoDevelop
- false
- UnityScript.MonoDevelop
-
-
- true
- full
- bin\Debug
- prompt
- false
-
- false
-
-
- none
- bin\Release
- prompt
- false
-
- false
-
-
-
-
- monodevelop
- False
-
-
- monodevelop
- False
-
-
- monodevelop-core-addins
- False
-
-
- monodevelop
- False
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/UnityScript.MonoDevelop/UnityScriptFiles.boo b/src/UnityScript.MonoDevelop/UnityScriptFiles.boo
deleted file mode 100644
index 7b1c977..0000000
--- a/src/UnityScript.MonoDevelop/UnityScriptFiles.boo
+++ /dev/null
@@ -1,5 +0,0 @@
-namespace UnityScript.MonoDevelop
-
-def IsUnityScriptFile(fileName as string):
- return System.IO.Path.GetExtension(fileName).ToLower() in (".us", ".js")
-
diff --git a/src/UnityScript.MonoDevelop/UnityScriptSyntaxMode.xml b/src/UnityScript.MonoDevelop/UnityScriptSyntaxMode.xml
deleted file mode 100644
index 05e6c9e..0000000
--- a/src/UnityScript.MonoDevelop/UnityScriptSyntaxMode.xml
+++ /dev/null
@@ -1,231 +0,0 @@
-
-
-
- //
- /*
- */
- "
- '
-
- #
- ///
- //
-
-
- /*
- */
-
-
-
- @"
- "
-
-
-
- "
- "
-
-
-
- '
- '
-
-
- CSharpNumber
-
-
- this
- super
-
-
-
- as
- is
- new
- sizeof
- typeof
-
-
-
- else
- if
- switch
- case
- default
-
-
-
- do
- for
- in
- while
-
-
-
- break
- continue
- goto
- return
-
-
-
- yield
- partial
-
-
-
- try
- throw
- catch
- finally
-
-
-
- true
- false
- null
-
-
-
- abstract
- event
- override
- final
- static
- virtual
-
- public
- protected
- private
- internal
-
-
-
- boolean
- byte
- char
- Date
- double
- enum
- float
- int
- long
- sbyte
- short
- struct
- uint
- ushort
- ulong
- Object
- String
- Regex
- Number
- Function
- Array
- var
-
-
-
- void
-
-
-
- package
- import
-
-
-
- get
- set
- add
- remove
- value
-
-
-
- class
- interface
- function
-
-
-
- ref
- out
-
-
-
-
- explicit
- implicit
-
- operator
-
-
-
- checked
- unchecked
- fixed
- lock
-
-
-
-
- pragma
-
-
-
-
-
- TODO
- FIXME
- HACK
- UNDONE
-
-
-
-
-
-
-
-
- <
- >
-
-
-
-
-
- "
- "
-
-
- c
- code
- example
- exception
- list
- para
- param
- paramref
- permission
- remarks
- returns
- see
- seealso
- summary
- value
- type
- name
- cref
- item
- term
- description
- listheader
-
-
-
-
diff --git a/src/UnityScript.Tests.CSharp/.monolipse b/src/UnityScript.Tests.CSharp/.monolipse
index 85f11ad..83e7aea 100755
--- a/src/UnityScript.Tests.CSharp/.monolipse
+++ b/src/UnityScript.Tests.CSharp/.monolipse
@@ -2,9 +2,9 @@
cs
library
-
- /UnityScript/lib/net-2.0/bin/Boo.Lang.dll
-
+
+ Boo.Lang
+
/UnityScript/bin
diff --git a/src/UnityScript.Tests.CSharp/AssemblyInfo.cs b/src/UnityScript.Tests.CSharp/AssemblyInfo.cs
index f8ee868..cbbb021 100755
--- a/src/UnityScript.Tests.CSharp/AssemblyInfo.cs
+++ b/src/UnityScript.Tests.CSharp/AssemblyInfo.cs
@@ -1,12 +1,6 @@
using System.Reflection;
using System.Runtime.CompilerServices;
-// Information about this assembly is defined by the following
-// attributes.
-//
-// change them to the information which is associated with the assembly
-// you compile.
-
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
@@ -15,13 +9,4 @@
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
-
-// The assembly version has following format :
-//
-// Major.Minor.Build.Revision
-//
-// You can specify all values by your own or you can build default build and revision
-// numbers with the '*' character (the default):
-
-[assembly: AssemblyVersion("1.0.*")]
-
+[assembly: AssemblyVersion("1.0.*")]
\ No newline at end of file
diff --git a/src/UnityScript.Tests.CSharp/Generics.cs b/src/UnityScript.Tests.CSharp/Generics.cs
index 131c42d..1969038 100644
--- a/src/UnityScript.Tests.CSharp/Generics.cs
+++ b/src/UnityScript.Tests.CSharp/Generics.cs
@@ -1,3 +1,5 @@
+using System;
+
namespace UnityScript.Tests.CSharp
{
public static class Generics
@@ -5,6 +7,19 @@ public static class Generics
public static T Identity(T o)
{
return o;
+ }
+
+ public static T Instantiate() where T:new()
+ {
+ return new T();
+ }
+
+ public static class GenericClass
+ {
+ public static void GenericMethod(T t, U u)
+ {
+ Console.WriteLine("GenericMethod({0}, {1})", typeof(T), typeof(U));
+ }
}
}
}
diff --git a/src/UnityScript.Tests.CSharp/MultidimensionalArrays.cs b/src/UnityScript.Tests.CSharp/MultidimensionalArrays.cs
new file mode 100644
index 0000000..a064be7
--- /dev/null
+++ b/src/UnityScript.Tests.CSharp/MultidimensionalArrays.cs
@@ -0,0 +1,18 @@
+using System;
+
+namespace UnityScript.Tests.CSharp
+{
+ public static class MultidimensionalArrays
+ {
+ public static int[,,] GetArray(int i, int j, int k)
+ {
+ var array = new int[i, j, k];
+ for (var ii=0; ii
Debug
AnyCPU
9.0.21022
2.0
{EF5AE116-19DD-42DC-847A-7BD3EE49AB01}
Library
UnityScript.Tests.CSharp
UnityScript.Tests.CSharp
v3.5
true
full
false
bin\Debug
DEBUG
prompt
4
false
none
false
bin\Release
prompt
4
false
\ No newline at end of file
+
+
+
+ Debug
+ AnyCPU
+ 9.0.21022
+ 2.0
+ {EF5AE116-19DD-42DC-847A-7BD3EE49AB01}
+ Library
+ UnityScript.Tests.CSharp
+ UnityScript.Tests.CSharp
+ v3.5
+
+
+ true
+ full
+ false
+ bin\Debug
+ DEBUG
+ prompt
+ 4
+ false
+
+
+ none
+ false
+ bin\Release
+ prompt
+ 4
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/UnityScript.Tests.CSharp/VarArgs.cs b/src/UnityScript.Tests.CSharp/VarArgs.cs
new file mode 100644
index 0000000..435ebe8
--- /dev/null
+++ b/src/UnityScript.Tests.CSharp/VarArgs.cs
@@ -0,0 +1,23 @@
+using System;
+
+namespace UnityScript.Tests.CSharp
+{
+ public static class VarArgsMethods
+ {
+ public static int WithVector3(params Vector3[] array)
+ {
+ return array.Length;
+ }
+ }
+
+ public class VarArgsConstructors
+ {
+ public readonly Vector3[] array;
+
+ public VarArgsConstructors(params Vector3[] array)
+ {
+ this.array = array;
+ }
+ }
+}
+
diff --git a/src/UnityScript.Tests/AbstractCompilerTest.boo b/src/UnityScript.Tests/AbstractCompilerTest.boo
new file mode 100644
index 0000000..3fc7aae
--- /dev/null
+++ b/src/UnityScript.Tests/AbstractCompilerTest.boo
@@ -0,0 +1,46 @@
+namespace UnityScript.Tests
+
+import System.IO
+import NUnit.Framework
+import UnityScript
+import Boo.Lang.Compiler
+
+abstract class AbstractCompilerTest:
+
+ _compiler as UnityScriptCompiler
+
+ Parameters:
+ get: return _compiler.Parameters
+
+ OutputAssemblyPath:
+ get: return Path.Combine(Path.Combine(Path.GetTempPath(), "UnityScript"), GetType().Name)
+
+ [TestFixtureSetUp]
+ virtual def SetUpFixture():
+ if Directory.Exists(OutputAssemblyPath): Directory.Delete(OutputAssemblyPath, true)
+ Directory.CreateDirectory(OutputAssemblyPath)
+ _compiler = CreateCompiler()
+
+ virtual def CreateCompiler():
+ compiler = UnityScriptCompiler()
+ compiler.Parameters.ScriptBaseType = MonoBehaviour
+ compiler.Parameters.ScriptMainMethod = "Awake"
+ compiler.Parameters.Pipeline = CreateCompilerPipeline()
+ compiler.Parameters.References.Add(typeof(AbstractCompilerTestFixture).Assembly)
+ compiler.Parameters.References.Add(typeof(UnityScript.Tests.CSharp.FooBarEnum).Assembly)
+ return compiler
+
+ virtual def CompileTestCase(*inputs as (ICompilerInput)):
+ SetCompilationOptions()
+ for input in inputs: Parameters.Input.Add(input)
+ Parameters.OutputAssembly = Path.Combine(OutputAssemblyPath, GetType().Name + "-" + Path.GetFileNameWithoutExtension(Parameters.Input[0].Name) + ".exe")
+ return _compiler.Run()
+
+ virtual def SetCompilationOptions():
+ Parameters.Input.Clear()
+ Parameters.Strict = false
+
+ protected abstract def CreateCompilerPipeline() as CompilerPipeline:
+ pass
+
+
diff --git a/src/UnityScript.Tests/AbstractCompilerTestFixture.boo b/src/UnityScript.Tests/AbstractCompilerTestFixture.boo
index 8f794ca..2f81d16 100755
--- a/src/UnityScript.Tests/AbstractCompilerTestFixture.boo
+++ b/src/UnityScript.Tests/AbstractCompilerTestFixture.boo
@@ -4,37 +4,19 @@ import System.IO
import Boo.Lang.Compiler
import Boo.Lang.Compiler.IO
import NUnit.Framework from nunit.framework
-import UnityScript
-abstract class AbstractCompilerTestFixture:
+abstract class AbstractCompilerTestFixture(AbstractCompilerTest):
virtual DisplayErrorStackTrace:
get: return false
static BasePath as string:
- get:
- if _basePath is null:
- _basePath = FindTestsPath()
- return _basePath
+ get: return _basePath or _basePath = FindTestsPath()
private static _basePath as string
- _compiler as UnityScriptCompiler
-
- [TestFixtureSetUp]
- virtual def SetUpFixture():
- _compiler = CreateCompiler()
-
- virtual def CreateCompiler() as UnityScriptCompiler:
- compiler = UnityScriptCompiler()
- compiler.Parameters.Ducky = true
- compiler.Parameters.ScriptBaseType = MonoBehaviour
- compiler.Parameters.ScriptMainMethod = "Awake"
- compiler.Parameters.Pipeline = CreateCompilerPipeline()
- compiler.Parameters.References.Add(typeof(AbstractCompilerTestFixture).Assembly)
- compiler.Parameters.References.Add(typeof(Assert).Assembly)
- compiler.Parameters.References.Add(typeof(UnityScript.Tests.CSharp.FooBarEnum).Assembly)
- return compiler
+ virtual def CompileTestCase([required] fname as string):
+ return CompileTestCase(FileInput(fname))
def RunTestCase(fname as string):
location = ResolvePath(fname)
@@ -42,14 +24,6 @@ abstract class AbstractCompilerTestFixture:
CheckTestCaseCompilationResult(result)
CheckTestCaseOutput(location, GetActualOutput(result))
- virtual def CompileTestCase([required] fname as string):
- return CompileTestCase(FileInput(fname))
-
- virtual def CompileTestCase([required] input as ICompilerInput):
- _compiler.Parameters.Input.Clear()
- _compiler.Parameters.Input.Add(input)
- return _compiler.Run()
-
virtual protected def CheckTestCaseCompilationResult([required] result as CompilerContext):
Assert.AreEqual(0, result.Errors.Count, result.Errors.ToString(DisplayErrorStackTrace))
@@ -76,10 +50,7 @@ abstract class AbstractCompilerTestFixture:
protected virtual def GetActualOutput(result as CompilerContext) as string:
return result.CompileUnit.Modules[0].ToCodeString()
- protected abstract def CreateCompilerPipeline() as CompilerPipeline:
- pass
-
- def GetExpectedOutput([required] fname as string):
+ protected virtual def GetExpectedOutput([required] fname as string):
contents = ReadAllText(fname)
start = contents.IndexOf("/*")
end = contents.IndexOf("*/", start + 2)
diff --git a/src/UnityScript.Tests/AbstractIntegrationTestFixture.boo b/src/UnityScript.Tests/AbstractIntegrationTestFixture.boo
index 92a8ea3..edc8d40 100755
--- a/src/UnityScript.Tests/AbstractIntegrationTestFixture.boo
+++ b/src/UnityScript.Tests/AbstractIntegrationTestFixture.boo
@@ -13,22 +13,11 @@ class AbstractIntegrationTestFixture(AbstractCompilerTestFixture):
override DisplayErrorStackTrace:
get: return true
- OutputAssemblyPath:
- get: return Path.Combine(
- Path.Combine(Path.GetTempPath(), "UnityScript"),
- GetType().Name)
-
[TestFixtureSetUp]
override def SetUpFixture():
super()
- if Directory.Exists(OutputAssemblyPath): Directory.Delete(OutputAssemblyPath, true)
- Directory.CreateDirectory(OutputAssemblyPath)
CopyReferencedAssemblies()
- override def CompileTestCase(fname as string):
- _compiler.Parameters.OutputAssembly = Path.Combine(OutputAssemblyPath, GetType().Name.Replace("TestFixture", "") + "-" + Path.GetFileNameWithoutExtension(fname) + ".exe")
- return super(fname)
-
def CopyReferencedAssemblies():
CopyParentAssembly(UnityScriptCompiler)
CopyParentAssembly(UnityScript.Lang.Array)
@@ -37,6 +26,7 @@ class AbstractIntegrationTestFixture(AbstractCompilerTestFixture):
CopyParentAssembly(GetType())
CopyParentAssembly(UnityScript.Tests.CSharp.FooBarEnum)
CopyParentAssembly(Assert)
+ CopyParentAssembly(MacroMacro)
def CopyParentAssembly(type as System.Type):
CopyFile(type.Module.FullyQualifiedName)
diff --git a/src/UnityScript.Tests/AbstractSemanticsTestFixture.boo b/src/UnityScript.Tests/AbstractSemanticsTestFixture.boo
index 3aa2fcc..197d491 100755
--- a/src/UnityScript.Tests/AbstractSemanticsTestFixture.boo
+++ b/src/UnityScript.Tests/AbstractSemanticsTestFixture.boo
@@ -1,6 +1,5 @@
namespace UnityScript.Tests
-import Boo.Lang.Compiler
import NUnit.Framework
class AbstractSemanticsTestFixture(AbstractCompilerTestFixture):
@@ -11,9 +10,4 @@ class AbstractSemanticsTestFixture(AbstractCompilerTestFixture):
_compiler.Parameters.Imports.Add("UnityScript.Tests")
override protected def CreateCompilerPipeline():
- pipeline = CompilerPipeline()
- pipeline.Add(UnityScript.Steps.Parse())
- pipeline.Add(Boo.Lang.Compiler.Steps.InitializeTypeSystemServices())
- pipeline.Add(Boo.Lang.Compiler.Steps.PreErrorChecking())
- pipeline.Add(UnityScript.Steps.ApplySemantics())
- return pipeline
+ return UnityScript.UnityScriptCompiler.Pipelines.Compile()
diff --git a/src/UnityScript.Tests/CommandLineOptionsTestFixture.boo b/src/UnityScript.Tests/CommandLineOptionsTestFixture.boo
old mode 100644
new mode 100755
index 7f72544..e0625ee
--- a/src/UnityScript.Tests/CommandLineOptionsTestFixture.boo
+++ b/src/UnityScript.Tests/CommandLineOptionsTestFixture.boo
@@ -1,5 +1,6 @@
namespace UnityScript.Tests
+import System.IO
import NUnit.Framework
[TestFixture]
@@ -8,4 +9,52 @@ class CommandLineOptionsTestFixture:
[Test]
def Defines():
options = us.CommandLineOptions("-d:FOO", "--define:BAR")
- assert options.Defines == ["FOO", "BAR"]
\ No newline at end of file
+ Assert.AreEqual(("FOO", "BAR"), options.Defines.ToArray())
+
+ [Test]
+ def ResponseFilesWithQuotedArgumentsContainingSpacesAreCorrectlyParsed():
+
+ sourceFile = "foo/with space/src.boo"
+ reference = "foo/with space/bar.dll"
+
+ rsp = Path.GetTempFileName()
+ File.WriteAllText(rsp, """
+#this is only a comment
+
+-r:"$reference"
+
+"$sourceFile"
+
+ """)
+
+ options = us.CommandLineOptions("@$rsp")
+ Assert.AreEqual((reference,), options.References.ToArray())
+ Assert.AreEqual((sourceFile,), options.SourceFiles.ToArray())
+
+ [Test]
+ def SourceDirectoriesAreRecursivelyScanned():
+ dir = CreateTempDirectory()
+
+ files = "a.js", "Sub1/b.js", "Sub1/c.js", "Sub1/Sub2/d.js", "Sub1/Sub2/Sub3/Sub4/e.js"
+ CreateFilesOn(dir, files)
+
+ options = us.CommandLineOptions("-srcdir:${dir}")
+
+ actualFiles = Boo.Lang.List of string()
+ options.ForEachSourceFile(actualFiles.Add)
+
+ Assert.AreEqual(
+ array(Path.Combine(dir, file).Replace(char('/'), Path.DirectorySeparatorChar) for file in files),
+ actualFiles.ToArray())
+
+def CreateFilesOn(dir as string, files as string*):
+ for file in files:
+ fullName = Path.Combine(dir, file)
+ Directory.CreateDirectory(Path.GetDirectoryName(fullName))
+ File.WriteAllText(fullName, "")
+
+def CreateTempDirectory():
+ tmp = Path.GetTempFileName()
+ File.Delete(tmp)
+ Directory.CreateDirectory(tmp)
+ return tmp
diff --git a/src/UnityScript.Tests/Core/PragmasTest.boo b/src/UnityScript.Tests/Core/PragmasTest.boo
new file mode 100644
index 0000000..cf05d31
--- /dev/null
+++ b/src/UnityScript.Tests/Core/PragmasTest.boo
@@ -0,0 +1,31 @@
+namespace UnityScript.Tests.Core
+
+import NUnit.Framework
+import Boo.Lang.Compiler.Ast
+import UnityScript.Core
+
+
+[TestFixture]
+class PragmasTest:
+
+ [Test]
+ def GivenIsNotEnabledWhenTryToEnableOnThenIsEnabledOnReturnsTrue():
+
+ m = Module()
+ for pragma in Pragmas.All:
+ assert not Pragmas.IsEnabledOn(m, pragma)
+ assert Pragmas.TryToEnableOn(m, pragma)
+ assert Pragmas.IsEnabledOn(m, pragma)
+
+
+ [Test]
+ def GivenIsDisabledWhenTryToEnabledOnThenIsEnabledOnReturnsFalse():
+
+ m = Module()
+ for pragma in Pragmas.All:
+ Pragmas.DisableOn(m, pragma)
+ assert not Pragmas.TryToEnableOn(m, pragma)
+ assert not Pragmas.IsEnabledOn(m, pragma)
+
+
+
diff --git a/src/UnityScript.Tests/DuckyIntegrationTestFixture.boo b/src/UnityScript.Tests/DuckyIntegrationTestFixture.boo
new file mode 100644
index 0000000..66d41af
--- /dev/null
+++ b/src/UnityScript.Tests/DuckyIntegrationTestFixture.boo
@@ -0,0 +1,831 @@
+
+namespace UnityScript.Tests
+
+import NUnit.Framework
+
+[TestFixture]
+class DuckyIntegrationTestFixture(AbstractIntegrationTestFixture):
+ override def SetCompilationOptions():
+ super()
+ Parameters.Strict = false
+
+
+ [Test] def JSCheckFloatToIntOverflow():
+ RunTestCase("tests/integration/JSCheckFloatToIntOverflow.js")
+
+
+ [Test] def JSChooseOverload():
+ RunTestCase("tests/integration/JSChooseOverload.js")
+
+
+ [Test] def accessor_2():
+ RunTestCase("tests/integration/accessor-2.js")
+
+
+ [Test] def accessor_3_duck():
+ RunTestCase("tests/integration/accessor-3-duck.js")
+
+
+ [Test] def accessor():
+ RunTestCase("tests/integration/accessor.js")
+
+
+ [Test] def anonymous_function_type_1():
+ RunTestCase("tests/integration/anonymous-function-type-1.js")
+
+
+ [Test] def anonymous_function_type_2():
+ RunTestCase("tests/integration/anonymous-function-type-2.js")
+
+
+ [Test] def anonymous_function_type_3():
+ RunTestCase("tests/integration/anonymous-function-type-3.js")
+
+
+ [Test] def array_Add():
+ RunTestCase("tests/integration/array-Add.js")
+
+
+ [Test] def array_Remove():
+ RunTestCase("tests/integration/array-Remove.js")
+
+
+ [Test] def array_cast():
+ RunTestCase("tests/integration/array-cast.js")
+
+
+ [Test] def array_comprehension_1():
+ RunTestCase("tests/integration/array-comprehension-1.js")
+
+
+ [Test] def array_concat_1():
+ RunTestCase("tests/integration/array-concat-1.js")
+
+
+ [Test] def array_concat_2():
+ RunTestCase("tests/integration/array-concat-2.js")
+
+
+ [Test] def array_create():
+ RunTestCase("tests/integration/array-create.js")
+
+
+ [Test] def array_ctor_with_single_null_element():
+ RunTestCase("tests/integration/array-ctor-with-single-null-element.js")
+
+
+ [Test] def array_implicit_from_null_enumerable():
+ RunTestCase("tests/integration/array-implicit-from-null-enumerable.js")
+
+
+ [Test] def array_implicit_from_null():
+ RunTestCase("tests/integration/array-implicit-from-null.js")
+
+
+ [Test] def array_initializer_in_static_field():
+ RunTestCase("tests/integration/array-initializer-in-static-field.js")
+
+
+ [Test] def array_instantiation_with_object_argument_in_strict_mode():
+ RunTestCase("tests/integration/array-instantiation-with-object-argument-in-strict-mode.js")
+
+
+ [Test] def array_instantiation_with_object_argument():
+ RunTestCase("tests/integration/array-instantiation-with-object-argument.js")
+
+
+ [Test] def array_iteration_with_nulls():
+ RunTestCase("tests/integration/array-iteration-with-nulls.js")
+
+
+ [Test] def array_join():
+ RunTestCase("tests/integration/array-join.js")
+
+
+ [Test] def array_length_duck_typed():
+ RunTestCase("tests/integration/array-length-duck-typed.js")
+
+
+ [Test] def array_nesting():
+ RunTestCase("tests/integration/array-nesting.js")
+
+
+ [Test] def array_pop():
+ RunTestCase("tests/integration/array-pop.js")
+
+
+ [Test] def array_push_2():
+ RunTestCase("tests/integration/array-push-2.js")
+
+
+ [Test] def array_push():
+ RunTestCase("tests/integration/array-push.js")
+
+
+ [Test] def array_shift():
+ RunTestCase("tests/integration/array-shift.js")
+
+
+ [Test] def array_slice():
+ RunTestCase("tests/integration/array-slice.js")
+
+
+ [Test] def array_sort():
+ RunTestCase("tests/integration/array-sort.js")
+
+
+ [Test] def array_splice_2():
+ RunTestCase("tests/integration/array-splice-2.js")
+
+
+ [Test] def array_splice():
+ RunTestCase("tests/integration/array-splice.js")
+
+
+ [Test] def array_str():
+ RunTestCase("tests/integration/array-str.js")
+
+
+ [Test] def array_toString():
+ RunTestCase("tests/integration/array-toString.js")
+
+
+ [Test] def array_unshift():
+ RunTestCase("tests/integration/array-unshift.js")
+
+
+ [Test] def array_with_initial_length():
+ RunTestCase("tests/integration/array-with-initial-length.js")
+
+
+ [Test] def array_with_two_dimensions():
+ RunTestCase("tests/integration/array-with-two-dimensions.js")
+
+
+ [Test] def arrays_2():
+ RunTestCase("tests/integration/arrays-2.js")
+
+
+ [Test] def arrays_3():
+ RunTestCase("tests/integration/arrays-3.js")
+
+
+ [Test] def arrays_4():
+ RunTestCase("tests/integration/arrays-4.js")
+
+
+ [Test] def arrays_6():
+ RunTestCase("tests/integration/arrays-6.js")
+
+
+ [Test] def arrays():
+ RunTestCase("tests/integration/arrays.js")
+
+
+ [Test] def assign_iterator():
+ RunTestCase("tests/integration/assign_iterator.js")
+
+
+ [Test] def attributes_2():
+ RunTestCase("tests/integration/attributes-2.js")
+
+
+ [Test] def attributes():
+ RunTestCase("tests/integration/attributes.js")
+
+
+ [Test] def auto_coroutine_2():
+ RunTestCase("tests/integration/auto-coroutine-2.js")
+
+
+ [Test] def auto_coroutine_return_2():
+ RunTestCase("tests/integration/auto-coroutine-return-2.js")
+
+
+ [Test] def auto_coroutine_static():
+ RunTestCase("tests/integration/auto-coroutine-static.js")
+
+
+ [Test] def cast_operator_1():
+ RunTestCase("tests/integration/cast-operator-1.js")
+
+
+ [Test] def cast_operator_precedence():
+ RunTestCase("tests/integration/cast-operator-precedence.js")
+
+
+ [Test] def chars():
+ RunTestCase("tests/integration/chars.js")
+
+
+ [Test] def comma_parsing():
+ RunTestCase("tests/integration/comma-parsing.js")
+
+
+ [Test] def constructor_1():
+ RunTestCase("tests/integration/constructor-1.js")
+
+
+ [Test] def constructor_2():
+ RunTestCase("tests/integration/constructor_2.js")
+
+
+ [Test] def continue_issue():
+ RunTestCase("tests/integration/continue-issue.js")
+
+
+ [Test] def coroutine_2():
+ RunTestCase("tests/integration/coroutine-2.js")
+
+
+ [Test] def coroutine_3():
+ RunTestCase("tests/integration/coroutine-3.js")
+
+
+ [Test] def coroutine_4():
+ RunTestCase("tests/integration/coroutine-4.js")
+
+
+ [Test] def coroutine_5():
+ RunTestCase("tests/integration/coroutine-5.js")
+
+
+ [Test] def coroutine_return_type_1():
+ RunTestCase("tests/integration/coroutine-return-type-1.js")
+
+
+ [Test] def coroutine_try_catch():
+ RunTestCase("tests/integration/coroutine-try-catch.js")
+
+
+ [Test] def coroutine():
+ RunTestCase("tests/integration/coroutine.js")
+
+
+ [Test] def crash():
+ RunTestCase("tests/integration/crash.js")
+
+
+ [Test] def do_while():
+ RunTestCase("tests/integration/do-while.js")
+
+
+ [Test] def double_precision_can_be_used_for_literals():
+ RunTestCase("tests/integration/double-precision-can-be-used-for-literals.js")
+
+
+ [Test] def empty_array_literal_as_return_value():
+ RunTestCase("tests/integration/empty-array-literal-as-return-value.js")
+
+
+ [Test] def empty_array_literal_as_yield_value():
+ RunTestCase("tests/integration/empty-array-literal-as-yield-value.js")
+
+
+ [Test] def empty_string_array():
+ RunTestCase("tests/integration/empty-string-array.js")
+
+
+ [Test] def enum_1():
+ RunTestCase("tests/integration/enum-1.js")
+
+
+ [Test] def enum_2():
+ RunTestCase("tests/integration/enum-2.js")
+
+
+ [Test] def enum_3():
+ RunTestCase("tests/integration/enum-3.js")
+
+
+ [Test] def enum_4():
+ RunTestCase("tests/integration/enum-4.js")
+
+
+ [Test] def enum_5():
+ RunTestCase("tests/integration/enum-5.js")
+
+
+ [Test] def enum_conversion():
+ RunTestCase("tests/integration/enum-conversion.js")
+
+
+ [Test] def enumerator_array():
+ RunTestCase("tests/integration/enumerator-array.js")
+
+
+ [Test] def explicit_awake_function():
+ RunTestCase("tests/integration/explicit-awake-function.js")
+
+
+ [Test] def float_1():
+ RunTestCase("tests/integration/float-1.js")
+
+
+ [Test] def float_2():
+ RunTestCase("tests/integration/float-2.js")
+
+
+ [Test] def float_array_literal():
+ RunTestCase("tests/integration/float-array-literal.js")
+
+
+ [Test] def float_overload_is_preferred_over_int_for_double_argument_2():
+ RunTestCase("tests/integration/float-overload-is-preferred-over-int-for-double-argument-2.js")
+
+
+ [Test] def float_overload_is_preferred_over_int_for_double_argument_strict_downcast():
+ RunTestCase("tests/integration/float-overload-is-preferred-over-int-for-double-argument-strict-downcast.js")
+
+
+ [Test] def float_overload_is_preferred_over_int_for_double_argument_strict():
+ RunTestCase("tests/integration/float-overload-is-preferred-over-int-for-double-argument-strict.js")
+
+
+ [Test] def float_overload_is_preferred_over_int_for_double_argument():
+ RunTestCase("tests/integration/float-overload-is-preferred-over-int-for-double-argument.js")
+
+
+ [Test] def for_break_1():
+ RunTestCase("tests/integration/for-break-1.js")
+
+
+ [Test] def for_continue_1():
+ RunTestCase("tests/integration/for-continue-1.js")
+
+
+ [Test] def for_continue_2():
+ RunTestCase("tests/integration/for-continue-2.js")
+
+
+ [Test] def for_in_switch_break():
+ RunTestCase("tests/integration/for-in-switch-break.js")
+
+
+ [Test] def for_over_null():
+ RunTestCase("tests/integration/for-over-null.js")
+
+
+ [Test] def for_var_reuse():
+ RunTestCase("tests/integration/for-var-reuse.js")
+
+
+ [Test] def functions_1():
+ RunTestCase("tests/integration/functions-1.js")
+
+
+ [Test] def functions_as_ternary_operands():
+ RunTestCase("tests/integration/functions-as-ternary-operands.js")
+
+
+ [Test] def generator_inheritance_calling_super():
+ RunTestCase("tests/integration/generator-inheritance-calling-super.js")
+
+
+ [Test] def generator_inheritance_yielding_super():
+ RunTestCase("tests/integration/generator-inheritance-yielding-super.js")
+
+
+ [Test] def generator_inheritance():
+ RunTestCase("tests/integration/generator-inheritance.js")
+
+
+ [Test] def implicit_array_to_native_array_cast():
+ RunTestCase("tests/integration/implicit-array-to-native-array-cast.js")
+
+
+ [Test] def implict_bool_hierarchy():
+ RunTestCase("tests/integration/implict-bool-hierarchy.js")
+
+
+ [Test] def inferred_GetComponent():
+ RunTestCase("tests/integration/inferred-GetComponent.js")
+
+
+ [Test] def initializeorder():
+ RunTestCase("tests/integration/initializeorder.js")
+
+
+ [Test] def interface_properties():
+ RunTestCase("tests/integration/interface-properties.js")
+
+
+ [Test] def interfaces_1():
+ RunTestCase("tests/integration/interfaces-1.js")
+
+
+ [Test] def internal_field():
+ RunTestCase("tests/integration/internal-field.js")
+
+
+ [Test] def invalidil():
+ RunTestCase("tests/integration/invalidil.js")
+
+
+ [Test] def length_string():
+ RunTestCase("tests/integration/length-string.js")
+
+
+ [Test] def linq_array_ToList():
+ RunTestCase("tests/integration/linq-array-ToList.js")
+
+
+ [Test] def linq_function_inference():
+ RunTestCase("tests/integration/linq-function-inference.js")
+
+
+ [Test] def linq_lambda_inference():
+ RunTestCase("tests/integration/linq-lambda-inference.js")
+
+
+ [Test] def magicclass():
+ RunTestCase("tests/integration/magicclass.js")
+
+
+ [Test] def magicconstructor():
+ RunTestCase("tests/integration/magicconstructor.js")
+
+
+ [Test] def magicconstructor_2():
+ RunTestCase("tests/integration/magicconstructor_2.js")
+
+
+ [Test] def multidimensional_array_of_struct():
+ RunTestCase("tests/integration/multidimensional-array-of-struct.js")
+
+
+ [Test] def multidimensional_arrays_1():
+ RunTestCase("tests/integration/multidimensional-arrays-1.js")
+
+
+ [Test] def nested_class_1():
+ RunTestCase("tests/integration/nested-class-1.js")
+
+
+ [Test] def nested_classes():
+ RunTestCase("tests/integration/nested-classes.js")
+
+
+ [Test] def new_1():
+ RunTestCase("tests/integration/new-1.js")
+
+
+ [Test] def not_in():
+ RunTestCase("tests/integration/not-in.js")
+
+
+ [Test] def null_initializer():
+ RunTestCase("tests/integration/null-initializer.js")
+
+
+ [Test] def operators_4():
+ RunTestCase("tests/integration/operators-4.js")
+
+
+ [Test] def operators_5():
+ RunTestCase("tests/integration/operators-5.js")
+
+
+ [Test] def override_1():
+ RunTestCase("tests/integration/override-1.js")
+
+
+ [Test] def param_test():
+ RunTestCase("tests/integration/param_test.js")
+
+
+ [Test] def parse_int():
+ RunTestCase("tests/integration/parse_int.js")
+
+
+ [Test] def private_duck():
+ RunTestCase("tests/integration/private-duck.js")
+
+
+ [Test] def properties():
+ RunTestCase("tests/integration/properties.js")
+
+
+ [Test] def quack_fu():
+ RunTestCase("tests/integration/quack-fu.js")
+
+
+ [Test] def question_mark():
+ RunTestCase("tests/integration/question_mark.js")
+
+
+ [Test] def raw_array_indexing():
+ RunTestCase("tests/integration/raw-array-indexing.js")
+
+
+ [Test] def rethrow():
+ RunTestCase("tests/integration/rethrow.js")
+
+
+ [Test] def script_attributes():
+ RunTestCase("tests/integration/script-attributes.js")
+
+
+ [Test] def script_properties():
+ RunTestCase("tests/integration/script-properties.js")
+
+
+ [Test] def shift_left_bitwise_or():
+ RunTestCase("tests/integration/shift-left-bitwise-or.js")
+
+
+ [Test] def static_instance_overload_resolution():
+ RunTestCase("tests/integration/static-instance-overload-resolution.js")
+
+
+ [Test] def string_append():
+ RunTestCase("tests/integration/string-append.js")
+
+
+ [Test] def string_concat():
+ RunTestCase("tests/integration/string-concat.js")
+
+
+ [Test] def switch_3():
+ RunTestCase("tests/integration/switch-3.js")
+
+
+ [Test] def switch_fallthrough():
+ RunTestCase("tests/integration/switch-fallthrough.js")
+
+
+ [Test] def switch_simple_2():
+ RunTestCase("tests/integration/switch-simple-2.js")
+
+
+ [Test] def switch_simple():
+ RunTestCase("tests/integration/switch-simple.js")
+
+
+ [Test] def switch_with_loop():
+ RunTestCase("tests/integration/switch-with-loop.js")
+
+
+ [Test] def switch():
+ RunTestCase("tests/integration/switch.js")
+
+
+ [Test] def transform_collider_bounds():
+ RunTestCase("tests/integration/transform-collider-bounds.js")
+
+
+ [Test] def typecast_1():
+ RunTestCase("tests/integration/typecast-1.js")
+
+
+ [Test] def typeof_1():
+ RunTestCase("tests/integration/typeof-1.js")
+
+
+ [Test] def typeof_2():
+ RunTestCase("tests/integration/typeof-2.js")
+
+
+ [Test] def types_1():
+ RunTestCase("tests/integration/types-1.js")
+
+
+ [Test] def uint_1():
+ RunTestCase("tests/integration/uint-1.js")
+
+
+ [Test] def ulong_bitshift_1():
+ RunTestCase("tests/integration/ulong-bitshift-1.js")
+
+
+ [Test] def ulong_bitshift_overflow_regression():
+ RunTestCase("tests/integration/ulong-bitshift-overflow-regression.js")
+
+
+ [Test] def value_types_1():
+ RunTestCase("tests/integration/value-types-1.js")
+
+
+ [Test] def valuetypes_1():
+ RunTestCase("tests/integration/valuetypes-1.js")
+
+
+ [Test] def varargs_in_constructor_with_vector3():
+ RunTestCase("tests/integration/varargs-in-constructor-with-vector3.js")
+
+
+ [Test] def varargs_with_vector3():
+ RunTestCase("tests/integration/varargs-with-vector3.js")
+
+
+ [Test] def variable_declaration_2():
+ RunTestCase("tests/integration/variable-declaration-2.js")
+
+
+ [Test] def variable_declaration():
+ RunTestCase("tests/integration/variable-declaration.js")
+
+
+ [Test] def variables():
+ RunTestCase("tests/integration/variables.js")
+
+
+ [Test] def vars_1():
+ RunTestCase("tests/integration/vars-1.js")
+
+
+ [Test] def yield_null():
+ RunTestCase("tests/integration/yield-null.js")
+
+
+ [Test] def Array_cast_to_native_array_of_struct():
+ RunTestCase("tests/ducky/Array-cast-to-native-array-of-struct.js")
+
+
+ [Test] def Array_length():
+ RunTestCase("tests/ducky/Array-length.js")
+
+
+ [Test] def Array_of_struct_with_struct_loop_update_as_duck():
+ RunTestCase("tests/ducky/Array-of-struct-with-struct-loop-update-as-duck.js")
+
+
+ [Test] def Array_of_struct_with_struct_loop_update():
+ RunTestCase("tests/ducky/Array-of-struct-with-struct-loop-update.js")
+
+
+ [Test] def accessor_2_duck():
+ RunTestCase("tests/ducky/accessor-2-duck.js")
+
+
+ [Test] def accessor_duck():
+ RunTestCase("tests/ducky/accessor-duck.js")
+
+
+ [Test] def ambigous_call():
+ RunTestCase("tests/ducky/ambigous-call.js")
+
+
+ [Test] def array_access():
+ RunTestCase("tests/ducky/array-access.js")
+
+
+ [Test] def array_cast_2():
+ RunTestCase("tests/ducky/array-cast-2.js")
+
+
+ [Test] def array_cast_3():
+ RunTestCase("tests/ducky/array-cast-3.js")
+
+
+ [Test] def array_cast_4():
+ RunTestCase("tests/ducky/array-cast-4.js")
+
+
+ [Test] def array_cast_5():
+ RunTestCase("tests/ducky/array-cast-5.js")
+
+
+ [Test] def array_iterate():
+ RunTestCase("tests/ducky/array-iterate.js")
+
+
+ [Test] def array_nest_1():
+ RunTestCase("tests/ducky/array-nest-1.js")
+
+
+ [Test] def array_nest_2():
+ RunTestCase("tests/ducky/array-nest-2.js")
+
+
+ [Test] def array_polymorphic_foreach():
+ RunTestCase("tests/ducky/array-polymorphic-foreach.js")
+
+
+ [Test] def array_push_typesjs():
+ RunTestCase("tests/ducky/array-push-typesjs.js")
+
+
+ [Test] def auto_coroutine_2_duck():
+ RunTestCase("tests/ducky/auto-coroutine-2-duck.js")
+
+
+ [Test] def auto_coroutine_duck():
+ RunTestCase("tests/ducky/auto-coroutine-duck.js")
+
+
+ [Test] def auto_coroutine():
+ RunTestCase("tests/ducky/auto-coroutine.js")
+
+
+ [Test] def boolcast():
+ RunTestCase("tests/ducky/boolcast.js")
+
+
+ [Test] def coroutine_return():
+ RunTestCase("tests/ducky/coroutine-return.js")
+
+
+ [Test] def duck_1():
+ RunTestCase("tests/ducky/duck-1.js")
+
+
+ [Test] def duck_equality_operator_1():
+ RunTestCase("tests/ducky/duck-equality-operator-1.js")
+
+
+ [Test] def duck_implicit_bool_1():
+ RunTestCase("tests/ducky/duck-implicit-bool-1.js")
+
+
+ [Test] def duck_implicit_bool_and_with_simple_ref():
+ RunTestCase("tests/ducky/duck-implicit-bool-and-with-simple-ref.js")
+
+
+ [Test] def duck_implicit_bool_and():
+ RunTestCase("tests/ducky/duck-implicit-bool-and.js")
+
+
+ [Test] def duck_implicit_bool_full():
+ RunTestCase("tests/ducky/duck-implicit-bool-full.js")
+
+
+ [Test] def duck_implicit_bool_simple():
+ RunTestCase("tests/ducky/duck-implicit-bool-simple.js")
+
+
+ [Test] def duck_negation():
+ RunTestCase("tests/ducky/duck-negation.js")
+
+
+ [Test] def duck_return_property():
+ RunTestCase("tests/ducky/duck-return-property.js")
+
+
+ [Test] def duck():
+ RunTestCase("tests/ducky/duck.js")
+
+
+ [Test] def ducktyped_1():
+ RunTestCase("tests/ducky/ducktyped-1.js")
+
+
+ [Test] def ducktyping_2():
+ RunTestCase("tests/ducky/ducktyping-2.js")
+
+
+ [Test] def ducktyping_3():
+ RunTestCase("tests/ducky/ducktyping-3.js")
+
+
+ [Test] def ducktyping():
+ RunTestCase("tests/ducky/ducktyping.js")
+
+
+ [Test] def ducky_1():
+ RunTestCase("tests/ducky/ducky-1.js")
+
+
+ [Test] def ducky_2():
+ RunTestCase("tests/ducky/ducky_2.js")
+
+
+ [Test] def ducky_3():
+ RunTestCase("tests/ducky/ducky_3.js")
+
+
+ [Test] def ducky_4():
+ RunTestCase("tests/ducky/ducky_4.js")
+
+
+ [Test] def ducky_5():
+ RunTestCase("tests/ducky/ducky_5.js")
+
+
+ [Test] def ducky_6():
+ RunTestCase("tests/ducky/ducky_6.js")
+
+
+ [Test] def implicit_conversion():
+ RunTestCase("tests/ducky/implicit-conversion.js")
+
+
+ [Test] def native_array_of_struct_with_struct_loop_update_as_duck():
+ RunTestCase("tests/ducky/native-array-of-struct-with-struct-loop-update-as-duck.js")
+
+
+ [Test] def native_array_to_Array_as_duck():
+ RunTestCase("tests/ducky/native-array-to-Array-as-duck.js")
+
+
+ [Test] def null_assign():
+ RunTestCase("tests/ducky/null-assign.js")
+
+
+ [Test] def var_with_no_initializer():
+ RunTestCase("tests/ducky/var-with-no-initializer.js")
+
+
+ [Test] def virtual_test():
+ RunTestCase("tests/ducky/virtual-test.js")
+
\ No newline at end of file
diff --git a/src/UnityScript.Tests/ErrorMessagesTestFixture.Generated.boo b/src/UnityScript.Tests/ErrorMessagesTestFixture.Generated.boo
index 7fcbaf1..1012c35 100755
--- a/src/UnityScript.Tests/ErrorMessagesTestFixture.Generated.boo
+++ b/src/UnityScript.Tests/ErrorMessagesTestFixture.Generated.boo
@@ -5,111 +5,227 @@ import NUnit.Framework
partial class ErrorMessagesTestFixture:
- [Test]
- def array_struct_warning():
+
+ [Test] def Boo_Lang_List_is_not_visible_by_default():
+ RunTestCase("tests/error-messages/Boo.Lang.List-is-not-visible-by-default.js")
+
+
+ [Test] def array_instantiation_with_array_multiplication():
+ RunTestCase("tests/error-messages/array-instantiation-with-array-multiplication.js")
+
+
+ [Test] def array_struct_warning():
RunTestCase("tests/error-messages/array-struct-warning.js")
- [Test]
- def builtins():
+
+ [Test] def array_type_name():
+ RunTestCase("tests/error-messages/array-type-name.js")
+
+
+ [Test] def bitwise_with_bool_operands_warning():
+ RunTestCase("tests/error-messages/bitwise-with-bool-operands-warning.js")
+
+
+ [Test] def builtins():
RunTestCase("tests/error-messages/builtins.js")
- [Test]
- def cannot_convert_error():
+
+ [Test] def cannot_convert_enum_to_float():
+ RunTestCase("tests/error-messages/cannot-convert-enum-to-float.js")
+
+
+ [Test] def cannot_convert_error():
RunTestCase("tests/error-messages/cannot-convert-error.js")
- [Test]
- def conditional_compilation_with_pragma_strict():
- RunTestCase("tests/error-messages/conditional-compilation-with-pragma-strict.js")
+
+ [Test] def cannot_start_coroutine_from_static_function():
+ RunTestCase("tests/error-messages/cannot-start-coroutine-from-static-function.js")
+
+
+ [Test] def do_while_const_condition():
+ RunTestCase("tests/error-messages/do-while-const-condition.js")
- [Test]
- def error_for_final_used_as_identifier():
+
+ [Test] def double_array_in_float_array_var_initializer():
+ RunTestCase("tests/error-messages/double-array-in-float-array-var-initializer.js")
+
+
+ [Test] def error_for_final_used_as_identifier():
RunTestCase("tests/error-messages/error-for-final-used-as-identifier.js")
- [Test]
- def implicit_main_shouldnt_be_redefined():
+
+ [Test] def error_for_internal_used_as_identifier():
+ RunTestCase("tests/error-messages/error-for-internal-used-as-identifier.js")
+
+
+ [Test] def for_variable_already_defined():
+ RunTestCase("tests/error-messages/for-variable-already-defined.js")
+
+
+ [Test] def for_with_unreachable_update():
+ RunTestCase("tests/error-messages/for-with-unreachable-update.js")
+
+
+ [Test] def function_type_name():
+ RunTestCase("tests/error-messages/function-type-name.js")
+
+
+ [Test] def generic_type_name():
+ RunTestCase("tests/error-messages/generic-type-name.js")
+
+
+ [Test] def implicit_main_shouldnt_be_redefined():
RunTestCase("tests/error-messages/implicit-main-shouldnt-be-redefined.js")
- [Test]
- def incompatible_initializer_1():
+
+ [Test] def incompatible_initializer_1():
RunTestCase("tests/error-messages/incompatible-initializer-1.js")
- [Test]
- def inner_text():
+
+ [Test] def inner_text():
RunTestCase("tests/error-messages/inner_text.js")
- [Test]
- def interface_errors():
+
+ [Test] def interface_errors():
RunTestCase("tests/error-messages/interface-errors.js")
- [Test]
- def iterator_warning():
+
+ [Test] def invalid_array_index():
+ RunTestCase("tests/error-messages/invalid-array-index.js")
+
+
+ [Test] def invalid_attribute_sequence():
+ RunTestCase("tests/error-messages/invalid-attribute-sequence.js")
+
+
+ [Test] def invalid_generator_return_type():
+ RunTestCase("tests/error-messages/invalid-generator-return-type.js")
+
+
+ [Test] def invalid_setter_return_type():
+ RunTestCase("tests/error-messages/invalid-setter-return-type.js")
+
+
+ [Test] def invalid_setter():
+ RunTestCase("tests/error-messages/invalid-setter.js")
+
+
+ [Test] def iterator_warning():
RunTestCase("tests/error-messages/iterator-warning.js")
- [Test]
- def missing_brace():
+
+ [Test] def loop_with_no_unreacheable_code_shouldnt_cause_warning():
+ RunTestCase("tests/error-messages/loop-with-no-unreacheable-code-shouldnt-cause-warning.js")
+
+
+ [Test] def missing_brace():
RunTestCase("tests/error-messages/missing-brace.js")
- [Test]
- def nolinenumber():
+
+ [Test] def nolinenumber():
RunTestCase("tests/error-messages/nolinenumber.js")
- [Test]
- def obsolete_2():
+
+ [Test] def non_strict_does_not_warn_about_downcast():
+ RunTestCase("tests/error-messages/non-strict-does-not-warn-about-downcast.js")
+
+
+ [Test] def obsolete_2():
RunTestCase("tests/error-messages/obsolete-2.js")
- [Test]
- def obsolete():
+
+ [Test] def obsolete():
RunTestCase("tests/error-messages/obsolete.js")
- [Test][Ignore("requires new parser infrastructure")]
- def overeager_semicolon():
+ [Ignore("requires new parser infrastructure")]
+ [Test] def overeager_semicolon():
RunTestCase("tests/error-messages/overeager-semicolon.js")
- [Test][Ignore("requires new parser infrastructure")]
- def overeager_semicolon2():
+ [Ignore("requires new parser infrastructure")]
+ [Test] def overeager_semicolon2():
RunTestCase("tests/error-messages/overeager-semicolon2.js")
- [Test]
- def pragma_strict_2():
- RunTestCase("tests/error-messages/pragma-strict-2.js")
+
+ [Test] def rethrow_outside_catch():
+ RunTestCase("tests/error-messages/rethrow-outside-catch.js")
+
+
+ [Test] def semicolon_2():
+ RunTestCase("tests/error-messages/semicolon-2.js")
+
+
+ [Test] def semicolon():
+ RunTestCase("tests/error-messages/semicolon.js")
- [Test]
- def pragma_strict_3js():
- RunTestCase("tests/error-messages/pragma-strict-3js.js")
+
+ [Test] def static_instance_overload_resolution():
+ RunTestCase("tests/error-messages/static-instance-overload-resolution.js")
- [Test]
- def pragma_strict_4():
- RunTestCase("tests/error-messages/pragma-strict-4.js")
+
+ [Test] def strict_conditional_compilation():
+ RunTestCase("tests/error-messages/strict-conditional-compilation.js")
- [Test]
- def pragma_strict():
- RunTestCase("tests/error-messages/pragma-strict.js")
+
+ [Test] def strict_disallows_dynamic_dispatching():
+ RunTestCase("tests/error-messages/strict-disallows-dynamic-dispatching.js")
- [Test]
- def semicolon_2():
- RunTestCase("tests/error-messages/semicolon-2.js")
+
+ [Test] def strict_disallows_implicit_variable_declaration():
+ RunTestCase("tests/error-messages/strict-disallows-implicit-variable-declaration.js")
- [Test]
- def semicolon():
- RunTestCase("tests/error-messages/semicolon.js")
+
+ [Test] def strict_nongeneric_GetComponent():
+ RunTestCase("tests/error-messages/strict-nongeneric-GetComponent.js")
- [Test]
- def unused_variable():
+
+ [Test] def strict_warns_about_array_downcast():
+ RunTestCase("tests/error-messages/strict-warns-about-array-downcast.js")
+
+
+ [Test] def strict_warns_about_downcast():
+ RunTestCase("tests/error-messages/strict-warns-about-downcast.js")
+
+
+ [Test] def strict_warns_about_duck_downcast():
+ RunTestCase("tests/error-messages/strict-warns-about-duck-downcast.js")
+
+
+ [Test] def strict_with_downcast_off_disallows_downcast():
+ RunTestCase("tests/error-messages/strict-with-downcast-off-disallows-downcast.js")
+
+
+ [Test] def strict_with_downcast_off_disallows_duck_downcast():
+ RunTestCase("tests/error-messages/strict-with-downcast-off-disallows-duck-downcast.js")
+
+
+ [Test] def strict_with_pragma_downcast_does_not_warn_about_downcast():
+ RunTestCase("tests/error-messages/strict-with-pragma-downcast-does-not-warn-about-downcast.js")
+
+
+ [Test] def switch_has_no_cases():
+ RunTestCase("tests/error-messages/switch-has-no-cases.js")
+
+
+ [Test] def unused_variable():
RunTestCase("tests/error-messages/unused-variable.js")
- [Test]
- def virtual_warning():
+
+ [Test] def virtual_warning():
RunTestCase("tests/error-messages/virtual-warning.js")
- [Test]
- def void_declaration():
+
+ [Test] def void_declaration():
RunTestCase("tests/error-messages/void-declaration.js")
- [Test]
- def void_in_hashtable():
+
+ [Test] def void_in_hashtable():
RunTestCase("tests/error-messages/void-in-hashtable.js")
- [Test]
- def voidcomparison():
+
+ [Test] def voidcomparison():
RunTestCase("tests/error-messages/voidcomparison.js")
+
+
+ [Test] def yield_from_try_catch_finally():
+ RunTestCase("tests/error-messages/yield-from-try-catch-finally.js")
\ No newline at end of file
diff --git a/src/UnityScript.Tests/EvalCompilationTest.boo b/src/UnityScript.Tests/EvalCompilationTest.boo
new file mode 100644
index 0000000..ab0538c
--- /dev/null
+++ b/src/UnityScript.Tests/EvalCompilationTest.boo
@@ -0,0 +1,45 @@
+namespace UnityScript.Tests
+
+import System
+import System.Reflection
+
+import NUnit.Framework
+import UnityScript
+import Boo.Lang.Compiler.IO
+
+[TestFixture]
+class EvalCompilationTest(AbstractCompilerTest):
+
+ override def CreateCompilerPipeline():
+ return UnityScriptCompiler.Pipelines.CompileToFile()
+
+ [Test]
+ def OnlyAssembliesWithReferencedTypesEndUpBeingReferenced():
+
+ expected = ("mscorlib", "UnityScript", "UnityScript.Tests")
+ code = """
+ eval("print(\"hello\")");
+ """
+ AssertAssemblyReferencesForEval expected, code
+
+ [Test]
+ def OnlyAssembliesWithReferencedTypesEndUpBeingReferencedIncludingGenerics():
+
+ expected = ("Boo.Lang", "mscorlib", "UnityScript", "UnityScript.Tests")
+ code = """
+ var foo = new Boo.Lang.List.();
+ eval("print(\"hello\")");
+ """
+ AssertAssemblyReferencesForEval expected, code
+
+ def AssertAssemblyReferencesForEval(expected as (string), code as string):
+
+ result = CompileTestCase(StringInput("t$(++_testId).js", code))
+ assert len(result.Errors) == 0, result.Errors.ToString()
+
+ actual = array(assemblyName.Name for assemblyName in Assembly.LoadFrom(Parameters.OutputAssembly).GetReferencedAssemblies())
+ Array.Sort(actual)
+ Assert.AreEqual(expected, actual)
+
+ _testId = 0
+
diff --git a/src/UnityScript.Tests/EvalTestFixture.boo b/src/UnityScript.Tests/EvalTestFixture.boo
index 68535d0..ce1c233 100755
--- a/src/UnityScript.Tests/EvalTestFixture.boo
+++ b/src/UnityScript.Tests/EvalTestFixture.boo
@@ -6,87 +6,95 @@ import NUnit.Framework
[TestFixture]
class EvalTestFixture(AbstractIntegrationTestFixture):
- [Test]
- def assembly_caching_1():
+
+ [Test] def assembly_caching_1():
RunTestCase("tests/eval/assembly-caching-1.js")
- [Test]
- def assembly_caching_2():
+
+ [Test] def assembly_caching_2():
RunTestCase("tests/eval/assembly-caching-2.js")
- [Test]
- def class_1():
- RunTestCase("tests/eval/class-1.js")
+
+ [Test] def assembly_references_are_visible_inside_eval_1():
+ RunTestCase("tests/eval/assembly-references-are-visible-inside-eval-1.js")
- [Test]
- def class_2():
- RunTestCase("tests/eval/class-2.js")
+
+ [Test] def assembly_references_are_visible_inside_eval_2():
+ RunTestCase("tests/eval/assembly-references-are-visible-inside-eval-2.js")
- [Test]
- def class_3():
- RunTestCase("tests/eval/class-3.js")
+
+ [Test] def class_1():
+ RunTestCase("tests/eval/class-1.js")
- [Test]
- def class_is_visible_1():
+
+ [Test] def class_is_visible_1():
RunTestCase("tests/eval/class-is-visible-1.js")
- [Test]
- def eval_in_static_function_1():
+
+ [Test] def eval_in_static_function_1():
RunTestCase("tests/eval/eval-in-static-function-1.js")
- [Test]
- def eval_in_static_function_2():
+ [Category("FailsOnMono")]
+ [Test] def eval_in_static_function_2():
RunTestCase("tests/eval/eval-in-static-function-2.js")
- [Test]
- def eval_in_static_function_3():
+
+ [Test] def eval_in_static_function_3():
RunTestCase("tests/eval/eval-in-static-function-3.js")
- [Test]
- def functions_1():
+
+ [Test] def functions_1():
RunTestCase("tests/eval/functions-1.js")
- [Test]
- def functions_2():
+
+ [Test] def functions_2():
RunTestCase("tests/eval/functions-2.js")
- [Test]
- def return_value_2():
+
+ [Test] def imports_are_visible_inside_eval_1():
+ RunTestCase("tests/eval/imports-are-visible-inside-eval-1.js")
+
+
+ [Test] def imports_are_visible_inside_eval_2():
+ RunTestCase("tests/eval/imports-are-visible-inside-eval-2.js")
+
+
+ [Test] def return_value_2():
RunTestCase("tests/eval/return-value-2.js")
- [Test]
- def return_value_3():
+
+ [Test] def return_value_3():
RunTestCase("tests/eval/return-value-3.js")
- [Test]
- def return_value():
+
+ [Test] def return_value():
RunTestCase("tests/eval/return-value.js")
- [Test]
- def simple_1():
+
+ [Test] def simple_1():
RunTestCase("tests/eval/simple-1.js")
- [Test]
- def variable_initializer_doesnt_move():
+
+ [Test] def variable_initializer_doesnt_move():
RunTestCase("tests/eval/variable-initializer-doesnt-move.js")
- [Test]
- def variables_1():
+
+ [Test] def variables_1():
RunTestCase("tests/eval/variables-1.js")
- [Test]
- def variables_2():
+
+ [Test] def variables_2():
RunTestCase("tests/eval/variables-2.js")
- [Test]
- def variables_3():
+
+ [Test] def variables_3():
RunTestCase("tests/eval/variables-3.js")
- [Test]
- def variables_4():
+
+ [Test] def variables_4():
RunTestCase("tests/eval/variables-4.js")
- [Test]
- def variables_5():
+
+ [Test] def variables_5():
RunTestCase("tests/eval/variables-5.js")
\ No newline at end of file
diff --git a/src/UnityScript.Tests/ExpandoTestFixture.boo b/src/UnityScript.Tests/ExpandoTestFixture.boo
index 4114a3f..5ac1eb1 100755
--- a/src/UnityScript.Tests/ExpandoTestFixture.boo
+++ b/src/UnityScript.Tests/ExpandoTestFixture.boo
@@ -6,20 +6,19 @@ import NUnit.Framework
[TestFixture]
class ExpandoTestFixture(AbstractIntegrationTestFixture):
- override def CreateCompiler():
- compiler = super()
- compiler.Parameters.Expando = true
- return compiler
+ override def SetCompilationOptions():
+ super()
+ Parameters.Expando = true
- [Test]
- def expando_1():
+
+ [Test] def expando_1():
RunTestCase("tests/expando/expando-1.js")
- [Test]
- def expando_2():
+
+ [Test] def expando_2():
RunTestCase("tests/expando/expando-2.js")
- [Test]
- def expando_gc_3():
+ [Category("FailsOnMono")]
+ [Test] def expando_gc_3():
RunTestCase("tests/expando/expando-gc-3.js")
\ No newline at end of file
diff --git a/src/UnityScript.Tests/GenericsTestFixture.Generated.boo b/src/UnityScript.Tests/GenericsTestFixture.Generated.boo
index 9b128d9..24b9b58 100644
--- a/src/UnityScript.Tests/GenericsTestFixture.Generated.boo
+++ b/src/UnityScript.Tests/GenericsTestFixture.Generated.boo
@@ -6,11 +6,27 @@ import NUnit.Framework
[TestFixture]
class GenericsTestFixture(AbstractIntegrationTestFixture):
- [Test]
- def generic_list_instantiation_1():
+
+ [Test] def generic_dictionary_of_string_to_function():
+ RunTestCase("tests/generics/generic-dictionary-of-string-to-function.js")
+
+
+ [Test] def generic_list_instantiation_1():
RunTestCase("tests/generics/generic-list-instantiation-1.js")
- [Test]
- def generic_method_1():
+
+ [Test] def generic_method_1():
RunTestCase("tests/generics/generic-method-1.js")
+
+
+ [Test] def generic_method_arguments_in_generic_class():
+ RunTestCase("tests/generics/generic-method-arguments-in-generic-class.js")
+
+
+ [Test] def generic_method_arguments():
+ RunTestCase("tests/generics/generic-method-arguments.js")
+
+
+ [Test] def generic_method_overload_in_base_class():
+ RunTestCase("tests/generics/generic-method-overload-in-base-class.js")
\ No newline at end of file
diff --git a/src/UnityScript.Tests/IntegrationTestFixture.boo b/src/UnityScript.Tests/IntegrationTestFixture.boo
deleted file mode 100644
index 69fbedb..0000000
--- a/src/UnityScript.Tests/IntegrationTestFixture.boo
+++ /dev/null
@@ -1,628 +0,0 @@
-
-namespace UnityScript.Tests
-
-import NUnit.Framework
-
-[TestFixture]
-class IntegrationTestFixture(AbstractIntegrationTestFixture):
-
- [Test]
- def accessor_2_duck():
- RunTestCase("tests/integration/accessor-2-duck.js")
-
- [Test]
- def accessor_2():
- RunTestCase("tests/integration/accessor-2.js")
-
- [Test]
- def accessor_3_duck():
- RunTestCase("tests/integration/accessor-3-duck.js")
-
- [Test]
- def accessor_duck():
- RunTestCase("tests/integration/accessor-duck.js")
-
- [Test]
- def accessor():
- RunTestCase("tests/integration/accessor.js")
-
- [Test]
- def ambigous_call():
- RunTestCase("tests/integration/ambigous-call.js")
-
- [Test]
- def anonymous_function_type_1():
- RunTestCase("tests/integration/anonymous-function-type-1.js")
-
- [Test]
- def anonymous_function_type_2():
- RunTestCase("tests/integration/anonymous-function-type-2.js")
-
- [Test]
- def anonymous_function_type_3():
- RunTestCase("tests/integration/anonymous-function-type-3.js")
-
- [Test]
- def array_access():
- RunTestCase("tests/integration/array-access.js")
-
- [Test]
- def array_Add():
- RunTestCase("tests/integration/array-Add.js")
-
- [Test]
- def array_cast_2():
- RunTestCase("tests/integration/array-cast-2.js")
-
- [Test]
- def array_cast_3():
- RunTestCase("tests/integration/array-cast-3.js")
-
- [Test]
- def array_cast_4():
- RunTestCase("tests/integration/array-cast-4.js")
-
- [Test]
- def array_cast_5():
- RunTestCase("tests/integration/array-cast-5.js")
-
- [Test]
- def array_cast_6():
- RunTestCase("tests/integration/array-cast-6.js")
-
- [Test]
- def array_cast():
- RunTestCase("tests/integration/array-cast.js")
-
- [Test]
- def array_concat_1():
- RunTestCase("tests/integration/array-concat-1.js")
-
- [Test]
- def array_concat_2():
- RunTestCase("tests/integration/array-concat-2.js")
-
- [Test]
- def array_create():
- RunTestCase("tests/integration/array-create.js")
-
- [Test]
- def array_ctor_with_single_null_element():
- RunTestCase("tests/integration/array-ctor-with-single-null-element.js")
-
- [Test]
- def array_implicit_from_null_enumerable():
- RunTestCase("tests/integration/array-implicit-from-null-enumerable.js")
-
- [Test]
- def array_implicit_from_null():
- RunTestCase("tests/integration/array-implicit-from-null.js")
-
- [Test]
- def array_iterate():
- RunTestCase("tests/integration/array-iterate.js")
-
- [Test]
- def array_iteration_with_nulls():
- RunTestCase("tests/integration/array-iteration-with-nulls.js")
-
- [Test]
- def array_join():
- RunTestCase("tests/integration/array-join.js")
-
- [Test]
- def array_length_2():
- RunTestCase("tests/integration/array-length-2.js")
-
- [Test]
- def array_length():
- RunTestCase("tests/integration/array-length.js")
-
- [Test]
- def array_nest_1():
- RunTestCase("tests/integration/array-nest-1.js")
-
- [Test]
- def array_nest_2():
- RunTestCase("tests/integration/array-nest-2.js")
-
- [Test]
- def array_polymorphic_foreach():
- RunTestCase("tests/integration/array-polymorphic-foreach.js")
-
- [Test]
- def array_pop():
- RunTestCase("tests/integration/array-pop.js")
-
- [Test]
- def array_push_2():
- RunTestCase("tests/integration/array-push-2.js")
-
- [Test]
- def array_push_typesjs():
- RunTestCase("tests/integration/array-push-typesjs.js")
-
- [Test]
- def array_push():
- RunTestCase("tests/integration/array-push.js")
-
- [Test]
- def array_Remove():
- RunTestCase("tests/integration/array-Remove.js")
-
- [Test]
- def array_shift():
- RunTestCase("tests/integration/array-shift.js")
-
- [Test]
- def array_slice():
- RunTestCase("tests/integration/array-slice.js")
-
- [Test]
- def array_sort():
- RunTestCase("tests/integration/array-sort.js")
-
- [Test]
- def array_splice_2():
- RunTestCase("tests/integration/array-splice-2.js")
-
- [Test]
- def array_splice():
- RunTestCase("tests/integration/array-splice.js")
-
- [Test]
- def array_str():
- RunTestCase("tests/integration/array-str.js")
-
- [Test]
- def array_toString():
- RunTestCase("tests/integration/array-toString.js")
-
- [Test]
- def array_unshift():
- RunTestCase("tests/integration/array-unshift.js")
-
- [Test]
- def arrays_10():
- RunTestCase("tests/integration/arrays-10.js")
-
- [Test]
- def arrays_2():
- RunTestCase("tests/integration/arrays-2.js")
-
- [Test]
- def arrays_3():
- RunTestCase("tests/integration/arrays-3.js")
-
- [Test]
- def arrays_4():
- RunTestCase("tests/integration/arrays-4.js")
-
- [Test]
- def arrays_5():
- RunTestCase("tests/integration/arrays-5.js")
-
- [Test]
- def arrays_6():
- RunTestCase("tests/integration/arrays-6.js")
-
- [Test]
- def arrays_7():
- RunTestCase("tests/integration/arrays-7.js")
-
- [Test]
- def arrays_9():
- RunTestCase("tests/integration/arrays-9.js")
-
- [Test]
- def arrays():
- RunTestCase("tests/integration/arrays.js")
-
- [Test]
- def assign_iterator():
- RunTestCase("tests/integration/assign_iterator.js")
-
- [Test]
- def attributes_2():
- RunTestCase("tests/integration/attributes-2.js")
-
- [Test]
- def attributes():
- RunTestCase("tests/integration/attributes.js")
-
- [Test]
- def auto_coroutine_2_duck():
- RunTestCase("tests/integration/auto-coroutine-2-duck.js")
-
- [Test]
- def auto_coroutine_2():
- RunTestCase("tests/integration/auto-coroutine-2.js")
-
- [Test]
- def auto_coroutine_duck():
- RunTestCase("tests/integration/auto-coroutine-duck.js")
-
- [Test]
- def auto_coroutine_return_2():
- RunTestCase("tests/integration/auto-coroutine-return-2.js")
-
- [Test]
- def auto_coroutine():
- RunTestCase("tests/integration/auto-coroutine.js")
-
- [Test]
- def boolcast():
- RunTestCase("tests/integration/boolcast.js")
-
- [Test]
- def chars():
- RunTestCase("tests/integration/chars.js")
-
- [Test]
- def comma_parsing():
- RunTestCase("tests/integration/comma-parsing.js")
-
- [Test]
- def constructor_1():
- RunTestCase("tests/integration/constructor-1.js")
-
- [Test]
- def constructor_2():
- RunTestCase("tests/integration/constructor_2.js")
-
- [Test]
- def continue_issue():
- RunTestCase("tests/integration/continue-issue.js")
-
- [Test]
- def coroutine_2():
- RunTestCase("tests/integration/coroutine-2.js")
-
- [Test]
- def coroutine_3():
- RunTestCase("tests/integration/coroutine-3.js")
-
- [Test]
- def coroutine_4():
- RunTestCase("tests/integration/coroutine-4.js")
-
- [Test]
- def coroutine_5():
- RunTestCase("tests/integration/coroutine-5.js")
-
- [Test]
- def coroutine_return_type_1():
- RunTestCase("tests/integration/coroutine-return-type-1.js")
-
- [Test]
- def coroutine_return():
- RunTestCase("tests/integration/coroutine-return.js")
-
- [Test]
- def coroutine_try_catch():
- RunTestCase("tests/integration/coroutine-try-catch.js")
-
- [Test]
- def coroutine():
- RunTestCase("tests/integration/coroutine.js")
-
- [Test]
- def crash():
- RunTestCase("tests/integration/crash.js")
-
- [Test]
- def duck_1():
- RunTestCase("tests/integration/duck-1.js")
-
- [Test]
- def duck_equality_operator_1():
- RunTestCase("tests/integration/duck-equality-operator-1.js")
-
- [Test]
- def duck_implicit_bool_1():
- RunTestCase("tests/integration/duck-implicit-bool-1.js")
-
- [Test]
- def duck_implicit_bool_full():
- RunTestCase("tests/integration/duck-implicit-bool-full.js")
-
- [Test]
- def duck_implicit_bool_simple():
- RunTestCase("tests/integration/duck-implicit-bool-simple.js")
-
- [Test]
- def duck_return_property():
- RunTestCase("tests/integration/duck-return-property.js")
-
- [Test]
- def duck():
- RunTestCase("tests/integration/duck.js")
-
- [Test]
- def ducktyped_1():
- RunTestCase("tests/integration/ducktyped-1.js")
-
- [Test]
- def ducktyping_2():
- RunTestCase("tests/integration/ducktyping-2.js")
-
- [Test]
- def ducktyping_3():
- RunTestCase("tests/integration/ducktyping-3.js")
-
- [Test]
- def ducktyping():
- RunTestCase("tests/integration/ducktyping.js")
-
- [Test]
- def ducky_1():
- RunTestCase("tests/integration/ducky-1.js")
-
- [Test]
- def ducky_2():
- RunTestCase("tests/integration/ducky_2.js")
-
- [Test]
- def ducky_3():
- RunTestCase("tests/integration/ducky_3.js")
-
- [Test]
- def ducky_4():
- RunTestCase("tests/integration/ducky_4.js")
-
- [Test]
- def ducky_5():
- RunTestCase("tests/integration/ducky_5.js")
-
- [Test]
- def ducky_6():
- RunTestCase("tests/integration/ducky_6.js")
-
- [Test]
- def empty_string_array():
- RunTestCase("tests/integration/empty-string-array.js")
-
- [Test]
- def enum_1():
- RunTestCase("tests/integration/enum-1.js")
-
- [Test]
- def enum_2():
- RunTestCase("tests/integration/enum-2.js")
-
- [Test]
- def enum_3():
- RunTestCase("tests/integration/enum-3.js")
-
- [Test]
- def enum_4():
- RunTestCase("tests/integration/enum-4.js")
-
- [Test]
- def enum_5():
- RunTestCase("tests/integration/enum-5.js")
-
- [Test]
- def enum_conversion():
- RunTestCase("tests/integration/enum-conversion.js")
-
- [Test]
- def enumerator_array():
- RunTestCase("tests/integration/enumerator-array.js")
-
- [Test]
- def explicit_awake_function():
- RunTestCase("tests/integration/explicit-awake-function.js")
-
- [Test]
- def float_1():
- RunTestCase("tests/integration/float-1.js")
-
- [Test]
- def float_2():
- RunTestCase("tests/integration/float-2.js")
-
- [Test]
- def for_break_1():
- RunTestCase("tests/integration/for-break-1.js")
-
- [Test]
- def for_continue_1():
- RunTestCase("tests/integration/for-continue-1.js")
-
- [Test]
- def for_continue_2():
- RunTestCase("tests/integration/for-continue-2.js")
-
- [Test]
- def for_over_null():
- RunTestCase("tests/integration/for-over-null.js")
-
- [Test]
- def functions_1():
- RunTestCase("tests/integration/functions-1.js")
-
- [Test]
- def generator_inheritance_calling_super():
- RunTestCase("tests/integration/generator-inheritance-calling-super.js")
-
- [Test]
- def generator_inheritance_yielding_super():
- RunTestCase("tests/integration/generator-inheritance-yielding-super.js")
-
- [Test]
- def generator_inheritance():
- RunTestCase("tests/integration/generator-inheritance.js")
-
- [Test]
- def implicit_conversion():
- RunTestCase("tests/integration/implicit_conversion.js")
-
- [Test]
- def initializeorder():
- RunTestCase("tests/integration/initializeorder.js")
-
- [Test]
- def interfaces_1():
- RunTestCase("tests/integration/interfaces-1.js")
-
- [Test]
- def invalidil():
- RunTestCase("tests/integration/invalidil.js")
-
- [Test]
- def JSCheckFloatToIntOverflow():
- RunTestCase("tests/integration/JSCheckFloatToIntOverflow.js")
-
- [Test]
- def JSChooseOverload():
- RunTestCase("tests/integration/JSChooseOverload.js")
-
- [Test]
- def length_string():
- RunTestCase("tests/integration/length-string.js")
-
- [Test]
- def magicclass():
- RunTestCase("tests/integration/magicclass.js")
-
- [Test]
- def magicconstructor():
- RunTestCase("tests/integration/magicconstructor.js")
-
- [Test]
- def magicconstructor_2():
- RunTestCase("tests/integration/magicconstructor_2.js")
-
- [Test]
- def nested_class_1():
- RunTestCase("tests/integration/nested-class-1.js")
-
- [Test]
- def new_1():
- RunTestCase("tests/integration/new-1.js")
-
- [Test]
- def null_assign():
- RunTestCase("tests/integration/null-assign.js")
-
- [Test]
- def operators_4():
- RunTestCase("tests/integration/operators-4.js")
-
- [Test]
- def operators_5():
- RunTestCase("tests/integration/operators-5.js")
-
- [Test]
- def override_1():
- RunTestCase("tests/integration/override-1.js")
-
- [Test]
- def param_test():
- RunTestCase("tests/integration/param_test.js")
-
- [Test]
- def parse_int():
- RunTestCase("tests/integration/parse_int.js")
-
- [Test]
- def pragma_expando_1():
- RunTestCase("tests/integration/pragma-expando-1.js")
-
- [Test]
- def pragma_expando_2():
- RunTestCase("tests/integration/pragma-expando-2.js")
-
- [Test]
- def private_duck():
- RunTestCase("tests/integration/private-duck.js")
-
- [Test]
- def properties():
- RunTestCase("tests/integration/properties.js")
-
- [Test]
- def question_mark():
- RunTestCase("tests/integration/question_mark.js")
-
- [Test]
- def raw_array_indexing():
- RunTestCase("tests/integration/raw-array-indexing.js")
-
- [Test]
- def script_attributes():
- RunTestCase("tests/integration/script-attributes.js")
-
- [Test]
- def string_append():
- RunTestCase("tests/integration/string-append.js")
-
- [Test]
- def string_concat():
- RunTestCase("tests/integration/string-concat.js")
-
- [Test]
- def switch_3():
- RunTestCase("tests/integration/switch-3.js")
-
- [Test]
- def switch_fallthrough():
- RunTestCase("tests/integration/switch-fallthrough.js")
-
- [Test]
- def switch_simple_2():
- RunTestCase("tests/integration/switch-simple-2.js")
-
- [Test]
- def switch_simple():
- RunTestCase("tests/integration/switch-simple.js")
-
- [Test]
- def switch_with_loop():
- RunTestCase("tests/integration/switch-with-loop.js")
-
- [Test]
- def switch():
- RunTestCase("tests/integration/switch.js")
-
- [Test]
- def transform_collider_bounds():
- RunTestCase("tests/integration/transform-collider-bounds.js")
-
- [Test]
- def typecast_1():
- RunTestCase("tests/integration/typecast-1.js")
-
- [Test]
- def typeof_1():
- RunTestCase("tests/integration/typeof-1.js")
-
- [Test]
- def types_1():
- RunTestCase("tests/integration/types-1.js")
-
- [Test]
- def valuetypes_1():
- RunTestCase("tests/integration/valuetypes-1.js")
-
- [Test]
- def variable_declaration_2():
- RunTestCase("tests/integration/variable-declaration-2.js")
-
- [Test]
- def variable_declaration():
- RunTestCase("tests/integration/variable-declaration.js")
-
- [Test]
- def variables():
- RunTestCase("tests/integration/variables.js")
-
- [Test]
- def vars_1():
- RunTestCase("tests/integration/vars-1.js")
-
- [Test]
- def virtual_test():
- RunTestCase("tests/integration/virtual-test.js")
-
\ No newline at end of file
diff --git a/src/UnityScript.Tests/Lang/ArrayTest.boo b/src/UnityScript.Tests/Lang/ArrayTest.boo
new file mode 100644
index 0000000..70b9e26
--- /dev/null
+++ b/src/UnityScript.Tests/Lang/ArrayTest.boo
@@ -0,0 +1,20 @@
+namespace UnityScript.Tests.Lang
+
+import NUnit.Framework
+
+[TestFixture]
+class ArrayTest:
+
+ [Test]
+ def Slice():
+ fruits = UnityScript.Lang.Array() { "Banana", "Orange", "Apple", "Mango" }
+ Assert.AreEqual("Banana", fruits.slice(0, 1).ToString())
+ Assert.AreEqual("Orange,Apple,Mango", fruits.slice(1).ToString())
+ Assert.AreEqual("Apple,Mango", fruits.slice(-2).ToString())
+ Assert.AreEqual("Banana,Orange,Apple,Mango", fruits.ToString())
+
+
+
+
+
+
diff --git a/src/UnityScript.Tests/MonoBehaviour.boo b/src/UnityScript.Tests/MonoBehaviour.boo
old mode 100755
new mode 100644
index a4b07ef..842f17f
--- a/src/UnityScript.Tests/MonoBehaviour.boo
+++ b/src/UnityScript.Tests/MonoBehaviour.boo
@@ -14,7 +14,11 @@ struct Vector3:
z = z_
class Component:
- pass
+ def GetComponentsInChildren[of T]() as T:
+ return typeof(T)()
+
+ def GetComponentsInChildren[of T](instantiate as bool) as T:
+ if instantiate: return typeof(T)()
struct Bounds:
def IntersectRay(ray as Ray, ref result as single):
@@ -92,10 +96,16 @@ class MonoBehaviour(Component):
routine.MoveNext()
return routine.Current
- [DuckTyped]
+ [TypeInferenceRule(TypeInferenceRules.TypeReferencedByFirstArgument)]
+ def InferredGetComponent(type as System.Type) as Component:
+ return GetComponent(type)
+
def GetComponent(type as System.Type) as Component:
return _foo if ComponentFoo is type
return _bar
+
+ def GetComponents(type as System.Type) as (Component):
+ return (GetComponent(type),)
[DuckTyped]
def implicit_bool_test_false() as ImplicitBoolTest:
diff --git a/src/UnityScript.Tests/ParserTestFixture.Generated.boo b/src/UnityScript.Tests/ParserTestFixture.Generated.boo
index 0426607..f45e7b8 100644
--- a/src/UnityScript.Tests/ParserTestFixture.Generated.boo
+++ b/src/UnityScript.Tests/ParserTestFixture.Generated.boo
@@ -5,191 +5,283 @@ import NUnit.Framework
partial class ParserTestFixture:
- [Test]
- def attributes_1():
+
+ [Test] def OperationInsideAParam():
+ RunTestCase("tests/parser/OperationInsideAParam.js")
+
+
+ [Test] def array_types():
+ RunTestCase("tests/parser/array-types.js")
+
+
+ [Test] def attributes_1():
RunTestCase("tests/parser/attributes-1.js")
- [Test]
- def class_1():
+
+ [Test] def attributes_for_script_and_assembly_before_import():
+ RunTestCase("tests/parser/attributes-for-script-and-assembly-before-import.js")
+
+
+ [Test] def attributes_for_script_and_assembly():
+ RunTestCase("tests/parser/attributes-for-script-and-assembly.js")
+
+
+ [Test] def class_1():
RunTestCase("tests/parser/class-1.js")
- [Test]
- def class_2():
+
+ [Test] def class_2():
RunTestCase("tests/parser/class-2.js")
- [Test]
- def commentbug():
+
+ [Test] def class_modifiers():
+ RunTestCase("tests/parser/class-modifiers.js")
+
+
+ [Test] def commentbug():
RunTestCase("tests/parser/commentbug.js")
- [Test]
- def final_1():
+
+ [Test] def do_while_1():
+ RunTestCase("tests/parser/do-while-1.js")
+
+
+ [Test] def do_while_false():
+ RunTestCase("tests/parser/do-while-false.js")
+
+
+ [Test] def empty_blocks():
+ RunTestCase("tests/parser/empty-blocks.js")
+
+
+ [Test] def empty_map_literal():
+ RunTestCase("tests/parser/empty-map-literal.js")
+
+
+ [Test] def enums():
+ RunTestCase("tests/parser/enums.js")
+
+
+ [Test] def final_1():
RunTestCase("tests/parser/final-1.js")
- [Test]
- def float_literals_1():
+
+ [Test] def float_literals_1():
RunTestCase("tests/parser/float-literals-1.js")
- [Test]
- def for_1():
+
+ [Test] def for_1():
RunTestCase("tests/parser/for-1.js")
- [Test]
- def for_loop_with_array_1():
+
+ [Test] def for_each_in_1():
+ RunTestCase("tests/parser/for-each-in-1.js")
+
+
+ [Test] def for_each_in_2():
+ RunTestCase("tests/parser/for-each-in-2.js")
+
+
+ [Test] def for_loop_with_array_1():
RunTestCase("tests/parser/for-loop-with-array-1.js")
- [Test]
- def forin_1():
+
+ [Test] def forin_1():
RunTestCase("tests/parser/forin-1.js")
- [Test]
- def forin_2():
+
+ [Test] def forin_2():
RunTestCase("tests/parser/forin-2.js")
- [Test]
- def function_expression_1():
+
+ [Test] def function_expression_1():
RunTestCase("tests/parser/function-expression-1.js")
- [Test]
- def function_types_1():
+
+ [Test] def function_types_1():
RunTestCase("tests/parser/function-types-1.js")
- [Test]
- def functions_1():
+
+ [Test] def functions_1():
RunTestCase("tests/parser/functions-1.js")
- [Test]
- def functions_2():
+
+ [Test] def functions_2():
RunTestCase("tests/parser/functions-2.js")
- [Test]
- def functions_3():
+
+ [Test] def functions_3():
RunTestCase("tests/parser/functions-3.js")
- [Test]
- def functions_4():
+
+ [Test] def functions_4():
RunTestCase("tests/parser/functions-4.js")
- [Test]
- def functions_5():
+
+ [Test] def functions_5():
RunTestCase("tests/parser/functions-5.js")
- [Test]
- def functions_6():
+
+ [Test] def functions_6():
RunTestCase("tests/parser/functions-6.js")
- [Test]
- def generic_instantiation_1():
+
+ [Test] def generic_instantiation_1():
RunTestCase("tests/parser/generic-instantiation-1.js")
- [Test]
- def globals_1():
+
+ [Test] def globals_1():
RunTestCase("tests/parser/globals-1.js")
- [Test]
- def if_1():
+
+ [Test] def if_1():
RunTestCase("tests/parser/if-1.js")
- [Test]
- def if_2():
+
+ [Test] def if_2():
RunTestCase("tests/parser/if-2.js")
- [Test]
- def if_3():
+
+ [Test] def if_3():
RunTestCase("tests/parser/if-3.js")
- [Test]
- def if_4():
+
+ [Test] def if_4():
RunTestCase("tests/parser/if-4.js")
- [Test]
- def if_5():
+
+ [Test] def if_5():
RunTestCase("tests/parser/if-5.js")
- [Test]
- def if_6():
+
+ [Test] def if_6():
RunTestCase("tests/parser/if-6.js")
- [Test]
- def if_7():
+
+ [Test] def if_7():
RunTestCase("tests/parser/if-7.js")
- [Test]
- def import_1():
+
+ [Test] def import_1():
RunTestCase("tests/parser/import-1.js")
- [Test]
- def inplace_1():
+
+ [Test] def inplace_1():
RunTestCase("tests/parser/inplace-1.js")
- [Test]
- def interface_inheritance():
+
+ [Test] def interface_inheritance():
RunTestCase("tests/parser/interface-inheritance.js")
- [Test]
- def interfaces_1():
+
+ [Test] def interfaces_1():
RunTestCase("tests/parser/interfaces-1.js")
- [Test]
- def new_1():
+
+ [Test] def lambdas():
+ RunTestCase("tests/parser/lambdas.js")
+
+
+ [Test] def macro_application_blocks():
+ RunTestCase("tests/parser/macro-application-blocks.js")
+
+
+ [Test] def nested_classes():
+ RunTestCase("tests/parser/nested-classes.js")
+
+
+ [Test] def nested_enums():
+ RunTestCase("tests/parser/nested-enums.js")
+
+
+ [Test] def nested_interfaces():
+ RunTestCase("tests/parser/nested-interfaces.js")
+
+
+ [Test] def new_1():
RunTestCase("tests/parser/new-1.js")
- [Test]
- def new_2():
+
+ [Test] def new_2():
RunTestCase("tests/parser/new-2.js")
- [Test]
- def new_3():
+
+ [Test] def new_3():
RunTestCase("tests/parser/new-3.js")
- [Test]
- def new_4():
+
+ [Test] def new_4():
RunTestCase("tests/parser/new-4.js")
- [Test]
- def OperationInsideAParam():
- RunTestCase("tests/parser/OperationInsideAParam.js")
-
- [Test]
- def operators_1():
+
+ [Test] def operators_1():
RunTestCase("tests/parser/operators-1.js")
- [Test]
- def operators_2():
+
+ [Test] def operators_2():
RunTestCase("tests/parser/operators-2.js")
- [Test]
- def operators_3():
+
+ [Test] def operators_3():
RunTestCase("tests/parser/operators-3.js")
- [Test]
- def operators_4():
+
+ [Test] def operators_4():
RunTestCase("tests/parser/operators-4.js")
- [Test]
- def operators_5():
+
+ [Test] def operators_5():
RunTestCase("tests/parser/operators-5.js")
- [Test]
- def override_1():
+
+ [Test] def override_1():
RunTestCase("tests/parser/override-1.js")
- [Test]
- def partial_1():
+
+ [Test] def partial_1():
RunTestCase("tests/parser/partial-1.js")
- [Test]
- def scientific_notation():
+
+ [Test] def plusplus_minusminus():
+ RunTestCase("tests/parser/plusplus-minusminus.js")
+
+
+ [Test] def pragma_strict_followed_by_identifier():
+ RunTestCase("tests/parser/pragma-strict-followed-by-identifier.js")
+
+
+ [Test] def pragma_strict_followed_by_tab():
+ RunTestCase("tests/parser/pragma-strict-followed-by-tab.js")
+
+
+ [Test] def scientific_notation():
RunTestCase("tests/parser/scientific-notation.js")
- [Test]
- def try_1():
+
+ [Test] def shift_left_bitwise_or():
+ RunTestCase("tests/parser/shift-left-bitwise-or.js")
+
+
+ [Test] def strings():
+ RunTestCase("tests/parser/strings.js")
+
+
+ [Test] def try_1():
RunTestCase("tests/parser/try-1.js")
- [Test]
- def var_1():
+
+ [Test] def try_finally():
+ RunTestCase("tests/parser/try-finally.js")
+
+
+ [Test] def typeof_1():
+ RunTestCase("tests/parser/typeof-1.js")
+
+
+ [Test] def var_1():
RunTestCase("tests/parser/var-1.js")
- [Test]
- def while_1():
+
+ [Test] def while_1():
RunTestCase("tests/parser/while-1.js")
\ No newline at end of file
diff --git a/src/UnityScript.Tests/ParserTestFixture.boo b/src/UnityScript.Tests/ParserTestFixture.boo
old mode 100644
new mode 100755
index f989593..84c0853
--- a/src/UnityScript.Tests/ParserTestFixture.boo
+++ b/src/UnityScript.Tests/ParserTestFixture.boo
@@ -15,8 +15,12 @@ partial class ParserTestFixture(AbstractCompilerTestFixture):
[Test]
def EmptyFile():
- result = CompileTestCase(StringInput("", ""))
+ result = CompileTestCase(StringInput("empty", ""))
Assert.AreEqual(0, len(result.Errors), result.Errors.ToString(true))
- Assert.AreEqual(0, len(result.CompileUnit.Modules))
+ Assert.AreEqual(1, len(result.CompileUnit.Modules))
+
+ module = result.CompileUnit.Modules[0]
+ Assert.AreEqual("empty", module.Name)
+ Assert.AreEqual("empty", module.LexicalInfo.FileName)
diff --git a/src/UnityScript.Tests/PragmaEnablementTest.boo b/src/UnityScript.Tests/PragmaEnablementTest.boo
new file mode 100644
index 0000000..4cac78d
--- /dev/null
+++ b/src/UnityScript.Tests/PragmaEnablementTest.boo
@@ -0,0 +1,45 @@
+namespace UnityScript.Tests
+
+import NUnit.Framework
+import us
+
+[TestFixture]
+class PragmaEnablementTest:
+
+ [Test]
+ def PragmaDowncastCanBeDisabled():
+
+ m1 = """
+ var i:int = 42 cast Object;
+ """
+
+ m2 = """
+ #pragma downcast on
+ var i:int = 42 cast Object;
+ """
+
+ m3 = """
+ #pragma downcast off
+ var i:int = 42 cast Object;
+ """
+
+ result = CompileModulesWithPragmas("strict,downcast", m1, m2, m3)
+ Assert.AreEqual("m3.js(3,16): BCE0022: Cannot convert 'Object' to 'int'.", result.Errors.ToString().Trim())
+
+def CompileModulesWithPragmas(pragmas as string, *modules as (string)):
+ options = CommandLineOptions("-pragmas:$pragmas", "-method:Awake", "-base:${typeof(MonoBehaviour).FullName}", "-r:${GetAssemblyLocation()}")
+
+ compiler = UnityScriptCompilerFactory.FromCommandLineOptions(options)
+ for i as int, m in enumerate(modules):
+ input = Boo.Lang.Compiler.IO.StringInput("m$(i+1).js", TrimLines(m))
+ compiler.Parameters.Input.Add(input)
+
+ return compiler.Run()
+
+
+def TrimLines(source as string):
+ return join(line.Trim() for line in /\n/.Split(source), "\n")
+
+
+
+
diff --git a/src/UnityScript.Tests/PragmaTestFixture.boo b/src/UnityScript.Tests/PragmaTestFixture.boo
index b571568..12a1b17 100644
--- a/src/UnityScript.Tests/PragmaTestFixture.boo
+++ b/src/UnityScript.Tests/PragmaTestFixture.boo
@@ -6,19 +6,35 @@ import NUnit.Framework
[TestFixture]
class PragmaTestFixture(AbstractIntegrationTestFixture):
- [Test]
- def downcast_plus_strict_1():
+
+ [Test] def downcast_plus_strict_1():
RunTestCase("tests/pragma/downcast-plus-strict-1.js")
- [Test]
- def downcast_plus_strict_for_arrays():
+
+ [Test] def downcast_plus_strict_for_arrays():
RunTestCase("tests/pragma/downcast-plus-strict-for-arrays.js")
- [Test]
- def implicit_1():
+
+ [Test] def downcast_plus_strict_for_each_in_arrays():
+ RunTestCase("tests/pragma/downcast-plus-strict-for-each-in-arrays.js")
+
+
+ [Test] def implicit_1():
RunTestCase("tests/pragma/implicit-1.js")
- [Test]
- def implicit_plus_strict():
+
+ [Test] def implicit_plus_strict():
RunTestCase("tests/pragma/implicit-plus-strict.js")
+
+
+ [Test] def pragma_checked_1():
+ RunTestCase("tests/pragma/pragma-checked-1.js")
+
+
+ [Test] def pragma_expando_1():
+ RunTestCase("tests/pragma/pragma-expando-1.js")
+
+
+ [Test] def pragma_expando_2():
+ RunTestCase("tests/pragma/pragma-expando-2.js")
\ No newline at end of file
diff --git a/src/UnityScript.Tests/ProjectIntegrationTestFixture.Generated.boo b/src/UnityScript.Tests/ProjectIntegrationTestFixture.Generated.boo
new file mode 100644
index 0000000..40e81c3
--- /dev/null
+++ b/src/UnityScript.Tests/ProjectIntegrationTestFixture.Generated.boo
@@ -0,0 +1,15 @@
+
+namespace UnityScript.Tests
+
+import NUnit.Framework
+
+partial class ProjectIntegrationTestFixture:
+
+
+ [Test] def ducky_mixed_with_pragma_strict():
+ RunTestCase("tests/projects/ducky-mixed-with-pragma-strict")
+
+
+ [Test] def interfaces():
+ RunTestCase("tests/projects/interfaces")
+
\ No newline at end of file
diff --git a/src/UnityScript.Tests/ProjectIntegrationTestFixture.boo b/src/UnityScript.Tests/ProjectIntegrationTestFixture.boo
new file mode 100644
index 0000000..83ff9b3
--- /dev/null
+++ b/src/UnityScript.Tests/ProjectIntegrationTestFixture.boo
@@ -0,0 +1,20 @@
+namespace UnityScript.Tests
+
+import NUnit.Framework
+import Boo.Lang.Compiler.IO
+import System.IO
+
+[TestFixture]
+partial class ProjectIntegrationTestFixture(AbstractIntegrationTestFixture):
+
+ override def CompileTestCase(location as string):
+ return CompileTestCase(*array(FileInput(file) for file in SourceFilesIn(location)))
+
+ override def GetExpectedOutput(location as string):
+ return super(SourceFilesIn(location)[0])
+
+ def SourceFilesIn(location as string):
+ files = Directory.GetFiles(location, "*.js")
+ System.Array.Sort(files)
+ return files
+
\ No newline at end of file
diff --git a/src/UnityScript.Tests/Scripting/EvaluatorTest.boo b/src/UnityScript.Tests/Scripting/EvaluatorTest.boo
new file mode 100644
index 0000000..8e7343d
--- /dev/null
+++ b/src/UnityScript.Tests/Scripting/EvaluatorTest.boo
@@ -0,0 +1,16 @@
+namespace UnityScript.Tests.Scripting
+
+import NUnit.Framework
+import UnityScript.Scripting
+
+[TestFixture]
+class EvaluatorTest:
+
+ [Test]
+ def SimpleEvalWithNoImports():
+ Assert.AreEqual(4, Evaluator.Eval(EvaluationContext(), "2 + 2"))
+
+ [Test]
+ def SimpleEvalWithImports():
+ ctx = EvaluationContext(SimpleEvaluationDomainProvider("System.IO"))
+ Assert.AreEqual(".js", Evaluator.Eval(ctx, 'Path.GetExtension("file.js")'))
diff --git a/src/UnityScript.Tests/SemanticsTestFixture.boo b/src/UnityScript.Tests/SemanticsTestFixture.boo
index e0c841f..2ac1808 100644
--- a/src/UnityScript.Tests/SemanticsTestFixture.boo
+++ b/src/UnityScript.Tests/SemanticsTestFixture.boo
@@ -6,39 +6,43 @@ import NUnit.Framework
[TestFixture]
class SemanticsTestFixture(AbstractSemanticsTestFixture):
- [Test]
- def Magic2Class():
+
+ [Test] def EmptyFileBegetsEmptyBehaviour():
+ RunTestCase("tests/semantics/EmptyFileBegetsEmptyBehaviour.js")
+
+
+ [Test] def Magic2Class():
RunTestCase("tests/semantics/Magic2Class.js")
- [Test]
- def MagicClass():
+
+ [Test] def MagicClass():
RunTestCase("tests/semantics/MagicClass.js")
- [Test]
- def class_3():
+
+ [Test] def class_3():
RunTestCase("tests/semantics/class-3.js")
- [Test]
- def coroutine():
+
+ [Test] def coroutine():
RunTestCase("tests/semantics/coroutine.js")
- [Test]
- def fields_1():
+
+ [Test] def fields_1():
RunTestCase("tests/semantics/fields-1.js")
- [Test]
- def functions_2():
+
+ [Test] def functions_2():
RunTestCase("tests/semantics/functions-2.js")
- [Test]
- def magic_members():
+
+ [Test] def magic_members():
RunTestCase("tests/semantics/magic-members.js")
- [Test]
- def single_update_function():
+
+ [Test] def single_update_function():
RunTestCase("tests/semantics/single-update-function.js")
- [Test]
- def variables():
+
+ [Test] def variables():
RunTestCase("tests/semantics/variables.js")
\ No newline at end of file
diff --git a/src/UnityScript.Tests/StackTraceTestFixture.Generated.boo b/src/UnityScript.Tests/StackTraceTestFixture.Generated.boo
index 7107afa..21130aa 100755
--- a/src/UnityScript.Tests/StackTraceTestFixture.Generated.boo
+++ b/src/UnityScript.Tests/StackTraceTestFixture.Generated.boo
@@ -5,27 +5,27 @@ import NUnit.Framework
partial class StackTraceTestFixture:
- [Test]
- def stacktrace_1():
+
+ [Test] def stacktrace_1():
RunTestCase("tests/stacktrace/stacktrace-1.js")
- [Test]
- def stacktrace_2():
+ [Category("FailsOnMono")]
+ [Test] def stacktrace_2():
RunTestCase("tests/stacktrace/stacktrace-2.js")
- [Test]
- def stacktrace_3():
+
+ [Test] def stacktrace_3():
RunTestCase("tests/stacktrace/stacktrace-3.js")
- [Test]
- def stacktrace_4():
+
+ [Test] def stacktrace_4():
RunTestCase("tests/stacktrace/stacktrace-4.js")
- [Test]
- def stacktrace_5():
+
+ [Test] def stacktrace_5():
RunTestCase("tests/stacktrace/stacktrace-5.js")
- [Test]
- def stacktrace_6():
+
+ [Test] def stacktrace_6():
RunTestCase("tests/stacktrace/stacktrace-6.js")
\ No newline at end of file
diff --git a/src/UnityScript.Tests/StrictIntegrationTestFixture.Generated.boo b/src/UnityScript.Tests/StrictIntegrationTestFixture.Generated.boo
new file mode 100644
index 0000000..3a71756
--- /dev/null
+++ b/src/UnityScript.Tests/StrictIntegrationTestFixture.Generated.boo
@@ -0,0 +1,637 @@
+
+namespace UnityScript.Tests
+
+import NUnit.Framework
+
+[TestFixture]
+partial class StrictIntegrationTestFixture(AbstractIntegrationTestFixture):
+
+
+
+ [Test] def JSCheckFloatToIntOverflow():
+ RunTestCase("tests/integration/JSCheckFloatToIntOverflow.js")
+
+
+ [Test] def JSChooseOverload():
+ RunTestCase("tests/integration/JSChooseOverload.js")
+
+
+ [Test] def accessor_2():
+ RunTestCase("tests/integration/accessor-2.js")
+
+
+ [Test] def accessor_3_duck():
+ RunTestCase("tests/integration/accessor-3-duck.js")
+
+
+ [Test] def accessor():
+ RunTestCase("tests/integration/accessor.js")
+
+
+ [Test] def anonymous_function_type_1():
+ RunTestCase("tests/integration/anonymous-function-type-1.js")
+
+
+ [Test] def anonymous_function_type_2():
+ RunTestCase("tests/integration/anonymous-function-type-2.js")
+
+
+ [Test] def anonymous_function_type_3():
+ RunTestCase("tests/integration/anonymous-function-type-3.js")
+
+
+ [Test] def array_Add():
+ RunTestCase("tests/integration/array-Add.js")
+
+
+ [Test] def array_Remove():
+ RunTestCase("tests/integration/array-Remove.js")
+
+
+ [Test] def array_cast():
+ RunTestCase("tests/integration/array-cast.js")
+
+
+ [Test] def array_comprehension_1():
+ RunTestCase("tests/integration/array-comprehension-1.js")
+
+
+ [Test] def array_concat_1():
+ RunTestCase("tests/integration/array-concat-1.js")
+
+
+ [Test] def array_concat_2():
+ RunTestCase("tests/integration/array-concat-2.js")
+
+
+ [Test] def array_create():
+ RunTestCase("tests/integration/array-create.js")
+
+
+ [Test] def array_ctor_with_single_null_element():
+ RunTestCase("tests/integration/array-ctor-with-single-null-element.js")
+
+
+ [Test] def array_implicit_from_null_enumerable():
+ RunTestCase("tests/integration/array-implicit-from-null-enumerable.js")
+
+
+ [Test] def array_implicit_from_null():
+ RunTestCase("tests/integration/array-implicit-from-null.js")
+
+
+ [Test] def array_initializer_in_static_field():
+ RunTestCase("tests/integration/array-initializer-in-static-field.js")
+
+
+ [Test] def array_instantiation_with_object_argument_in_strict_mode():
+ RunTestCase("tests/integration/array-instantiation-with-object-argument-in-strict-mode.js")
+
+
+ [Test] def array_instantiation_with_object_argument():
+ RunTestCase("tests/integration/array-instantiation-with-object-argument.js")
+
+
+ [Test] def array_iteration_with_nulls():
+ RunTestCase("tests/integration/array-iteration-with-nulls.js")
+
+
+ [Test] def array_join():
+ RunTestCase("tests/integration/array-join.js")
+
+
+ [Test] def array_length_duck_typed():
+ RunTestCase("tests/integration/array-length-duck-typed.js")
+
+
+ [Test] def array_nesting():
+ RunTestCase("tests/integration/array-nesting.js")
+
+
+ [Test] def array_pop():
+ RunTestCase("tests/integration/array-pop.js")
+
+
+ [Test] def array_push_2():
+ RunTestCase("tests/integration/array-push-2.js")
+
+
+ [Test] def array_push():
+ RunTestCase("tests/integration/array-push.js")
+
+
+ [Test] def array_shift():
+ RunTestCase("tests/integration/array-shift.js")
+
+
+ [Test] def array_slice():
+ RunTestCase("tests/integration/array-slice.js")
+
+
+ [Test] def array_sort():
+ RunTestCase("tests/integration/array-sort.js")
+
+
+ [Test] def array_splice_2():
+ RunTestCase("tests/integration/array-splice-2.js")
+
+
+ [Test] def array_splice():
+ RunTestCase("tests/integration/array-splice.js")
+
+
+ [Test] def array_str():
+ RunTestCase("tests/integration/array-str.js")
+
+
+ [Test] def array_toString():
+ RunTestCase("tests/integration/array-toString.js")
+
+
+ [Test] def array_unshift():
+ RunTestCase("tests/integration/array-unshift.js")
+
+
+ [Test] def array_with_initial_length():
+ RunTestCase("tests/integration/array-with-initial-length.js")
+
+
+ [Test] def array_with_two_dimensions():
+ RunTestCase("tests/integration/array-with-two-dimensions.js")
+
+
+ [Test] def arrays_2():
+ RunTestCase("tests/integration/arrays-2.js")
+
+
+ [Test] def arrays_3():
+ RunTestCase("tests/integration/arrays-3.js")
+
+
+ [Test] def arrays_4():
+ RunTestCase("tests/integration/arrays-4.js")
+
+
+ [Test] def arrays_6():
+ RunTestCase("tests/integration/arrays-6.js")
+
+
+ [Test] def arrays():
+ RunTestCase("tests/integration/arrays.js")
+
+
+ [Test] def assign_iterator():
+ RunTestCase("tests/integration/assign_iterator.js")
+
+
+ [Test] def attributes_2():
+ RunTestCase("tests/integration/attributes-2.js")
+
+
+ [Test] def attributes():
+ RunTestCase("tests/integration/attributes.js")
+
+
+ [Test] def auto_coroutine_2():
+ RunTestCase("tests/integration/auto-coroutine-2.js")
+
+
+ [Test] def auto_coroutine_return_2():
+ RunTestCase("tests/integration/auto-coroutine-return-2.js")
+
+
+ [Test] def auto_coroutine_static():
+ RunTestCase("tests/integration/auto-coroutine-static.js")
+
+
+ [Test] def cast_operator_1():
+ RunTestCase("tests/integration/cast-operator-1.js")
+
+
+ [Test] def cast_operator_precedence():
+ RunTestCase("tests/integration/cast-operator-precedence.js")
+
+
+ [Test] def chars():
+ RunTestCase("tests/integration/chars.js")
+
+
+ [Test] def comma_parsing():
+ RunTestCase("tests/integration/comma-parsing.js")
+
+
+ [Test] def constructor_1():
+ RunTestCase("tests/integration/constructor-1.js")
+
+
+ [Test] def constructor_2():
+ RunTestCase("tests/integration/constructor_2.js")
+
+
+ [Test] def continue_issue():
+ RunTestCase("tests/integration/continue-issue.js")
+
+
+ [Test] def coroutine_2():
+ RunTestCase("tests/integration/coroutine-2.js")
+
+
+ [Test] def coroutine_3():
+ RunTestCase("tests/integration/coroutine-3.js")
+
+
+ [Test] def coroutine_4():
+ RunTestCase("tests/integration/coroutine-4.js")
+
+
+ [Test] def coroutine_5():
+ RunTestCase("tests/integration/coroutine-5.js")
+
+
+ [Test] def coroutine_return_type_1():
+ RunTestCase("tests/integration/coroutine-return-type-1.js")
+
+
+ [Test] def coroutine_try_catch():
+ RunTestCase("tests/integration/coroutine-try-catch.js")
+
+
+ [Test] def coroutine():
+ RunTestCase("tests/integration/coroutine.js")
+
+
+ [Test] def crash():
+ RunTestCase("tests/integration/crash.js")
+
+
+ [Test] def do_while():
+ RunTestCase("tests/integration/do-while.js")
+
+
+ [Test] def double_precision_can_be_used_for_literals():
+ RunTestCase("tests/integration/double-precision-can-be-used-for-literals.js")
+
+
+ [Test] def empty_array_literal_as_return_value():
+ RunTestCase("tests/integration/empty-array-literal-as-return-value.js")
+
+
+ [Test] def empty_array_literal_as_yield_value():
+ RunTestCase("tests/integration/empty-array-literal-as-yield-value.js")
+
+
+ [Test] def empty_string_array():
+ RunTestCase("tests/integration/empty-string-array.js")
+
+
+ [Test] def enum_1():
+ RunTestCase("tests/integration/enum-1.js")
+
+
+ [Test] def enum_2():
+ RunTestCase("tests/integration/enum-2.js")
+
+
+ [Test] def enum_3():
+ RunTestCase("tests/integration/enum-3.js")
+
+
+ [Test] def enum_4():
+ RunTestCase("tests/integration/enum-4.js")
+
+
+ [Test] def enum_5():
+ RunTestCase("tests/integration/enum-5.js")
+
+
+ [Test] def enum_conversion():
+ RunTestCase("tests/integration/enum-conversion.js")
+
+
+ [Test] def enumerator_array():
+ RunTestCase("tests/integration/enumerator-array.js")
+
+
+ [Test] def explicit_awake_function():
+ RunTestCase("tests/integration/explicit-awake-function.js")
+
+
+ [Test] def float_1():
+ RunTestCase("tests/integration/float-1.js")
+
+
+ [Test] def float_2():
+ RunTestCase("tests/integration/float-2.js")
+
+
+ [Test] def float_array_literal():
+ RunTestCase("tests/integration/float-array-literal.js")
+
+
+ [Test] def float_overload_is_preferred_over_int_for_double_argument_2():
+ RunTestCase("tests/integration/float-overload-is-preferred-over-int-for-double-argument-2.js")
+
+
+ [Test] def float_overload_is_preferred_over_int_for_double_argument_strict_downcast():
+ RunTestCase("tests/integration/float-overload-is-preferred-over-int-for-double-argument-strict-downcast.js")
+
+
+ [Test] def float_overload_is_preferred_over_int_for_double_argument_strict():
+ RunTestCase("tests/integration/float-overload-is-preferred-over-int-for-double-argument-strict.js")
+
+
+ [Test] def float_overload_is_preferred_over_int_for_double_argument():
+ RunTestCase("tests/integration/float-overload-is-preferred-over-int-for-double-argument.js")
+
+
+ [Test] def for_break_1():
+ RunTestCase("tests/integration/for-break-1.js")
+
+
+ [Test] def for_continue_1():
+ RunTestCase("tests/integration/for-continue-1.js")
+
+
+ [Test] def for_continue_2():
+ RunTestCase("tests/integration/for-continue-2.js")
+
+
+ [Test] def for_in_switch_break():
+ RunTestCase("tests/integration/for-in-switch-break.js")
+
+
+ [Test] def for_over_null():
+ RunTestCase("tests/integration/for-over-null.js")
+
+
+ [Test] def for_var_reuse():
+ RunTestCase("tests/integration/for-var-reuse.js")
+
+
+ [Test] def functions_1():
+ RunTestCase("tests/integration/functions-1.js")
+
+
+ [Test] def functions_as_ternary_operands():
+ RunTestCase("tests/integration/functions-as-ternary-operands.js")
+
+
+ [Test] def generator_inheritance_calling_super():
+ RunTestCase("tests/integration/generator-inheritance-calling-super.js")
+
+
+ [Test] def generator_inheritance_yielding_super():
+ RunTestCase("tests/integration/generator-inheritance-yielding-super.js")
+
+
+ [Test] def generator_inheritance():
+ RunTestCase("tests/integration/generator-inheritance.js")
+
+
+ [Test] def implicit_array_to_native_array_cast():
+ RunTestCase("tests/integration/implicit-array-to-native-array-cast.js")
+
+
+ [Test] def implict_bool_hierarchy():
+ RunTestCase("tests/integration/implict-bool-hierarchy.js")
+
+
+ [Test] def inferred_GetComponent():
+ RunTestCase("tests/integration/inferred-GetComponent.js")
+
+
+ [Test] def initializeorder():
+ RunTestCase("tests/integration/initializeorder.js")
+
+
+ [Test] def interface_properties():
+ RunTestCase("tests/integration/interface-properties.js")
+
+
+ [Test] def interfaces_1():
+ RunTestCase("tests/integration/interfaces-1.js")
+
+
+ [Test] def internal_field():
+ RunTestCase("tests/integration/internal-field.js")
+
+
+ [Test] def invalidil():
+ RunTestCase("tests/integration/invalidil.js")
+
+
+ [Test] def length_string():
+ RunTestCase("tests/integration/length-string.js")
+
+
+ [Test] def linq_array_ToList():
+ RunTestCase("tests/integration/linq-array-ToList.js")
+
+
+ [Test] def linq_function_inference():
+ RunTestCase("tests/integration/linq-function-inference.js")
+
+
+ [Test] def linq_lambda_inference():
+ RunTestCase("tests/integration/linq-lambda-inference.js")
+
+
+ [Test] def magicclass():
+ RunTestCase("tests/integration/magicclass.js")
+
+
+ [Test] def magicconstructor():
+ RunTestCase("tests/integration/magicconstructor.js")
+
+
+ [Test] def magicconstructor_2():
+ RunTestCase("tests/integration/magicconstructor_2.js")
+
+
+ [Test] def multidimensional_array_of_struct():
+ RunTestCase("tests/integration/multidimensional-array-of-struct.js")
+
+
+ [Test] def multidimensional_arrays_1():
+ RunTestCase("tests/integration/multidimensional-arrays-1.js")
+
+
+ [Test] def nested_class_1():
+ RunTestCase("tests/integration/nested-class-1.js")
+
+
+ [Test] def nested_classes():
+ RunTestCase("tests/integration/nested-classes.js")
+
+
+ [Test] def new_1():
+ RunTestCase("tests/integration/new-1.js")
+
+
+ [Test] def not_in():
+ RunTestCase("tests/integration/not-in.js")
+
+
+ [Test] def null_initializer():
+ RunTestCase("tests/integration/null-initializer.js")
+
+
+ [Test] def operators_4():
+ RunTestCase("tests/integration/operators-4.js")
+
+
+ [Test] def operators_5():
+ RunTestCase("tests/integration/operators-5.js")
+
+
+ [Test] def override_1():
+ RunTestCase("tests/integration/override-1.js")
+
+
+ [Test] def param_test():
+ RunTestCase("tests/integration/param_test.js")
+
+
+ [Test] def parse_int():
+ RunTestCase("tests/integration/parse_int.js")
+
+
+ [Test] def private_duck():
+ RunTestCase("tests/integration/private-duck.js")
+
+
+ [Test] def properties():
+ RunTestCase("tests/integration/properties.js")
+
+
+ [Test] def quack_fu():
+ RunTestCase("tests/integration/quack-fu.js")
+
+
+ [Test] def question_mark():
+ RunTestCase("tests/integration/question_mark.js")
+
+
+ [Test] def raw_array_indexing():
+ RunTestCase("tests/integration/raw-array-indexing.js")
+
+
+ [Test] def rethrow():
+ RunTestCase("tests/integration/rethrow.js")
+
+
+ [Test] def script_attributes():
+ RunTestCase("tests/integration/script-attributes.js")
+
+
+ [Test] def script_properties():
+ RunTestCase("tests/integration/script-properties.js")
+
+
+ [Test] def shift_left_bitwise_or():
+ RunTestCase("tests/integration/shift-left-bitwise-or.js")
+
+
+ [Test] def static_instance_overload_resolution():
+ RunTestCase("tests/integration/static-instance-overload-resolution.js")
+
+
+ [Test] def string_append():
+ RunTestCase("tests/integration/string-append.js")
+
+
+ [Test] def string_concat():
+ RunTestCase("tests/integration/string-concat.js")
+
+
+ [Test] def switch_3():
+ RunTestCase("tests/integration/switch-3.js")
+
+
+ [Test] def switch_fallthrough():
+ RunTestCase("tests/integration/switch-fallthrough.js")
+
+
+ [Test] def switch_simple_2():
+ RunTestCase("tests/integration/switch-simple-2.js")
+
+
+ [Test] def switch_simple():
+ RunTestCase("tests/integration/switch-simple.js")
+
+
+ [Test] def switch_with_loop():
+ RunTestCase("tests/integration/switch-with-loop.js")
+
+
+ [Test] def switch():
+ RunTestCase("tests/integration/switch.js")
+
+
+ [Test] def transform_collider_bounds():
+ RunTestCase("tests/integration/transform-collider-bounds.js")
+
+
+ [Test] def typecast_1():
+ RunTestCase("tests/integration/typecast-1.js")
+
+
+ [Test] def typeof_1():
+ RunTestCase("tests/integration/typeof-1.js")
+
+
+ [Test] def typeof_2():
+ RunTestCase("tests/integration/typeof-2.js")
+
+
+ [Test] def types_1():
+ RunTestCase("tests/integration/types-1.js")
+
+
+ [Test] def uint_1():
+ RunTestCase("tests/integration/uint-1.js")
+
+
+ [Test] def ulong_bitshift_1():
+ RunTestCase("tests/integration/ulong-bitshift-1.js")
+
+
+ [Test] def ulong_bitshift_overflow_regression():
+ RunTestCase("tests/integration/ulong-bitshift-overflow-regression.js")
+
+
+ [Test] def value_types_1():
+ RunTestCase("tests/integration/value-types-1.js")
+
+
+ [Test] def valuetypes_1():
+ RunTestCase("tests/integration/valuetypes-1.js")
+
+
+ [Test] def varargs_in_constructor_with_vector3():
+ RunTestCase("tests/integration/varargs-in-constructor-with-vector3.js")
+
+
+ [Test] def varargs_with_vector3():
+ RunTestCase("tests/integration/varargs-with-vector3.js")
+
+
+ [Test] def variable_declaration_2():
+ RunTestCase("tests/integration/variable-declaration-2.js")
+
+
+ [Test] def variable_declaration():
+ RunTestCase("tests/integration/variable-declaration.js")
+
+
+ [Test] def variables():
+ RunTestCase("tests/integration/variables.js")
+
+
+ [Test] def vars_1():
+ RunTestCase("tests/integration/vars-1.js")
+
+
+ [Test] def yield_null():
+ RunTestCase("tests/integration/yield-null.js")
+
\ No newline at end of file
diff --git a/src/UnityScript.Tests/StrictIntegrationTestFixture.boo b/src/UnityScript.Tests/StrictIntegrationTestFixture.boo
new file mode 100644
index 0000000..cf0f860
--- /dev/null
+++ b/src/UnityScript.Tests/StrictIntegrationTestFixture.boo
@@ -0,0 +1,11 @@
+
+namespace UnityScript.Tests
+
+import NUnit.Framework
+
+partial class StrictIntegrationTestFixture(AbstractIntegrationTestFixture):
+
+ override def CreateCompilerPipeline():
+ pipeline = super()
+ pipeline.InsertAfter(UnityScript.Steps.Parse, UnityScript.Steps.IntroducePragmas((UnityScript.Core.Pragmas.Strict,)))
+ return pipeline
\ No newline at end of file
diff --git a/src/UnityScript.Tests/UnityScript.Tests.booproj b/src/UnityScript.Tests/UnityScript.Tests.booproj
index d1372cb..bd49959 100755
--- a/src/UnityScript.Tests/UnityScript.Tests.booproj
+++ b/src/UnityScript.Tests/UnityScript.Tests.booproj
@@ -1,5 +1,5 @@
-
+
Debug
AnyCPU
@@ -20,6 +20,7 @@
false
false
+ false
none
@@ -28,20 +29,21 @@
false
false
+ false
-
-
-
-
-
-
+
+
+
+
+
+
+
-
@@ -51,7 +53,6 @@
-
@@ -61,10 +62,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -84,4 +98,9 @@
us
+
+
+
+
+
\ No newline at end of file
diff --git a/src/UnityScript.Tests/UnityScriptCompilerFactoryTestFixture.boo b/src/UnityScript.Tests/UnityScriptCompilerFactoryTestFixture.boo
old mode 100644
new mode 100755
index b332748..ec6e326
--- a/src/UnityScript.Tests/UnityScriptCompilerFactoryTestFixture.boo
+++ b/src/UnityScript.Tests/UnityScriptCompilerFactoryTestFixture.boo
@@ -3,6 +3,11 @@ namespace UnityScript.Tests
import NUnit.Framework
import us
+import Boo.Lang.Environments
+import Boo.Lang.Compiler
+import Boo.Lang.Compiler.Steps
+import Boo.Lang.Compiler.TypeSystem.Services
+
[TestFixture]
class UnityScriptCompilerFactoryTestFixture:
@@ -12,11 +17,41 @@ class UnityScriptCompilerFactoryTestFixture:
options = CommandLineOptions(
"-d:FOO", "--define:BAR",
- "-method:Awake", "-base:${typeof(MonoBehaviour).FullName}",
- "-r:${GetAssemblyLocation()}")
+ "-method:Awake", "-base:$MonoBehaviour",
+ "-r:$(GetAssemblyLocation())")
compiler = UnityScriptCompilerFactory.FromCommandLineOptions(options)
Assert.AreEqual(["FOO", "BAR"], [define for define in compiler.Parameters.Defines.Keys])
+
+ [Test]
+ def CustomTypeInferenceRuleAttribute():
+
+ options = CommandLineOptions(
+ "-x-type-inference-rule-attribute:$CustomAttribute",
+
+ "-method:Awake", "-base:$MonoBehaviour",
+ "-r:$(GetAssemblyLocation())")
+
+ compiler = UnityScriptCompilerFactory.FromCommandLineOptions(options)
+ compiler.Parameters.Pipeline = CompilerPipeline() { ActionStep(CheckCustomTypeInferenceRuleAttribute) }
+ result = compiler.Run()
+ Assert.AreEqual(0, len(result.Errors), result.Errors.ToString(true))
+
+ private def CheckCustomTypeInferenceRuleAttribute():
+ method = GetType().GetMethod("MethodWithCustomAttribute")
+ rule = my(TypeInferenceRuleProvider).TypeInferenceRuleFor(method)
+ Assert.AreEqual("custom", rule)
+
+ [CustomAttribute]
+ def MethodWithCustomAttribute():
+ return null
+
+class CustomAttribute(System.Attribute):
+ override def ToString():
+ return "custom"
+
+
+
\ No newline at end of file
diff --git a/src/UnityScript.Tests/UnityScriptCompilerParametersTest.boo b/src/UnityScript.Tests/UnityScriptCompilerParametersTest.boo
new file mode 100755
index 0000000..bb1a9da
--- /dev/null
+++ b/src/UnityScript.Tests/UnityScriptCompilerParametersTest.boo
@@ -0,0 +1,12 @@
+namespace UnityScript.Tests
+
+import UnityScript
+import NUnit.Framework
+
+[TestFixture]
+class UnityScriptCompilerParametersTest:
+
+ [Test]
+ def PragmaDowncastCanBeDisabled():
+
+ Assert.AreEqual(0, UnityScriptCompilerParameters(false).References.Count)
diff --git a/src/UnityScript.Tests/UsTestFixture.boo b/src/UnityScript.Tests/UsTestFixture.boo
index 1b694e6..18a98e0 100755
--- a/src/UnityScript.Tests/UsTestFixture.boo
+++ b/src/UnityScript.Tests/UsTestFixture.boo
@@ -44,7 +44,7 @@ class UsTestFixture:
"-b:UnityScript.Tests.MonoBehaviour",
"-m:Awake",
ResolvePath("errors-1.js"), )
- AssertErrorMessageAndExitCode(argv)
+ AssertUnknownIdentifierErrorMessageAndExitCode(argv)
[Test]
def AcceptsMultipleReferences():
@@ -54,16 +54,32 @@ class UsTestFixture:
"-b:UnityScript.Tests.MonoBehaviour",
"-m:Awake",
ResolvePath("errors-1.js"), )
- AssertErrorMessageAndExitCode(argv)
+ AssertUnknownIdentifierErrorMessageAndExitCode(argv)
+
+ [Test]
+ def EvalCanBeDisabled():
+ message = "eval is not available on this platform"
+ argv = (
+ "-r:${GetAssemblyLocation()}",
+ "-b:UnityScript.Tests.MonoBehaviour",
+ "-m:Awake",
+ '"-disable-eval:' + message + '"',
+ path = ResolvePath("eval-can-be-disabled.js"))
+
+ expected = "$path(2,2): UCE0008: $message"
+ AssertErrorMessageAndExitCode(expected, argv)
def ResolvePath(fname as string):
return "${AbstractCompilerTestFixture.BasePath}/tests/us/${fname}"
- def AssertErrorMessageAndExitCode(argv as (string)):
- exitCode, output as string = ExecuteUs(argv)
+ def AssertUnknownIdentifierErrorMessageAndExitCode(argv as (string)):
expected = """
${ResolvePath('errors-1.js')}(2,4): BCE0005: Unknown identifier: 'undefinedNoPathNameError'.
"""
+ AssertErrorMessageAndExitCode(expected, argv)
+
+ def AssertErrorMessageAndExitCode(expected as string, argv as (string)):
+ exitCode, output as string = ExecuteUs(argv)
Assert.AreEqual(255, exitCode)
Assert.AreEqual(expected.Trim(), output.Trim())
@@ -73,8 +89,9 @@ class UsTestFixture:
assert output.Trim().StartsWith("Successfully compiled")
def ExecuteUs(argv as (string)):
- if PlatformInformation.IsMono:
- p = shellp("mono", UsExePath + " ${join(argv)}")
+ if PlatformInformation.IsMono:
+ monoexe = System.Environment.GetEnvironmentVariable("MONO_EXECUTABLE") or "mono"
+ p = shellp(monoexe, UsExePath + " ${join(argv)}")
else:
p = shellp(UsExePath, join(argv))
diff --git a/src/UnityScript/.monolipse b/src/UnityScript/.monolipse
index 5922ac3..97f9fd5 100755
--- a/src/UnityScript/.monolipse
+++ b/src/UnityScript/.monolipse
@@ -2,18 +2,24 @@
boo
library
-
- /UnityScript/lib/net-2.0/bin/Boo.Lang.Compiler.dll
-
-
- /UnityScript/lib/net-2.0/bin/Boo.Lang.Parser.dll
-
/UnityScript/src/UnityScript.Lang
-
- /UnityScript/lib/net-2.0/bin/Boo.Lang.PatternMatching.dll
-
+
+ Boo.Lang
+
+
+ Boo.Lang.PatternMatching
+
+
+ Boo.Lang.Useful
+
+
+ Boo.Lang.Parser
+
+
+ Boo.Lang.Compiler
+
/UnityScript/bin
diff --git a/src/UnityScript/Core/DeclarationAnnotations.boo b/src/UnityScript/Core/DeclarationAnnotations.boo
new file mode 100644
index 0000000..6617f7e
--- /dev/null
+++ b/src/UnityScript/Core/DeclarationAnnotations.boo
@@ -0,0 +1,14 @@
+namespace UnityScript.Core
+
+import Boo.Lang.Compiler.Ast
+
+static class DeclarationAnnotations:
+
+ def ForceNewVariable(d as Declaration):
+ d.Annotate(NewVariableAnnotation)
+
+ def ShouldForceNewVariableFor(d as Declaration):
+ return d.ContainsAnnotation(NewVariableAnnotation)
+
+ NewVariableAnnotation = object()
+
diff --git a/src/UnityScript/Core/Pragmas.boo b/src/UnityScript/Core/Pragmas.boo
new file mode 100644
index 0000000..f040ef3
--- /dev/null
+++ b/src/UnityScript/Core/Pragmas.boo
@@ -0,0 +1,42 @@
+namespace UnityScript.Core
+
+import Boo.Lang.Compiler.Ast
+
+static class Pragmas:
+
+ public final Strict = "strict"
+
+ public final Expando = "expando"
+
+ public final Implicit = "implicit"
+
+ public final Downcast = "downcast"
+
+ public final Checked = "checked"
+
+ final ValidPragmas = Strict, Expando, Implicit, Downcast, Checked
+
+ final Enabled = true
+
+ final Disabled = false
+
+ All:
+ get: return ValidPragmas[:]
+
+ def IsValid(pragma as string):
+ return pragma in ValidPragmas
+
+ def IsEnabledOn(module as Module, pragma as string):
+ return Enabled == module[pragma]
+
+ def IsDisabledOn(module as Module, pragma as string):
+ return Disabled == module[pragma]
+
+ def TryToEnableOn(module as Module, pragma as string):
+ if module.ContainsAnnotation(pragma):
+ return false
+ module.Annotate(pragma, Enabled)
+ return true
+
+ def DisableOn(module as Module, pragma as string):
+ module[pragma] = Disabled
\ No newline at end of file
diff --git a/src/UnityScript/Core/UnityScriptCompilerErrors.boo b/src/UnityScript/Core/UnityScriptCompilerErrors.boo
index 5cc51ba..a47fabd 100755
--- a/src/UnityScript/Core/UnityScriptCompilerErrors.boo
+++ b/src/UnityScript/Core/UnityScriptCompilerErrors.boo
@@ -17,13 +17,19 @@ static class UnityScriptCompilerErrors:
return CreateError("UCE0004", location, "Property getter cannot declare any arguments.")
def InterfaceExpected(location as LexicalInfo, typeName as string):
- return CreateError("UCE0005", location, "'${typeName}' is not an interface. 'implements' can only be used with interfaces. Did you mean 'extends'?")
+ return CreateError("UCE0005", location, "'$typeName' is not an interface. 'implements' can only be used with interfaces. Did you mean 'extends'?")
def ClassExpected(location as LexicalInfo, typeName as string):
- return CreateError("UCE0006", location, "'${typeName}' is not a class. 'extends' can only be used with classes. Did you mean 'implements'?")
+ return CreateError("UCE0006", location, "'$typeName' is not a class. 'extends' can only be used with classes. Did you mean 'implements'?")
def KeywordCannotBeUsedAsAnIdentifier(location as LexicalInfo, keyword as string):
- return CreateError("UCE0007", location, "Reserved keyword '${keyword}' cannot be used as an identifier.")
+ return CreateError("UCE0007", location, "'$keyword' keyword cannot be used as an identifier.")
+
+ def EvalHasBeenDisabled(location as LexicalInfo, reason as string):
+ return CreateError("UCE0008", location, reason)
+
+ def SetterCanNotDeclareReturnType(location as LexicalInfo):
+ return CreateError("UCE0009", location, "Property setter can not declare return type.")
private def CreateError(code as string, location as LexicalInfo, message as string):
return Boo.Lang.Compiler.CompilerError(code, location, message, null)
diff --git a/src/UnityScript/Core/UnityScriptWarnings.boo b/src/UnityScript/Core/UnityScriptWarnings.boo
index 68276d6..7a0714a 100755
--- a/src/UnityScript/Core/UnityScriptWarnings.boo
+++ b/src/UnityScript/Core/UnityScriptWarnings.boo
@@ -8,7 +8,13 @@ static class UnityScriptWarnings:
return CreateWarning("UCW0100", location, "WARNING: 'virtual' keyword has no effect and it has been deprecated. Functions are virtual by default.")
def ScriptMainMethodIsImplicitlyDefined(location as LexicalInfo, functionName as string):
- return CreateWarning("UCW0002", location, "WARNING: Function '${functionName}()' is already implicitly defined to contain global script code. Global code will be merged at the end. Either rename the function, change its signature or remove any global code if that's not what you intended.")
+ return CreateWarning("UCW0002", location, "WARNING: Function '$functionName()' is already implicitly defined to contain global script code. Global code will be merged at the end. Either rename the function, change its signature or remove any global code if that's not what you intended.")
+
+ def BitwiseOperatorWithBooleanOperands(location as LexicalInfo, expectedOperator as string, actualOperator as string):
+ return CreateWarning("UCW0003", location, "WARNING: Bitwise operation '$actualOperator' on boolean values won't shortcut. Did you mean '$expectedOperator'?")
+
+ def CannotStartCoroutineFromStaticFunction(location as LexicalInfo, coroutineName as string):
+ return CreateWarning("UCW0004", location, "WARNING: Coroutine '$coroutineName' cannot be automatically started from a static function.")
private def CreateWarning(code as string, location as LexicalInfo, message as string):
return Boo.Lang.Compiler.CompilerWarning(location, message, code)
diff --git a/src/UnityScript/Macros/DeferredMacro.boo b/src/UnityScript/Macros/DeferredMacro.boo
old mode 100644
new mode 100755
index 7aeed5d..e19f544
--- a/src/UnityScript/Macros/DeferredMacro.boo
+++ b/src/UnityScript/Macros/DeferredMacro.boo
@@ -1,8 +1,6 @@
namespace UnityScript.Macros
-import Boo.Lang.Compiler
import Boo.Lang.Compiler.Ast
-import Boo.Lang.PatternMatching
macro deferred:
case [| deferred $(ReferenceExpression(Name: name)) = $initializer |]:
diff --git a/src/UnityScript/Macros/PerNodeMacro.boo b/src/UnityScript/Macros/PerNodeMacro.boo
new file mode 100644
index 0000000..c3c4653
--- /dev/null
+++ b/src/UnityScript/Macros/PerNodeMacro.boo
@@ -0,0 +1,22 @@
+namespace UnityScript.Macros
+
+import Boo.Lang.Compiler.Ast
+import Boo.Lang.PatternMatching
+
+macro perNode(node as ReferenceExpression):
+
+ match perNode.Body:
+ case Block(Statements: (ReturnStatement(Expression: value),)):
+ key = ReferenceExpression(Name: Context.GetUniqueName(node.Name))
+ yield [|
+ static private final $key = object()
+ |]
+ yield [|
+ block:
+ cached = $node[$key]
+ return cached if cached is not null
+ value = $value
+ $node[$key] = value
+ return value
+ |].Body
+
diff --git a/src/UnityScript/Macros/SwitchMacro.boo b/src/UnityScript/Macros/SwitchMacro.boo
index 0cf96cf..7daee79 100755
--- a/src/UnityScript/Macros/SwitchMacro.boo
+++ b/src/UnityScript/Macros/SwitchMacro.boo
@@ -13,7 +13,14 @@ class DefaultStatement(CustomStatement):
macro switch:
- assert len(switch.Arguments) == 1
+ if len(switch.Arguments) != 1:
+ Errors.Add(CompilerErrorFactory.CustomError(switch, "switch requires an expression."))
+ return null
+
+ statements = switch.Body.Statements
+ if len(statements) == 0:
+ Warnings.Add(CompilerWarningFactory.CustomWarning(switch, "switch statement has no cases."))
+ return null
macro case:
return CaseStatement(Expressions: case.Arguments, Body: case.Body)
@@ -36,8 +43,8 @@ macro switch:
passThrough as LabelStatement
- lastItem = switch.Body.Statements[-1]
- for item in switch.Body.Statements:
+ lastItem = statements[-1]
+ for item in statements:
match item:
case CaseStatement(Expressions: expressions, Body: body):
@@ -89,8 +96,14 @@ class GotoOnTopLevelBreak(DepthFirstTransformer):
ReplaceCurrentNode(NewGoto(_label))
override def OnWhileStatement(node as WhileStatement):
+ OnLoopBody node.Block
+
+ override def OnForStatement(node as ForStatement):
+ OnLoopBody node.Block
+
+ def OnLoopBody(block as Block):
++_level
- node.Block.Accept(self)
+ block.Accept(self)
--_level
def NewGoto(label as LabelStatement):
diff --git a/src/UnityScript/Parser/CodeFactory.boo b/src/UnityScript/Parser/CodeFactory.boo
index a4fd84f..8e7fb01 100755
--- a/src/UnityScript/Parser/CodeFactory.boo
+++ b/src/UnityScript/Parser/CodeFactory.boo
@@ -1,13 +1,43 @@
namespace UnityScript.Parser
+import System.Globalization
import Boo.Lang.Compiler.Ast
static class CodeFactory:
+
+ def NewModule(fileName as string):
+ return Module(LexicalInfo(fileName, 1, 1), Name: ModuleNameFromFileName(fileName))
+
+ def NewArrayComprehension(location as LexicalInfo, projection as Expression, variable as Declaration, expression as Expression, filter as Expression):
+ ge = GeneratorExpression(location, Expression: projection, Iterator: expression)
+ ge.Declarations.Add(variable)
+ if filter is not null:
+ ge.Filter = StatementModifier(filter.LexicalInfo, Type: StatementModifierType.If, Condition: filter)
+ return [| Boo.Lang.Builtins.array($ge) |].WithLocation(location)
- def NewArrayInitializer(location as LexicalInfo, elementType as TypeReference, count as Expression):
- return [| Boo.Lang.Builtins.array[of $elementType]($count) |].WithLocation(location)
+ def NewArrayInitializer(location as LexicalInfo, elementType as TypeReference, dimensions as List of Expression):
+ if len(dimensions) == 1:
+ size = dimensions[0]
+ return [| Boo.Lang.Builtins.array[of $elementType](cast(int, $size)) |].WithLocation(location)
+ initializer = [| Boo.Lang.Builtins.matrix[of $elementType]() |].WithLocation(location)
+ initializer.Arguments.AddRange(dimensions)
+ return initializer
+
+ def NewDoubleLiteralExpression(location as LexicalInfo, literal as string):
+ if literal.EndsWith('d') or literal.EndsWith('D'):
+ return DoubleLiteralExpression(location, ParseDouble(literal[:-1]))
+
+ literal = literal[:-1] if literal.EndsWith('f') or literal.EndsWith('F')
+ value = ParseDouble(literal)
+ return DoubleLiteralExpression(location, value, IsSingle: true)
+
+ private def ParseDouble(text as string):
+ return double.Parse(text, CultureInfo.InvariantCulture)
[Extension]
def WithLocation[of T(Node)](node as T, location as LexicalInfo):
node.LexicalInfo = location
return node
+
+def ModuleNameFromFileName(fname as string):
+ return System.IO.Path.GetFileNameWithoutExtension(fname)
diff --git a/src/UnityScript/Parser/UnityScriptLexer.boo b/src/UnityScript/Parser/UnityScriptLexer.boo
index faaa98b..6e01560 100644
--- a/src/UnityScript/Parser/UnityScriptLexer.boo
+++ b/src/UnityScript/Parser/UnityScriptLexer.boo
@@ -34,119 +34,128 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
public static final NULL_TREE_LOOKAHEAD = 3
public static final AS = 4
public static final BREAK = 5
- public static final CATCH = 6
- public static final CLASS = 7
- public static final CONTINUE = 8
- public static final ELSE = 9
- public static final ENUM = 10
- public static final EXTENDS = 11
- public static final FALSE = 12
- public static final FINAL = 13
- public static final FINALLY = 14
- public static final FOR = 15
- public static final FUNCTION = 16
- public static final GET = 17
- public static final IF = 18
- public static final IMPORT = 19
- public static final IMPLEMENTS = 20
- public static final IN = 21
- public static final INTERFACE = 22
- public static final INSTANCEOF = 23
- public static final NEW = 24
- public static final NOT = 25
- public static final NULL = 26
- public static final RETURN = 27
- public static final PUBLIC = 28
- public static final PROTECTED = 29
- public static final INTERNAL = 30
- public static final OVERRIDE = 31
- public static final PARTIAL = 32
- public static final PRAGMA = 33
- public static final PRIVATE = 34
- public static final SET = 35
- public static final STATIC = 36
- public static final SUPER = 37
- public static final THIS = 38
- public static final THROW = 39
- public static final TRUE = 40
- public static final TRY = 41
- public static final TYPEOF = 42
- public static final VAR = 43
- public static final VIRTUAL = 44
- public static final WHILE = 45
- public static final YIELD = 46
- public static final SWITCH = 47
- public static final CASE = 48
- public static final DEFAULT = 49
- public static final INPLACE_DIVISION = 50
- public static final INPLACE_ADD = 51
- public static final INPLACE_SUBTRACT = 52
- public static final INPLACE_MULTIPLY = 53
- public static final ID = 54
- public static final DOUBLE_QUOTED_STRING = 55
- public static final LBRACE = 56
- public static final RBRACE = 57
- public static final LPAREN = 58
- public static final RPAREN = 59
- public static final DOT = 60
- public static final COLON = 61
- public static final COMMA = 62
- public static final LBRACK = 63
- public static final RBRACK = 64
- public static final BITWISE_OR = 65
- public static final INPLACE_BITWISE_OR = 66
- public static final BITWISE_AND = 67
- public static final BITWISE_XOR = 68
- public static final INPLACE_BITWISE_AND = 69
- public static final LOGICAL_OR = 70
- public static final LOGICAL_AND = 71
- public static final EOS = 72
- public static final ASSIGN = 73
- public static final INCREMENT = 74
- public static final DECREMENT = 75
- public static final ADD = 76
- public static final SUBTRACT = 77
- public static final MODULUS = 78
- public static final MULTIPLY = 79
- public static final EQUALITY = 80
- public static final INEQUALITY = 81
- public static final QUESTION_MARK = 82
- public static final ONES_COMPLEMENT = 83
- public static final REFERENCE_EQUALITY = 84
- public static final REFERENCE_INEQUALITY = 85
- public static final LESS_THAN = 86
- public static final LESS_THAN_OR_EQUAL = 87
- public static final SHIFT_LEFT = 88
- public static final INPLACE_SHIFT_LEFT = 89
- public static final GREATER_THAN = 90
- public static final GREATER_THAN_OR_EQUAL = 91
- public static final SHIFT_RIGHT = 92
- public static final INPLACE_SHIFT_RIGHT = 93
- public static final AT = 94
- public static final SCRIPT_ATTRIBUTE_MARKER = 95
- public static final HASH = 96
- public static final INPLACE_BITWISE_XOR = 97
- public static final EXCLUSIVE_OR = 98
- public static final DIVISION = 99
- public static final RE_LITERAL = 100
- public static final DOUBLE = 101
- public static final INT = 102
- public static final LONG = 103
- public static final DOUBLE_SUFFIX = 104
- public static final EXPONENT = 105
- public static final WHITE_SPACE = 106
- public static final DQS_ESC = 107
- public static final SQS_ESC = 108
- public static final SESC = 109
- public static final ML_COMMENT = 110
- public static final RE_CHAR = 111
- public static final RE_ESC = 112
- public static final NEWLINE = 113
- public static final ID_LETTER = 114
- public static final DIGIT = 115
- public static final HEXDIGIT = 116
+ public static final CAST = 6
+ public static final CATCH = 7
+ public static final CLASS = 8
+ public static final CONTINUE = 9
+ public static final DO = 10
+ public static final ELSE = 11
+ public static final EACH = 12
+ public static final ENUM = 13
+ public static final EXTENDS = 14
+ public static final FALSE = 15
+ public static final FINAL = 16
+ public static final FINALLY = 17
+ public static final FOR = 18
+ public static final FUNCTION = 19
+ public static final GET = 20
+ public static final IF = 21
+ public static final IMPORT = 22
+ public static final IMPLEMENTS = 23
+ public static final IN = 24
+ public static final INTERFACE = 25
+ public static final INSTANCEOF = 26
+ public static final NEW = 27
+ public static final NOT = 28
+ public static final NULL = 29
+ public static final RETURN = 30
+ public static final PUBLIC = 31
+ public static final PROTECTED = 32
+ public static final INTERNAL = 33
+ public static final OVERRIDE = 34
+ public static final PARTIAL = 35
+ public static final PRIVATE = 36
+ public static final SET = 37
+ public static final STATIC = 38
+ public static final SUPER = 39
+ public static final THIS = 40
+ public static final THROW = 41
+ public static final TRUE = 42
+ public static final TRY = 43
+ public static final TYPEOF = 44
+ public static final VAR = 45
+ public static final VIRTUAL = 46
+ public static final WHILE = 47
+ public static final YIELD = 48
+ public static final SWITCH = 49
+ public static final CASE = 50
+ public static final DEFAULT = 51
+ public static final INPLACE_DIVISION = 52
+ public static final INPLACE_ADD = 53
+ public static final INPLACE_SUBTRACT = 54
+ public static final INPLACE_MULTIPLY = 55
+ public static final SL_COMMENT = 56
+ public static final PRAGMA_ON = 57
+ public static final PRAGMA_OFF = 58
+ public static final ID = 59
+ public static final DOUBLE_QUOTED_STRING = 60
+ public static final LBRACE = 61
+ public static final RBRACE = 62
+ public static final LPAREN = 63
+ public static final RPAREN = 64
+ public static final DOT = 65
+ public static final COLON = 66
+ public static final COMMA = 67
+ public static final LBRACK = 68
+ public static final RBRACK = 69
+ public static final BITWISE_OR = 70
+ public static final INPLACE_BITWISE_OR = 71
+ public static final BITWISE_AND = 72
+ public static final BITWISE_XOR = 73
+ public static final INPLACE_BITWISE_AND = 74
+ public static final LOGICAL_OR = 75
+ public static final LOGICAL_AND = 76
+ public static final EOS = 77
+ public static final ASSIGN = 78
+ public static final INCREMENT = 79
+ public static final DECREMENT = 80
+ public static final ADD = 81
+ public static final SUBTRACT = 82
+ public static final MODULUS = 83
+ public static final MULTIPLY = 84
+ public static final EQUALITY = 85
+ public static final INEQUALITY = 86
+ public static final QUESTION_MARK = 87
+ public static final BITWISE_NOT = 88
+ public static final REFERENCE_EQUALITY = 89
+ public static final REFERENCE_INEQUALITY = 90
+ public static final LESS_THAN = 91
+ public static final LESS_THAN_OR_EQUAL = 92
+ public static final SHIFT_LEFT = 93
+ public static final INPLACE_SHIFT_LEFT = 94
+ public static final GREATER_THAN = 95
+ public static final GREATER_THAN_OR_EQUAL = 96
+ public static final SHIFT_RIGHT = 97
+ public static final INPLACE_SHIFT_RIGHT = 98
+ public static final AT = 99
+ public static final SCRIPT_ATTRIBUTE_MARKER = 100
+ public static final ASSEMBLY_ATTRIBUTE_MARKER = 101
+ public static final INPLACE_BITWISE_XOR = 102
+ public static final LOGICAL_NOT = 103
+ public static final DIVISION = 104
+ public static final RE_LITERAL = 105
+ public static final DOUBLE = 106
+ public static final INT = 107
+ public static final LONG = 108
+ public static final SINGLE_QUOTED_STRING = 109
+ public static final DOUBLE_SUFFIX = 110
+ public static final EXPONENT = 111
+ public static final PRAGMA_WHITE_SPACE = 112
+ public static final WHITE_SPACE = 113
+ public static final DQS_ESC = 114
+ public static final SQS_ESC = 115
+ public static final SESC = 116
+ public static final ML_COMMENT = 117
+ public static final RE_CHAR = 118
+ public static final RE_ESC = 119
+ public static final NEWLINE = 120
+ public static final ID_LETTER = 121
+ public static final DIGIT = 122
+ public static final HEXDIGIT = 123
+ property PreserveComments = false
+
static def IsDigit(ch as char):
return ch >= char('0') and ch <= char('9')
def constructor(ins as Stream):
@@ -166,98 +175,104 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
caseSensitiveLiterals = true
setCaseSensitive(true)
literals = Hashtable(100, 0.4, null, Comparer.Default)
- literals.Add(",", 62)
- literals.Add("public", 28)
- literals.Add("a string", 55)
- literals.Add("an identifier", 54)
- literals.Add("]", 64)
- literals.Add("case", 48)
+ literals.Add(",", 67)
+ literals.Add("public", 31)
+ literals.Add("a string", 60)
+ literals.Add("an identifier", 59)
+ literals.Add("]", 69)
+ literals.Add("case", 50)
literals.Add("break", 5)
- literals.Add("while", 45)
- literals.Add("new", 24)
- literals.Add("||", 70)
- literals.Add("+", 76)
- literals.Add("instanceof", 23)
- literals.Add("implements", 20)
- literals.Add("*", 79)
- literals.Add("|=", 66)
- literals.Add("typeof", 42)
- literals.Add("[", 63)
- literals.Add(">>=", 93)
- literals.Add("not", 25)
- literals.Add("return", 27)
- literals.Add("throw", 39)
- literals.Add("var", 43)
- literals.Add(")", 59)
- literals.Add("==", 80)
- literals.Add("null", 26)
- literals.Add("protected", 29)
- literals.Add("@script", 95)
- literals.Add("class", 7)
- literals.Add("(", 58)
- literals.Add("~", 83)
- literals.Add("function", 16)
- literals.Add("/=", 50)
- literals.Add("super", 37)
- literals.Add("@", 94)
- literals.Add("-=", 52)
- literals.Add("set", 35)
- literals.Add("+=", 51)
- literals.Add("!==", 85)
- literals.Add("}", 57)
- literals.Add("interface", 22)
- literals.Add("?", 82)
- literals.Add("&", 67)
- literals.Add("internal", 30)
- literals.Add("final", 13)
- literals.Add("yield", 46)
- literals.Add("!=", 81)
- literals.Add("===", 84)
- literals.Add("if", 18)
- literals.Add("|", 65)
- literals.Add("override", 31)
- literals.Add(">", 90)
+ literals.Add("while", 47)
+ literals.Add("new", 27)
+ literals.Add("||", 75)
+ literals.Add("+", 81)
+ literals.Add("instanceof", 26)
+ literals.Add("implements", 23)
+ literals.Add("*", 84)
+ literals.Add("|=", 71)
+ literals.Add("typeof", 44)
+ literals.Add("@assembly", 101)
+ literals.Add("[", 68)
+ literals.Add(">>=", 98)
+ literals.Add("not", 28)
+ literals.Add("return", 30)
+ literals.Add("throw", 41)
+ literals.Add("var", 45)
+ literals.Add(")", 64)
+ literals.Add("==", 85)
+ literals.Add("null", 29)
+ literals.Add("protected", 32)
+ literals.Add("pragma off", 58)
+ literals.Add("@script", 100)
+ literals.Add("class", 8)
+ literals.Add("(", 63)
+ literals.Add("do", 10)
+ literals.Add("~", 88)
+ literals.Add("function", 19)
+ literals.Add("/=", 52)
+ literals.Add("super", 39)
+ literals.Add("each", 12)
+ literals.Add("@", 99)
+ literals.Add("-=", 54)
+ literals.Add("set", 37)
+ literals.Add("+=", 53)
+ literals.Add("!==", 90)
+ literals.Add("}", 62)
+ literals.Add("interface", 25)
+ literals.Add("?", 87)
+ literals.Add("&", 72)
+ literals.Add("internal", 33)
+ literals.Add("final", 16)
+ literals.Add("yield", 48)
+ literals.Add("!=", 86)
+ literals.Add("//", 56)
+ literals.Add("===", 89)
+ literals.Add("if", 21)
+ literals.Add("|", 70)
+ literals.Add("override", 34)
+ literals.Add(">", 95)
literals.Add("as", 4)
- literals.Add("%", 78)
- literals.Add("pragma", 33)
- literals.Add("catch", 6)
- literals.Add("try", 41)
- literals.Add("{", 56)
- literals.Add("=", 73)
- literals.Add("enum", 10)
- literals.Add("for", 15)
- literals.Add(">>", 92)
- literals.Add("extends", 11)
- literals.Add("private", 34)
- literals.Add("default", 49)
- literals.Add("--", 75)
- literals.Add("<", 86)
- literals.Add("false", 12)
- literals.Add("this", 38)
- literals.Add("static", 36)
- literals.Add(">=", 91)
- literals.Add("<=", 87)
- literals.Add("partial", 32)
- literals.Add(";", 72)
- literals.Add("get", 17)
- literals.Add("<<=", 89)
- literals.Add("continue", 8)
- literals.Add("&&", 71)
- literals.Add("<<", 88)
- literals.Add(".", 60)
- literals.Add("finally", 14)
- literals.Add("else", 9)
- literals.Add("import", 19)
- literals.Add("++", 74)
- literals.Add(":", 61)
- literals.Add("in", 21)
- literals.Add("switch", 47)
- literals.Add("true", 40)
- literals.Add("-", 77)
- literals.Add("*=", 53)
- literals.Add("virtual", 44)
- literals.Add("^", 68)
- literals.Add("&=", 69)
+ literals.Add("%", 83)
+ literals.Add("catch", 7)
+ literals.Add("try", 43)
+ literals.Add("{", 61)
+ literals.Add("=", 78)
+ literals.Add("enum", 13)
+ literals.Add("for", 18)
+ literals.Add(">>", 97)
+ literals.Add("extends", 14)
+ literals.Add("private", 36)
+ literals.Add("default", 51)
+ literals.Add("--", 80)
+ literals.Add("<", 91)
+ literals.Add("false", 15)
+ literals.Add("this", 40)
+ literals.Add("static", 38)
+ literals.Add(">=", 96)
+ literals.Add("<=", 92)
+ literals.Add("partial", 35)
+ literals.Add(";", 77)
+ literals.Add("get", 20)
+ literals.Add("<<=", 94)
+ literals.Add("continue", 9)
+ literals.Add("&&", 76)
+ literals.Add("cast", 6)
+ literals.Add("<<", 93)
+ literals.Add("pragma on", 57)
+ literals.Add(".", 65)
+ literals.Add("finally", 17)
+ literals.Add("else", 11)
+ literals.Add("import", 22)
+ literals.Add("++", 79)
+ literals.Add(":", 66)
+ literals.Add("in", 24)
+ literals.Add("switch", 49)
+ literals.Add("true", 42)
+ literals.Add("-", 82)
+ literals.Add("*=", 55)
+ literals.Add("virtual", 46)
+ literals.Add("^", 73)
+ literals.Add("&=", 74)
override def nextToken() as IToken:
theRetToken as IToken
@@ -369,7 +384,7 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
mEOS(true)
theRetToken = returnToken_
elif ((_givenValue == char('#'))): // 1831
- mHASH(true)
+ mPRAGMA_ON(true)
theRetToken = returnToken_
elif ((_givenValue == char('%'))): // 1831
mMODULUS(true)
@@ -378,7 +393,7 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
mQUESTION_MARK(true)
theRetToken = returnToken_
elif ((_givenValue == char('~'))): // 1831
- mONES_COMPLEMENT(true)
+ mBITWISE_NOT(true)
theRetToken = returnToken_
elif ((_givenValue == char('@'))): // 1831
mAT(true)
@@ -397,6 +412,9 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
elif ((_givenValue == char('"'))): // 1831
mDOUBLE_QUOTED_STRING(true)
theRetToken = returnToken_
+ elif ((_givenValue == char('\''))): // 1831
+ mSINGLE_QUOTED_STRING(true)
+ theRetToken = returnToken_
else: // line 1969
if ((cached_LA1==char('=')) and (cached_LA2==char('=')) and (LA(3)==char('='))):
mREFERENCE_EQUALITY(true)
@@ -480,7 +498,7 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
mMULTIPLY(true)
theRetToken = returnToken_
elif ((cached_LA1==char('!')) and (true)): // line 2102
- mNOT(true)
+ mLOGICAL_NOT(true)
theRetToken = returnToken_
elif ((cached_LA1==char('<')) and (true)): // line 2102
mLESS_THAN(true)
@@ -580,8 +598,8 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
): // 1827
mDIGIT(false)
else: // line 1969
- goto _loop304_breakloop
- :_loop304_breakloop
+ goto _loop332_breakloop
+ :_loop332_breakloop
_ttype = testLiteralsTable(_ttype)
if (_createToken and (_token is null) and (_ttype != Token.SKIP)):
_token = makeToken(_ttype)
@@ -674,17 +692,17 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
if ((cached_LA1==char('0')) and (cached_LA2==char('x'))):
match("0x")
- _cnt308 as int = 0
+ _cnt336 as int = 0
while true:
if ((tokenSet_0_.member(cast(int, cached_LA1)))):
mHEXDIGIT(false)
else:
- if (_cnt308 >= 1):
- goto _loop308_breakloop
+ if (_cnt336 >= 1):
+ goto _loop336_breakloop
else:
raise NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn())
- ++_cnt308
- :_loop308_breakloop
+ ++_cnt336
+ :_loop336_breakloop
if ((cached_LA1==char('L') or cached_LA1==char('l'))):
_givenValue = cached_LA1
if ((_givenValue == char('l'))): // 1831
@@ -698,17 +716,17 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
else: // line 2053
pass // 947
elif ((((cached_LA1 >= char('0')) and (cached_LA1 <= char('9')))) and (true)): // line 2102
- _cnt312 as int = 0
+ _cnt340 as int = 0
while true:
if ((((cached_LA1 >= char('0')) and (cached_LA1 <= char('9'))))):
mDIGIT(false)
else:
- if (_cnt312 >= 1):
- goto _loop312_breakloop
+ if (_cnt340 >= 1):
+ goto _loop340_breakloop
else:
raise NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn())
- ++_cnt312
- :_loop312_breakloop
+ ++_cnt340
+ :_loop340_breakloop
_givenValue = cached_LA1
if ((_givenValue == char('L'))
or (_givenValue ==char('l'))
@@ -722,18 +740,20 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
raise NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn())
if 0 == inputState.guessing:
_ttype = LONG;
- elif ((_givenValue == char('F'))
+ elif ((_givenValue == char('D'))
+ or (_givenValue ==char('F'))
+ or (_givenValue ==char('d'))
or (_givenValue ==char('f'))
): // 1827
_givenValue = cached_LA1
if ((_givenValue == char('f'))): // 1831
- _saveIndex = text.Length
match('f')
- text.Length = _saveIndex
elif ((_givenValue == char('F'))): // 1831
- _saveIndex = text.Length
match('F')
- text.Length = _saveIndex
+ elif ((_givenValue == char('d'))): // 1831
+ match('d')
+ elif ((_givenValue == char('D'))): // 1831
+ match('D')
else: // line 1969
raise NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn())
if 0 == inputState.guessing:
@@ -802,30 +822,30 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
_ttype as int; _token as IToken; _begin = text.Length;
_ttype = DOUBLE_SUFFIX
- _cnt321 as int = 0
+ _cnt349 as int = 0
while true:
if ((((cached_LA1 >= char('0')) and (cached_LA1 <= char('9'))))):
mDIGIT(false)
else:
- if (_cnt321 >= 1):
- goto _loop321_breakloop
+ if (_cnt349 >= 1):
+ goto _loop349_breakloop
else:
raise NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn())
- ++_cnt321
- :_loop321_breakloop
+ ++_cnt349
+ :_loop349_breakloop
if ((cached_LA1==char('E') or cached_LA1==char('e'))):
mEXPONENT(false)
else: // line 2053
pass // 947
_givenValue = cached_LA1
if ((_givenValue == char('f'))): // 1831
- _saveIndex = text.Length
match('f')
- text.Length = _saveIndex
elif ((_givenValue == char('F'))): // 1831
- _saveIndex = text.Length
match('F')
- text.Length = _saveIndex
+ elif ((_givenValue == char('d'))): // 1831
+ match('d')
+ elif ((_givenValue == char('D'))): // 1831
+ match('D')
else: // line 1969
pass // 947
if (_createToken and (_token is null) and (_ttype != Token.SKIP)):
@@ -863,17 +883,17 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
pass // 947
else: // line 1969
raise NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn())
- _cnt328 as int = 0
+ _cnt356 as int = 0
while true:
if ((((cached_LA1 >= char('0')) and (cached_LA1 <= char('9'))))):
mDIGIT(false)
else:
- if (_cnt328 >= 1):
- goto _loop328_breakloop
+ if (_cnt356 >= 1):
+ goto _loop356_breakloop
else:
raise NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn())
- ++_cnt328
- :_loop328_breakloop
+ ++_cnt356
+ :_loop356_breakloop
if (_createToken and (_token is null) and (_ttype != Token.SKIP)):
_token = makeToken(_ttype)
_token.setText(text.ToString(_begin, text.Length-_begin))
@@ -1105,11 +1125,106 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
_token.setText(text.ToString(_begin, text.Length-_begin))
returnToken_ = _token
- public def mHASH(_createToken as bool) as void: //throws RecognitionException, CharStreamException, TokenStreamException
+ public def mPRAGMA_ON(_createToken as bool) as void: //throws RecognitionException, CharStreamException, TokenStreamException
+ _ttype as int; _token as IToken; _begin = text.Length;
+ _ttype = PRAGMA_ON
+ id as IToken
+
+ _saveIndex = text.Length
+ match("#pragma")
+ text.Length = _saveIndex
+ _cnt380 as int = 0
+ while true:
+ if ((cached_LA1==char('\t') or cached_LA1==char(' '))):
+ mPRAGMA_WHITE_SPACE(false)
+ else:
+ if (_cnt380 >= 1):
+ goto _loop380_breakloop
+ else:
+ raise NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn())
+ ++_cnt380
+ :_loop380_breakloop
+ mID(true)
+ id = returnToken_
+ if ((cached_LA1==char('\t') or cached_LA1==char(' ')) and (cached_LA2==char('\t') or cached_LA2==char(' ') or cached_LA2==char('o')) and (LA(3)==char('\t') or LA(3)==char(' ') or LA(3)==char('f') or LA(3)==char('n') or LA(3)==char('o'))):
+ _cnt383 as int = 0
+ while true:
+ if ((cached_LA1==char('\t') or cached_LA1==char(' '))):
+ mPRAGMA_WHITE_SPACE(false)
+ else:
+ if (_cnt383 >= 1):
+ goto _loop383_breakloop
+ else:
+ raise NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn())
+ ++_cnt383
+ :_loop383_breakloop
+ if ((cached_LA1==char('o')) and (cached_LA2==char('f'))):
+ _saveIndex = text.Length
+ match("off")
+ text.Length = _saveIndex
+ if 0 == inputState.guessing:
+ _ttype = PRAGMA_OFF;
+ elif ((cached_LA1==char('o')) and (cached_LA2==char('n'))): // line 2102
+ _saveIndex = text.Length
+ match("on")
+ text.Length = _saveIndex
+ else:
+ raise NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn())
+ elif ((cached_LA1==char('\t') or cached_LA1==char('\n') or cached_LA1==char('\r') or cached_LA1==char(' ')) and (true) and (true)): // line 2102
+ pass // 947
+ else:
+ raise NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn())
+ while true:
+ if ((cached_LA1==char('\t') or cached_LA1==char(' '))):
+ mPRAGMA_WHITE_SPACE(false)
+ else:
+ goto _loop386_breakloop
+ :_loop386_breakloop
+ _saveIndex = text.Length
+ mNEWLINE(false)
+ text.Length = _saveIndex
+ if (_createToken and (_token is null) and (_ttype != Token.SKIP)):
+ _token = makeToken(_ttype)
+ _token.setText(text.ToString(_begin, text.Length-_begin))
+ returnToken_ = _token
+
+ protected def mPRAGMA_WHITE_SPACE(_createToken as bool) as void: //throws RecognitionException, CharStreamException, TokenStreamException
+ _ttype as int; _token as IToken; _begin = text.Length;
+ _ttype = PRAGMA_WHITE_SPACE
+
+ _givenValue = cached_LA1
+ if ((_givenValue == char(' '))): // 1831
+ _saveIndex = text.Length
+ match(' ')
+ text.Length = _saveIndex
+ elif ((_givenValue == char('\t'))): // 1831
+ _saveIndex = text.Length
+ match('\t')
+ text.Length = _saveIndex
+ else: // line 1969
+ raise NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn())
+ if (_createToken and (_token is null) and (_ttype != Token.SKIP)):
+ _token = makeToken(_ttype)
+ _token.setText(text.ToString(_begin, text.Length-_begin))
+ returnToken_ = _token
+
+ protected def mNEWLINE(_createToken as bool) as void: //throws RecognitionException, CharStreamException, TokenStreamException
_ttype as int; _token as IToken; _begin = text.Length;
- _ttype = HASH
+ _ttype = NEWLINE
- match('#')
+ _givenValue = cached_LA1
+ if ((_givenValue == char('\n'))): // 1831
+ match('\n')
+ elif ((_givenValue == char('\r'))): // 1831
+ match('\r')
+ if ((cached_LA1==char('\n')) and (true) and (true)):
+ match('\n')
+ else: // line 2053
+ pass // 947
+ else: // line 1969
+ raise NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn())
+ if 0 == inputState.guessing:
+ newline();
if (_createToken and (_token is null) and (_ttype != Token.SKIP)):
_token = makeToken(_ttype)
_token.setText(text.ToString(_begin, text.Length-_begin))
@@ -1195,9 +1310,9 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
_token.setText(text.ToString(_begin, text.Length-_begin))
returnToken_ = _token
- public def mNOT(_createToken as bool) as void: //throws RecognitionException, CharStreamException, TokenStreamException
+ public def mLOGICAL_NOT(_createToken as bool) as void: //throws RecognitionException, CharStreamException, TokenStreamException
_ttype as int; _token as IToken; _begin = text.Length;
- _ttype = NOT
+ _ttype = LOGICAL_NOT
match('!')
if (_createToken and (_token is null) and (_ttype != Token.SKIP)):
@@ -1215,9 +1330,9 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
_token.setText(text.ToString(_begin, text.Length-_begin))
returnToken_ = _token
- public def mONES_COMPLEMENT(_createToken as bool) as void: //throws RecognitionException, CharStreamException, TokenStreamException
+ public def mBITWISE_NOT(_createToken as bool) as void: //throws RecognitionException, CharStreamException, TokenStreamException
_ttype as int; _token as IToken; _begin = text.Length;
- _ttype = ONES_COMPLEMENT
+ _ttype = BITWISE_NOT
match('~')
if (_createToken and (_token is null) and (_ttype != Token.SKIP)):
@@ -1330,12 +1445,6 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
_ttype = AT
match('@')
- if ((cached_LA1==char('s'))):
- match("script")
- if 0 == inputState.guessing:
- _ttype = SCRIPT_ATTRIBUTE_MARKER;
- else: // line 2053
- pass // 947
if (_createToken and (_token is null) and (_ttype != Token.SKIP)):
_token = makeToken(_ttype)
_token.setText(text.ToString(_begin, text.Length-_begin))
@@ -1345,21 +1454,22 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
_ttype as int; _token as IToken; _begin = text.Length;
_ttype = DIVISION
- synPredMatched376 as bool = false
+ synPredMatched413 as bool = false
if ((cached_LA1==char('/')) and (cached_LA2==char('*'))):
- _m376 as int = mark()
- synPredMatched376 = true
+ _m413 as int = mark()
+ synPredMatched413 = true
++inputState.guessing
try:
match("/*")
except x as RecognitionException:
- synPredMatched376 = false
- rewind(_m376)
+ synPredMatched413 = false
+ rewind(_m413)
--inputState.guessing
- if synPredMatched376:
+ if synPredMatched413:
mML_COMMENT(false)
if 0 == inputState.guessing:
- _ttype = Token.SKIP;
+ if not PreserveComments:
+ _ttype = Token.SKIP
elif ((cached_LA1==char('/')) and (true)): // line 2102
match('/')
_givenValue = cached_LA1
@@ -1369,10 +1479,13 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
if ((tokenSet_1_.member(cast(int, cached_LA1)))):
match(tokenSet_1_)
else:
- goto _loop381_breakloop
- :_loop381_breakloop
+ goto _loop418_breakloop
+ :_loop418_breakloop
if 0 == inputState.guessing:
- _ttype = Token.SKIP;
+ if PreserveComments:
+ _ttype = SL_COMMENT
+ else:
+ _ttype = Token.SKIP;
elif ((_givenValue == char('='))): // 1831
match('=')
if 0 == inputState.guessing:
@@ -1399,11 +1512,9 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
elif ((tokenSet_2_.member(cast(int, cached_LA1)))): // line 2102
match(tokenSet_2_)
else:
- goto _loop406_breakloop
- :_loop406_breakloop
+ goto _loop447_breakloop
+ :_loop447_breakloop
match("*/")
- if 0 == inputState.guessing:
- _ttype = Token.SKIP;
if (_createToken and (_token is null) and (_ttype != Token.SKIP)):
_token = makeToken(_ttype)
_token.setText(text.ToString(_begin, text.Length-_begin))
@@ -1413,7 +1524,7 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
_ttype as int; _token as IToken; _begin = text.Length;
_ttype = WHITE_SPACE
- _cnt385 as int = 0
+ _cnt422 as int = 0
while true:
_givenValue = cached_LA1
if ((_givenValue == char(' '))): // 1831
@@ -1427,12 +1538,12 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
): // 1827
mNEWLINE(false)
else: // line 1969
- if (_cnt385 >= 1):
- goto _loop385_breakloop
+ if (_cnt422 >= 1):
+ goto _loop422_breakloop
else:
raise NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn())
- ++_cnt385
- :_loop385_breakloop
+ ++_cnt422
+ :_loop422_breakloop
if 0 == inputState.guessing:
_ttype = Token.SKIP;
if (_createToken and (_token is null) and (_ttype != Token.SKIP)):
@@ -1440,28 +1551,6 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
_token.setText(text.ToString(_begin, text.Length-_begin))
returnToken_ = _token
- protected def mNEWLINE(_createToken as bool) as void: //throws RecognitionException, CharStreamException, TokenStreamException
- _ttype as int; _token as IToken; _begin = text.Length;
- _ttype = NEWLINE
-
- _givenValue = cached_LA1
- if ((_givenValue == char('\n'))): // 1831
- match('\n')
- elif ((_givenValue == char('\r'))): // 1831
- match('\r')
- if ((cached_LA1==char('\n')) and (true) and (true)):
- match('\n')
- else: // line 2053
- pass // 947
- else: // line 1969
- raise NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn())
- if 0 == inputState.guessing:
- newline();
- if (_createToken and (_token is null) and (_ttype != Token.SKIP)):
- _token = makeToken(_ttype)
- _token.setText(text.ToString(_begin, text.Length-_begin))
- returnToken_ = _token
-
public def mDOUBLE_QUOTED_STRING(_createToken as bool) as void: //throws RecognitionException, CharStreamException, TokenStreamException
_ttype as int; _token as IToken; _begin = text.Length;
_ttype = DOUBLE_QUOTED_STRING
@@ -1475,8 +1564,8 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
elif ((tokenSet_3_.member(cast(int, cached_LA1)))): // line 2102
match(tokenSet_3_)
else:
- goto _loop389_breakloop
- :_loop389_breakloop
+ goto _loop426_breakloop
+ :_loop426_breakloop
_saveIndex = text.Length
match('"')
text.Length = _saveIndex
@@ -1505,8 +1594,56 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
mSESC(false)
elif ((_givenValue == char('"'))): // 1831
match('"')
- elif ((_givenValue == char('$'))): // 1831
- match('$')
+ else: // line 1969
+ raise NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn())
+ if (_createToken and (_token is null) and (_ttype != Token.SKIP)):
+ _token = makeToken(_ttype)
+ _token.setText(text.ToString(_begin, text.Length-_begin))
+ returnToken_ = _token
+
+ public def mSINGLE_QUOTED_STRING(_createToken as bool) as void: //throws RecognitionException, CharStreamException, TokenStreamException
+ _ttype as int; _token as IToken; _begin = text.Length;
+ _ttype = SINGLE_QUOTED_STRING
+
+ _saveIndex = text.Length
+ match('\'')
+ text.Length = _saveIndex
+ while true:
+ if ((cached_LA1==char('\\'))):
+ mSQS_ESC(false)
+ elif ((tokenSet_4_.member(cast(int, cached_LA1)))): // line 2102
+ match(tokenSet_4_)
+ else:
+ goto _loop430_breakloop
+ :_loop430_breakloop
+ _saveIndex = text.Length
+ match('\'')
+ text.Length = _saveIndex
+ if (_createToken and (_token is null) and (_ttype != Token.SKIP)):
+ _token = makeToken(_ttype)
+ _token.setText(text.ToString(_begin, text.Length-_begin))
+ returnToken_ = _token
+
+ protected def mSQS_ESC(_createToken as bool) as void: //throws RecognitionException, CharStreamException, TokenStreamException
+ _ttype as int; _token as IToken; _begin = text.Length;
+ _ttype = SQS_ESC
+
+ _saveIndex = text.Length
+ match('\\')
+ text.Length = _saveIndex
+ _givenValue = cached_LA1
+ if ((_givenValue == char('0'))
+ or (_givenValue ==char('\\'))
+ or (_givenValue ==char('a'))
+ or (_givenValue ==char('b'))
+ or (_givenValue ==char('f'))
+ or (_givenValue ==char('n'))
+ or (_givenValue ==char('r'))
+ or (_givenValue ==char('t'))
+ ): // 1827
+ mSESC(false)
+ elif ((_givenValue == char('\''))): // 1831
+ match('\'')
else: // line 1969
raise NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn())
if (_createToken and (_token is null) and (_ttype != Token.SKIP)):
@@ -1574,49 +1711,22 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
_token.setText(text.ToString(_begin, text.Length-_begin))
returnToken_ = _token
- protected def mSQS_ESC(_createToken as bool) as void: //throws RecognitionException, CharStreamException, TokenStreamException
- _ttype as int; _token as IToken; _begin = text.Length;
- _ttype = SQS_ESC
-
- _saveIndex = text.Length
- match('\\')
- text.Length = _saveIndex
- _givenValue = cached_LA1
- if ((_givenValue == char('0'))
- or (_givenValue ==char('\\'))
- or (_givenValue ==char('a'))
- or (_givenValue ==char('b'))
- or (_givenValue ==char('f'))
- or (_givenValue ==char('n'))
- or (_givenValue ==char('r'))
- or (_givenValue ==char('t'))
- ): // 1827
- mSESC(false)
- elif ((_givenValue == char('\''))): // 1831
- match('\'')
- else: // line 1969
- raise NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn())
- if (_createToken and (_token is null) and (_ttype != Token.SKIP)):
- _token = makeToken(_ttype)
- _token.setText(text.ToString(_begin, text.Length-_begin))
- returnToken_ = _token
-
protected def mRE_LITERAL(_createToken as bool) as void: //throws RecognitionException, CharStreamException, TokenStreamException
_ttype as int; _token as IToken; _begin = text.Length;
_ttype = RE_LITERAL
match('/')
- _cnt409 as int = 0
+ _cnt450 as int = 0
while true:
- if ((tokenSet_4_.member(cast(int, cached_LA1)))):
+ if ((tokenSet_5_.member(cast(int, cached_LA1)))):
mRE_CHAR(false)
else:
- if (_cnt409 >= 1):
- goto _loop409_breakloop
+ if (_cnt450 >= 1):
+ goto _loop450_breakloop
else:
raise NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn())
- ++_cnt409
- :_loop409_breakloop
+ ++_cnt450
+ :_loop450_breakloop
match('/')
if (_createToken and (_token is null) and (_ttype != Token.SKIP)):
_token = makeToken(_ttype)
@@ -1629,8 +1739,8 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
if ((cached_LA1==char('\\'))):
mRE_ESC(false)
- elif ((tokenSet_5_.member(cast(int, cached_LA1)))): // line 2102
- match(tokenSet_5_)
+ elif ((tokenSet_6_.member(cast(int, cached_LA1)))): // line 2102
+ match(tokenSet_6_)
else:
raise NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn())
if (_createToken and (_token is null) and (_ttype != Token.SKIP)):
@@ -1674,17 +1784,17 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
or (_givenValue ==char('8'))
or (_givenValue ==char('9'))
): // 1827
- _cnt415 as int = 0
+ _cnt456 as int = 0
while true:
- if ((((cached_LA1 >= char('0')) and (cached_LA1 <= char('9')))) and (tokenSet_6_.member(cast(int, cached_LA2))) and (true)):
+ if ((((cached_LA1 >= char('0')) and (cached_LA1 <= char('9')))) and (tokenSet_7_.member(cast(int, cached_LA2))) and (true)):
mDIGIT(false)
else:
- if (_cnt415 >= 1):
- goto _loop415_breakloop
+ if (_cnt456 >= 1):
+ goto _loop456_breakloop
else:
raise NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn())
- ++_cnt415
- :_loop415_breakloop
+ ++_cnt456
+ :_loop456_breakloop
elif ((_givenValue == char('x'))): // 1831
match('x')
mDIGIT(false)
@@ -1810,8 +1920,9 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
public static final tokenSet_3_ = BitSet(mk_tokenSet_3_())
private static def mk_tokenSet_4_() as (long):
data = array(long, 2048)
- data[0]=-140741783332360L
- i = 1
+ data[0]=-549755823112L
+ data[1]=-268435457L
+ i = 2
while i<=1022:
data[i] = -1L
++i
@@ -1825,8 +1936,7 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
private static def mk_tokenSet_5_() as (long):
data = array(long, 2048)
data[0]=-140741783332360L
- data[1]=-268435457L
- i = 2
+ i = 1
while i<=1022:
data[i] = -1L
++i
@@ -1838,6 +1948,21 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
return data
public static final tokenSet_5_ = BitSet(mk_tokenSet_5_())
private static def mk_tokenSet_6_() as (long):
+ data = array(long, 2048)
+ data[0]=-140741783332360L
+ data[1]=-268435457L
+ i = 2
+ while i<=1022:
+ data[i] = -1L
+ ++i
+ data[1023]=9223372036854775807L
+ i = 1024
+ while i<=2047:
+ data[i] = 0L
+ ++i
+ return data
+ public static final tokenSet_6_ = BitSet(mk_tokenSet_6_())
+ private static def mk_tokenSet_7_() as (long):
data = array(long, 2048)
data[0]=-4294977032L
i = 1
@@ -1850,5 +1975,5 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
data[i] = 0L
++i
return data
- public static final tokenSet_6_ = BitSet(mk_tokenSet_6_())
+ public static final tokenSet_7_ = BitSet(mk_tokenSet_7_())
diff --git a/src/UnityScript/Parser/UnityScriptParser.boo b/src/UnityScript/Parser/UnityScriptParser.boo
index b88bf69..119e842 100755
--- a/src/UnityScript/Parser/UnityScriptParser.boo
+++ b/src/UnityScript/Parser/UnityScriptParser.boo
@@ -27,122 +27,129 @@ import System.Globalization
import UnityScript
import UnityScript.Core
-class UnityScriptParser(antlr.LLkParser):
+partial class UnityScriptParser(antlr.LLkParser):
public static final EOF = 1
public static final NULL_TREE_LOOKAHEAD = 3
public static final AS = 4
public static final BREAK = 5
- public static final CATCH = 6
- public static final CLASS = 7
- public static final CONTINUE = 8
- public static final ELSE = 9
- public static final ENUM = 10
- public static final EXTENDS = 11
- public static final FALSE = 12
- public static final FINAL = 13
- public static final FINALLY = 14
- public static final FOR = 15
- public static final FUNCTION = 16
- public static final GET = 17
- public static final IF = 18
- public static final IMPORT = 19
- public static final IMPLEMENTS = 20
- public static final IN = 21
- public static final INTERFACE = 22
- public static final INSTANCEOF = 23
- public static final NEW = 24
- public static final NOT = 25
- public static final NULL = 26
- public static final RETURN = 27
- public static final PUBLIC = 28
- public static final PROTECTED = 29
- public static final INTERNAL = 30
- public static final OVERRIDE = 31
- public static final PARTIAL = 32
- public static final PRAGMA = 33
- public static final PRIVATE = 34
- public static final SET = 35
- public static final STATIC = 36
- public static final SUPER = 37
- public static final THIS = 38
- public static final THROW = 39
- public static final TRUE = 40
- public static final TRY = 41
- public static final TYPEOF = 42
- public static final VAR = 43
- public static final VIRTUAL = 44
- public static final WHILE = 45
- public static final YIELD = 46
- public static final SWITCH = 47
- public static final CASE = 48
- public static final DEFAULT = 49
- public static final INPLACE_DIVISION = 50
- public static final INPLACE_ADD = 51
- public static final INPLACE_SUBTRACT = 52
- public static final INPLACE_MULTIPLY = 53
- public static final ID = 54
- public static final DOUBLE_QUOTED_STRING = 55
- public static final LBRACE = 56
- public static final RBRACE = 57
- public static final LPAREN = 58
- public static final RPAREN = 59
- public static final DOT = 60
- public static final COLON = 61
- public static final COMMA = 62
- public static final LBRACK = 63
- public static final RBRACK = 64
- public static final BITWISE_OR = 65
- public static final INPLACE_BITWISE_OR = 66
- public static final BITWISE_AND = 67
- public static final BITWISE_XOR = 68
- public static final INPLACE_BITWISE_AND = 69
- public static final LOGICAL_OR = 70
- public static final LOGICAL_AND = 71
- public static final EOS = 72
- public static final ASSIGN = 73
- public static final INCREMENT = 74
- public static final DECREMENT = 75
- public static final ADD = 76
- public static final SUBTRACT = 77
- public static final MODULUS = 78
- public static final MULTIPLY = 79
- public static final EQUALITY = 80
- public static final INEQUALITY = 81
- public static final QUESTION_MARK = 82
- public static final ONES_COMPLEMENT = 83
- public static final REFERENCE_EQUALITY = 84
- public static final REFERENCE_INEQUALITY = 85
- public static final LESS_THAN = 86
- public static final LESS_THAN_OR_EQUAL = 87
- public static final SHIFT_LEFT = 88
- public static final INPLACE_SHIFT_LEFT = 89
- public static final GREATER_THAN = 90
- public static final GREATER_THAN_OR_EQUAL = 91
- public static final SHIFT_RIGHT = 92
- public static final INPLACE_SHIFT_RIGHT = 93
- public static final AT = 94
- public static final SCRIPT_ATTRIBUTE_MARKER = 95
- public static final HASH = 96
- public static final INPLACE_BITWISE_XOR = 97
- public static final EXCLUSIVE_OR = 98
- public static final DIVISION = 99
- public static final RE_LITERAL = 100
- public static final DOUBLE = 101
- public static final INT = 102
- public static final LONG = 103
- public static final DOUBLE_SUFFIX = 104
- public static final EXPONENT = 105
- public static final WHITE_SPACE = 106
- public static final DQS_ESC = 107
- public static final SQS_ESC = 108
- public static final SESC = 109
- public static final ML_COMMENT = 110
- public static final RE_CHAR = 111
- public static final RE_ESC = 112
- public static final NEWLINE = 113
- public static final ID_LETTER = 114
- public static final DIGIT = 115
- public static final HEXDIGIT = 116
+ public static final CAST = 6
+ public static final CATCH = 7
+ public static final CLASS = 8
+ public static final CONTINUE = 9
+ public static final DO = 10
+ public static final ELSE = 11
+ public static final EACH = 12
+ public static final ENUM = 13
+ public static final EXTENDS = 14
+ public static final FALSE = 15
+ public static final FINAL = 16
+ public static final FINALLY = 17
+ public static final FOR = 18
+ public static final FUNCTION = 19
+ public static final GET = 20
+ public static final IF = 21
+ public static final IMPORT = 22
+ public static final IMPLEMENTS = 23
+ public static final IN = 24
+ public static final INTERFACE = 25
+ public static final INSTANCEOF = 26
+ public static final NEW = 27
+ public static final NOT = 28
+ public static final NULL = 29
+ public static final RETURN = 30
+ public static final PUBLIC = 31
+ public static final PROTECTED = 32
+ public static final INTERNAL = 33
+ public static final OVERRIDE = 34
+ public static final PARTIAL = 35
+ public static final PRIVATE = 36
+ public static final SET = 37
+ public static final STATIC = 38
+ public static final SUPER = 39
+ public static final THIS = 40
+ public static final THROW = 41
+ public static final TRUE = 42
+ public static final TRY = 43
+ public static final TYPEOF = 44
+ public static final VAR = 45
+ public static final VIRTUAL = 46
+ public static final WHILE = 47
+ public static final YIELD = 48
+ public static final SWITCH = 49
+ public static final CASE = 50
+ public static final DEFAULT = 51
+ public static final INPLACE_DIVISION = 52
+ public static final INPLACE_ADD = 53
+ public static final INPLACE_SUBTRACT = 54
+ public static final INPLACE_MULTIPLY = 55
+ public static final SL_COMMENT = 56
+ public static final PRAGMA_ON = 57
+ public static final PRAGMA_OFF = 58
+ public static final ID = 59
+ public static final DOUBLE_QUOTED_STRING = 60
+ public static final LBRACE = 61
+ public static final RBRACE = 62
+ public static final LPAREN = 63
+ public static final RPAREN = 64
+ public static final DOT = 65
+ public static final COLON = 66
+ public static final COMMA = 67
+ public static final LBRACK = 68
+ public static final RBRACK = 69
+ public static final BITWISE_OR = 70
+ public static final INPLACE_BITWISE_OR = 71
+ public static final BITWISE_AND = 72
+ public static final BITWISE_XOR = 73
+ public static final INPLACE_BITWISE_AND = 74
+ public static final LOGICAL_OR = 75
+ public static final LOGICAL_AND = 76
+ public static final EOS = 77
+ public static final ASSIGN = 78
+ public static final INCREMENT = 79
+ public static final DECREMENT = 80
+ public static final ADD = 81
+ public static final SUBTRACT = 82
+ public static final MODULUS = 83
+ public static final MULTIPLY = 84
+ public static final EQUALITY = 85
+ public static final INEQUALITY = 86
+ public static final QUESTION_MARK = 87
+ public static final BITWISE_NOT = 88
+ public static final REFERENCE_EQUALITY = 89
+ public static final REFERENCE_INEQUALITY = 90
+ public static final LESS_THAN = 91
+ public static final LESS_THAN_OR_EQUAL = 92
+ public static final SHIFT_LEFT = 93
+ public static final INPLACE_SHIFT_LEFT = 94
+ public static final GREATER_THAN = 95
+ public static final GREATER_THAN_OR_EQUAL = 96
+ public static final SHIFT_RIGHT = 97
+ public static final INPLACE_SHIFT_RIGHT = 98
+ public static final AT = 99
+ public static final SCRIPT_ATTRIBUTE_MARKER = 100
+ public static final ASSEMBLY_ATTRIBUTE_MARKER = 101
+ public static final INPLACE_BITWISE_XOR = 102
+ public static final LOGICAL_NOT = 103
+ public static final DIVISION = 104
+ public static final RE_LITERAL = 105
+ public static final DOUBLE = 106
+ public static final INT = 107
+ public static final LONG = 108
+ public static final SINGLE_QUOTED_STRING = 109
+ public static final DOUBLE_SUFFIX = 110
+ public static final EXPONENT = 111
+ public static final PRAGMA_WHITE_SPACE = 112
+ public static final WHITE_SPACE = 113
+ public static final DQS_ESC = 114
+ public static final SQS_ESC = 115
+ public static final SESC = 116
+ public static final ML_COMMENT = 117
+ public static final RE_CHAR = 118
+ public static final RE_ESC = 119
+ public static final NEWLINE = 120
+ public static final ID_LETTER = 121
+ public static final DIGIT = 122
+ public static final HEXDIGIT = 123
[property(CompilerContext)]
@@ -181,7 +188,7 @@ class UnityScriptParser(antlr.LLkParser):
return node.ContainsAnnotation("LabelInUse")
def FlushAttributes(node as INodeWithAttributes):
- node.Attributes.Extend(_attributes)
+ node.Attributes.AddRange(_attributes)
_attributes.Clear()
def GlobalVariablesBecomeFields():
@@ -190,9 +197,6 @@ class UnityScriptParser(antlr.LLkParser):
UnityScriptParameters as UnityScriptCompilerParameters:
get: return _context.Parameters
- static def ToLexicalInfo(token as antlr.IToken):
- return LexicalInfo(token.getFilename(), token.getLine(), token.getColumn())
-
static def SetEndSourceLocation(node as Node, token as antlr.IToken):
node.EndSourceLocation = ToSourceLocation(token)
@@ -200,9 +204,9 @@ class UnityScriptParser(antlr.LLkParser):
text = token.getText()
tokenLength = (0 if text is null else len(text)-1)
return SourceLocation(token.getLine(), token.getColumn()+tokenLength)
-
- static def ParseDouble(text as string):
- return double.Parse(text, CultureInfo.InvariantCulture)
+
+ static def ToLexicalInfo(token as antlr.IToken):
+ return LexicalInfo(token.getFilename(), token.getLine(), token.getColumn())
static def ParseIntegerLiteralExpression(token as antlr.IToken,
s as string,
@@ -233,6 +237,9 @@ class UnityScriptParser(antlr.LLkParser):
protected def VirtualKeywordHasNoEffect(token as antlr.IToken):
_context.Warnings.Add(UnityScriptWarnings.VirtualKeywordHasNoEffect(ToLexicalInfo(token)))
+ protected def UnexpectedToken(token as antlr.IToken):
+ ReportError(CompilerErrorFactory.UnexpectedToken(ToLexicalInfo(token), null, token.getText()))
+
protected def KeywordCannotBeUsedAsAnIdentifier(token as antlr.IToken):
ReportError(UnityScriptCompilerErrors.KeywordCannotBeUsedAsAnIdentifier(ToLexicalInfo(token), token.getText()))
@@ -246,11 +253,31 @@ class UnityScriptParser(antlr.LLkParser):
li = ToLexicalInfo(LT(1))
ReportError(UnityScriptCompilerErrors.SemicolonExpected(li))
- static def CreateModuleName(fname as string):
- return System.IO.Path.GetFileNameWithoutExtension(fname)
+ static def IsConstructorName(name as string, type as TypeDefinition):
+ return type.NodeType != NodeType.Module and name == type.Name
- static final ValidPragmas = ("strict", "expando", "implicit", "downcast")
-
+ def AddFunctionTo(type as TypeDefinition, nameToken as IToken, getter as IToken, setter as IToken):
+
+ name = nameToken.getText()
+ location = ToLexicalInfo(nameToken)
+
+ function as Method = (Constructor(location) if IsConstructorName(name, type) else Method(location, Name: name))
+ if getter is not null or setter is not null:
+ p = type.Members[name] as Property
+ if p is null:
+ p = Property(location, Name: name)
+ type.Members.Add(p)
+ if getter is not null:
+ assert p.Getter is null
+ p.Getter = function
+ else:
+ assert p.Setter is null
+ p.Setter = function
+ FlushAttributes(p)
+ else:
+ type.Members.Add(function)
+ FlushAttributes(function)
+ return function
protected def initialize():
tokenNames = tokenNames_
@@ -279,31 +306,64 @@ class UnityScriptParser(antlr.LLkParser):
) as void: //throws RecognitionException, TokenStreamException
eof as IToken = null
- module = Module(LexicalInfo(getFilename(), 1, 1))
- module.Name = CreateModuleName(getFilename())
+ module = CodeFactory.NewModule(getFilename())
cu.Modules.Add(module)
+ globals = module.Globals
try: // for error handling
while true:
_givenValue = LA(1)
if ((_givenValue == IMPORT)): // 1831
import_directive(module)
- elif ((_givenValue == HASH)): // 1831
+ elif ((_givenValue == PRAGMA_ON)
+ or (_givenValue ==PRAGMA_OFF)
+ ): // 1827
pragma_directive(module)
else: // line 1969
- goto _loop3_breakloop
- :_loop3_breakloop
+ synPredMatched4 as bool = false
+ if ((LA(1)==AT) and (LA(2)==ID)):
+ _m4 as int = mark()
+ synPredMatched4 = true
+ ++inputState.guessing
+ try:
+ match(AT)
+ match(ID)
+ match(ID)
+ except x as RecognitionException:
+ synPredMatched4 = false
+ rewind(_m4)
+ --inputState.guessing
+ if synPredMatched4:
+ script_or_assembly_attribute(module)
+ else:
+ goto _loop5_breakloop
+ :_loop5_breakloop
while true:
- if ((LA(1)==AT)):
+ synPredMatched8 as bool = false
+ if ((LA(1)==AT) and (LA(2)==ID)):
+ _m8 as int = mark()
+ synPredMatched8 = true
+ ++inputState.guessing
+ try:
+ match(AT)
+ match(ID)
+ match(ID)
+ except x as RecognitionException:
+ synPredMatched8 = false
+ rewind(_m8)
+ --inputState.guessing
+ if synPredMatched8:
+ script_or_assembly_attribute(module)
+ elif ((LA(1)==AT) and (LA(2)==ID)): // line 2102
attributes()
module_member(module)
elif ((tokenSet_0_.member(cast(int, LA(1)))) and (tokenSet_1_.member(cast(int, LA(2))))): // line 2102
module_member(module)
elif ((tokenSet_2_.member(cast(int, LA(1)))) and (tokenSet_3_.member(cast(int, LA(2))))): // line 2102
- global_statement(module)
+ compound_or_single_stmt(globals)
else:
- goto _loop6_breakloop
- :_loop6_breakloop
+ goto _loop10_breakloop
+ :_loop10_breakloop
eof = LT(1)
match(Token.EOF_TYPE)
if 0 == inputState.guessing:
@@ -319,14 +379,16 @@ class UnityScriptParser(antlr.LLkParser):
container as Module
) as void: //throws RecognitionException, TokenStreamException
+ imp as IToken = null
try: // for error handling
+ imp = LT(1)
match(IMPORT)
ns=qname()
eos()
if 0 == inputState.guessing:
container.Imports.Add(
- Import(ToLexicalInfo(ns), Namespace: ns.getText()))
+ Import(ToLexicalInfo(imp), ReferenceExpression(ToLexicalInfo(ns), ns.getText())))
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
@@ -338,18 +400,58 @@ class UnityScriptParser(antlr.LLkParser):
container as Module
) as void: //throws RecognitionException, TokenStreamException
- id as IToken = null
+ on as IToken = null
+ off as IToken = null
try: // for error handling
- match(HASH)
- match(PRAGMA)
- id = LT(1)
- match(ID)
+ _givenValue = LA(1)
+ if ((_givenValue == PRAGMA_ON)): // 1831
+ on = LT(1)
+ match(PRAGMA_ON)
+ if 0 == inputState.guessing:
+ id=on
+ elif ((_givenValue == PRAGMA_OFF)): // 1831
+ off = LT(1)
+ match(PRAGMA_OFF)
+ if 0 == inputState.guessing:
+ id=off
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
if 0 == inputState.guessing:
pragma = id.getText()
- if pragma not in ValidPragmas:
+ if Pragmas.IsValid(pragma):
+ if on is not null:
+ Pragmas.TryToEnableOn(container, pragma)
+ else:
+ Pragmas.DisableOn(container, pragma)
+ else:
ReportError(UnityScriptCompilerErrors.UnknownPragma(ToLexicalInfo(id), pragma))
- container.Annotate(pragma)
+ except ex as RecognitionException:
+ if (0 == inputState.guessing):
+ reportError(ex)
+ recover(ex,tokenSet_5_)
+ else:
+ raise
+
+ public def script_or_assembly_attribute(
+ m as Module
+ ) as void: //throws RecognitionException, TokenStreamException
+
+ attributeKindToken as IToken = null
+
+ try: // for error handling
+ match(AT)
+ attributeKindToken = LT(1)
+ match(ID)
+ attr=attribute_constructor()
+ if 0 == inputState.guessing:
+ attributeKind = attributeKindToken.getText()
+ if attributeKind == "assembly":
+ m.AssemblyAttributes.Add(attr)
+ elif attributeKind == "script":
+ m.Attributes.Add(attr)
+ else:
+ UnexpectedToken(attributeKindToken)
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
@@ -362,17 +464,17 @@ class UnityScriptParser(antlr.LLkParser):
_attributes.Clear()
try: // for error handling
- _cnt19 as int = 0
+ _cnt18 as int = 0
while true:
if ((LA(1)==AT)):
attribute()
else:
- if (_cnt19 >= 1):
- goto _loop19_breakloop
+ if (_cnt18 >= 1):
+ goto _loop18_breakloop
else:
raise NoViableAltException(LT(1), getFilename())
- ++_cnt19
- :_loop19_breakloop
+ ++_cnt18
+ :_loop18_breakloop
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
@@ -381,503 +483,196 @@ class UnityScriptParser(antlr.LLkParser):
raise
public def module_member(
- m as Module
+ module as Module
) as void: //throws RecognitionException, TokenStreamException
+ globals = module.Globals
try: // for error handling
- _givenValue = LA(1)
- if ((_givenValue == CLASS)
- or (_givenValue ==PARTIAL)
- ): // 1827
- class_declaration(m)
- elif ((_givenValue == INTERFACE)): // 1831
- interface_declaration(m)
- elif ((_givenValue == ENUM)): // 1831
- enum_declaration(m)
- elif ((_givenValue == FINAL)
- or (_givenValue ==FUNCTION)
- or (_givenValue ==PUBLIC)
- or (_givenValue ==PROTECTED)
- or (_givenValue ==INTERNAL)
- or (_givenValue ==PRIVATE)
- or (_givenValue ==STATIC)
- or (_givenValue ==VAR)
- or (_givenValue ==VIRTUAL)
- ): // 1827
- module_function_or_field(m)
- elif ((_givenValue == SCRIPT_ATTRIBUTE_MARKER)): // 1831
- script_attribute(m)
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
+ synPredMatched27 as bool = false
+ if (((tokenSet_7_.member(cast(int, LA(1)))) and (tokenSet_8_.member(cast(int, LA(2))))) and (GlobalVariablesBecomeFields())):
+ _m27 as int = mark()
+ synPredMatched27 = true
+ ++inputState.guessing
+ try:
+ module_member_modifiers()
+ match(VAR)
+ except x as RecognitionException:
+ synPredMatched27 = false
+ rewind(_m27)
+ --inputState.guessing
+ if synPredMatched27:
+ module_field(module)
+ elif ((LA(1)==VAR) and (tokenSet_9_.member(cast(int, LA(2))))): // line 2102
+ declaration_statement(globals)
+ eos()
+ elif ((tokenSet_10_.member(cast(int, LA(1)))) and (tokenSet_11_.member(cast(int, LA(2))))): // line 2102
+ mod=module_member_modifiers()
+ _givenValue = LA(1)
+ if ((_givenValue == CLASS)
+ or (_givenValue ==PARTIAL)
+ ): // 1827
+ mm=class_declaration(module)
+ elif ((_givenValue == INTERFACE)): // 1831
+ mm=interface_declaration(module)
+ elif ((_givenValue == ENUM)): // 1831
+ mm=enum_declaration(module)
+ elif ((_givenValue == FUNCTION)): // 1831
+ mm=function_member(module)
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
+ if 0 == inputState.guessing:
+ mm.Modifiers |= mod if mm is not null
+ else:
+ raise NoViableAltException(LT(1), getFilename())
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_7_)
+ recover(ex,tokenSet_12_)
else:
raise
- public def global_statement(
- m as Module
+ public def compound_or_single_stmt(
+ b as Block
) as void: //throws RecognitionException, TokenStreamException
- b = m.Globals
try: // for error handling
- _givenValue = LA(1)
- if ((_givenValue == FINALLY)
- or (_givenValue ==FOR)
- or (_givenValue ==IF)
- or (_givenValue ==TRY)
- or (_givenValue ==WHILE)
- or (_givenValue ==SWITCH)
- ): // 1827
- _givenValue = LA(1)
- if ((_givenValue == WHILE)): // 1831
- while_statement(b)
- elif ((_givenValue == FOR)): // 1831
- for_statement(b)
- elif ((_givenValue == IF)): // 1831
- if_statement(b)
- elif ((_givenValue == FINALLY)
- or (_givenValue ==TRY)
- ): // 1827
- try_statement(b)
- elif ((_givenValue == SWITCH)): // 1831
- switch_statement(b)
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
- elif ((_givenValue == BREAK)
- or (_givenValue ==CONTINUE)
- or (_givenValue ==FALSE)
- or (_givenValue ==FUNCTION)
- or (_givenValue ==NEW)
- or (_givenValue ==NOT)
- or (_givenValue ==NULL)
- or (_givenValue ==RETURN)
- or (_givenValue ==SUPER)
- or (_givenValue ==THIS)
- or (_givenValue ==THROW)
- or (_givenValue ==TRUE)
- or (_givenValue ==TYPEOF)
- or (_givenValue ==VAR)
- or (_givenValue ==YIELD)
- or (_givenValue ==ID)
- or (_givenValue ==DOUBLE_QUOTED_STRING)
- or (_givenValue ==LBRACE)
- or (_givenValue ==LPAREN)
- or (_givenValue ==LBRACK)
- or (_givenValue ==INCREMENT)
- or (_givenValue ==DECREMENT)
- or (_givenValue ==SUBTRACT)
- or (_givenValue ==ONES_COMPLEMENT)
- or (_givenValue ==RE_LITERAL)
- or (_givenValue ==DOUBLE)
- or (_givenValue ==INT)
- or (_givenValue ==LONG)
- ): // 1827
- _givenValue = LA(1)
- if ((_givenValue == FALSE)
- or (_givenValue ==FUNCTION)
- or (_givenValue ==NEW)
- or (_givenValue ==NOT)
- or (_givenValue ==NULL)
- or (_givenValue ==SUPER)
- or (_givenValue ==THIS)
- or (_givenValue ==TRUE)
- or (_givenValue ==TYPEOF)
- or (_givenValue ==ID)
- or (_givenValue ==DOUBLE_QUOTED_STRING)
- or (_givenValue ==LBRACE)
- or (_givenValue ==LPAREN)
- or (_givenValue ==LBRACK)
- or (_givenValue ==INCREMENT)
- or (_givenValue ==DECREMENT)
- or (_givenValue ==SUBTRACT)
- or (_givenValue ==ONES_COMPLEMENT)
- or (_givenValue ==RE_LITERAL)
- or (_givenValue ==DOUBLE)
- or (_givenValue ==INT)
- or (_givenValue ==LONG)
- ): // 1827
- expression_statement(b)
- elif ((_givenValue == YIELD)): // 1831
- yield_statement(b)
- elif ((_givenValue == RETURN)): // 1831
- return_statement(b)
- elif ((_givenValue == BREAK)): // 1831
- break_statement(b)
- elif ((_givenValue == CONTINUE)): // 1831
- continue_statement(b)
- elif ((_givenValue == THROW)): // 1831
- throw_statement(b)
- elif ((_givenValue == VAR)): // 1831
- declaration_statement(b)
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
- eos()
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
+ if ((LA(1)==LBRACE) and (tokenSet_13_.member(cast(int, LA(2))))):
+ compound_statement(b)
+ elif ((tokenSet_2_.member(cast(int, LA(1)))) and (tokenSet_14_.member(cast(int, LA(2))))): // line 2102
+ statement(b)
+ else:
+ raise NoViableAltException(LT(1), getFilename())
+ except ex as RecognitionException:
+ if (0 == inputState.guessing):
+ reportError(ex)
+ recover(ex,tokenSet_15_)
+ else:
+ raise
+
+ public def attribute_parameter(
+ attr as Ast.Attribute
+ ) as void: //throws RecognitionException, TokenStreamException
+
+
+ try: // for error handling
+ synPredMatched13 as bool = false
+ if ((LA(1)==EACH or LA(1)==ID) and (LA(2)==DOT or LA(2)==ASSIGN)):
+ _m13 as int = mark()
+ synPredMatched13 = true
+ ++inputState.guessing
+ try:
+ match(ID)
+ match(ASSIGN)
+ except x as RecognitionException:
+ synPredMatched13 = false
+ rewind(_m13)
+ --inputState.guessing
+ if synPredMatched13:
+ name=reference_expression()
+ match(ASSIGN)
+ value=expression()
+ if 0 == inputState.guessing:
+ attr.NamedArguments.Add(ExpressionPair(name, value))
+ elif ((tokenSet_16_.member(cast(int, LA(1)))) and (tokenSet_17_.member(cast(int, LA(2))))): // line 2102
+ value=expression()
+ if 0 == inputState.guessing:
+ attr.Arguments.Add(value)
+ else:
+ raise NoViableAltException(LT(1), getFilename())
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_7_)
+ recover(ex,tokenSet_18_)
else:
raise
- public def attribute_parameter_value() as Expression : //throws RecognitionException, TokenStreamException
+ public def reference_expression() as Expression : //throws RecognitionException, TokenStreamException
e as Expression
try: // for error handling
- _givenValue = LA(1)
- if ((_givenValue == INT)
- or (_givenValue ==LONG)
- ): // 1827
- e=integer_literal()
- elif ((_givenValue == DOUBLE_QUOTED_STRING)): // 1831
- e=string_literal()
- elif ((_givenValue == FALSE)
- or (_givenValue ==TRUE)
- ): // 1827
- e=bool_literal()
- elif ((_givenValue == NULL)): // 1831
- e=null_literal()
- elif ((_givenValue == DOUBLE)): // 1831
- e=double_literal()
- else: // line 1969
- if ((LA(1)==ID) and (tokenSet_8_.member(cast(int, LA(2))))):
- e=attribute_parameter_value_bitwise_expression()
- elif ((tokenSet_9_.member(cast(int, LA(1)))) and (tokenSet_10_.member(cast(int, LA(2))))): // line 2102
- e=typeof_expression()
+ e=simple_reference_expression()
+ while true:
+ if ((LA(1)==DOT)):
+ match(DOT)
+ e=member_reference_expression(e)
else:
- raise NoViableAltException(LT(1), getFilename())
+ goto _loop211_breakloop
+ :_loop211_breakloop
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_11_)
+ recover(ex,tokenSet_19_)
else:
raise
return e
- public def integer_literal() as IntegerLiteralExpression : //throws RecognitionException, TokenStreamException
- e as IntegerLiteralExpression
+ public def expression() as Expression : //throws RecognitionException, TokenStreamException
+ e as Expression
- i as IToken = null
- l as IToken = null
try: // for error handling
- _givenValue = LA(1)
- if ((_givenValue == INT)): // 1831
- i = LT(1)
- match(INT)
- if 0 == inputState.guessing:
- e = ParseIntegerLiteralExpression(i, i.getText(), false);
- elif ((_givenValue == LONG)): // 1831
- l = LT(1)
- match(LONG)
- if 0 == inputState.guessing:
- s = l.getText()
- e = ParseIntegerLiteralExpression(l, s[:-1], true)
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
+ e=conditional_expression()
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_12_)
+ recover(ex,tokenSet_20_)
else:
raise
return e
- public def string_literal() as Expression : //throws RecognitionException, TokenStreamException
- e as Expression
+ public def attribute() as void: //throws RecognitionException, TokenStreamException
- dqs as IToken = null
try: // for error handling
- dqs = LT(1)
- match(DOUBLE_QUOTED_STRING)
+ match(AT)
+ attr=attribute_constructor()
if 0 == inputState.guessing:
- e = StringLiteralExpression(ToLexicalInfo(dqs), dqs.getText())
+ _attributes.Add(attr)
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_12_)
+ recover(ex,tokenSet_21_)
else:
raise
- return e
- public def bool_literal() as BoolLiteralExpression : //throws RecognitionException, TokenStreamException
- e as BoolLiteralExpression
-
- t as IToken = null
- f as IToken = null
-
- try: // for error handling
- _givenValue = LA(1)
- if ((_givenValue == TRUE)): // 1831
- t = LT(1)
- match(TRUE)
- if 0 == inputState.guessing:
- e = BoolLiteralExpression(ToLexicalInfo(t), Value: true)
- elif ((_givenValue == FALSE)): // 1831
- f = LT(1)
- match(FALSE)
- if 0 == inputState.guessing:
- e = BoolLiteralExpression(ToLexicalInfo(f), Value: false)
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
- except ex as RecognitionException:
- if (0 == inputState.guessing):
- reportError(ex)
- recover(ex,tokenSet_12_)
- else:
- raise
- return e
-
- public def null_literal() as NullLiteralExpression : //throws RecognitionException, TokenStreamException
- e as NullLiteralExpression
-
- t as IToken = null
-
- try: // for error handling
- t = LT(1)
- match(NULL)
- if 0 == inputState.guessing:
- e = NullLiteralExpression(ToLexicalInfo(t))
- except ex as RecognitionException:
- if (0 == inputState.guessing):
- reportError(ex)
- recover(ex,tokenSet_12_)
- else:
- raise
- return e
-
- public def double_literal() as DoubleLiteralExpression : //throws RecognitionException, TokenStreamException
- rle as DoubleLiteralExpression
-
- value as IToken = null
-
- try: // for error handling
- value = LT(1)
- match(DOUBLE)
- if 0 == inputState.guessing:
- rle = DoubleLiteralExpression(ToLexicalInfo(value),
- ParseDouble(value.getText()),
- IsSingle: true);
- except ex as RecognitionException:
- if (0 == inputState.guessing):
- reportError(ex)
- recover(ex,tokenSet_12_)
- else:
- raise
- return rle
-
- public def attribute_parameter_value_bitwise_expression() as Expression : //throws RecognitionException, TokenStreamException
- e as Expression
-
- op as IToken = null
-
- try: // for error handling
- e=attribute_parameter_value_reference_expression()
- while true:
- if ((LA(1)==BITWISE_OR)):
- op = LT(1)
- match(BITWISE_OR)
- rhs=attribute_parameter_value_reference_expression()
- if 0 == inputState.guessing:
- e = BinaryExpression(ToLexicalInfo(op),
- Operator: BinaryOperatorType.BitwiseOr,
- Left: e,
- Right: rhs)
- else:
- goto _loop10_breakloop
- :_loop10_breakloop
- except ex as RecognitionException:
- if (0 == inputState.guessing):
- reportError(ex)
- recover(ex,tokenSet_11_)
- else:
- raise
- return e
-
- public def typeof_expression() as Expression : //throws RecognitionException, TokenStreamException
- e as Expression
-
- t as IToken = null
-
- try: // for error handling
- _givenValue = LA(1)
- if ((_givenValue == TYPEOF)): // 1831
- t = LT(1)
- match(TYPEOF)
- if ((LA(1)==LPAREN) and (tokenSet_13_.member(cast(int, LA(2))))):
- match(LPAREN)
- arg=expression()
- match(RPAREN)
- elif ((tokenSet_13_.member(cast(int, LA(1)))) and (tokenSet_12_.member(cast(int, LA(2))))): // line 2102
- arg=expression()
- else:
- raise NoViableAltException(LT(1), getFilename())
- if 0 == inputState.guessing:
- mie = MethodInvocationExpression(ToLexicalInfo(t));
- mie.Target = ReferenceExpression(ToLexicalInfo(t), Name: t.getText())
- mie.Arguments.Add(arg)
- e = mie
- elif ((_givenValue == FUNCTION)
- or (_givenValue ==ID)
- or (_givenValue ==LPAREN)
- ): // 1827
- _givenValue = LA(1)
- if ((_givenValue == LPAREN)): // 1831
- match(LPAREN)
- tr=type_reference()
- match(RPAREN)
- elif ((_givenValue == FUNCTION)
- or (_givenValue ==ID)
- ): // 1827
- tr=type_reference()
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
- if 0 == inputState.guessing:
- e = TypeofExpression(ToLexicalInfo(t), tr);
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
- except ex as RecognitionException:
- if (0 == inputState.guessing):
- reportError(ex)
- recover(ex,tokenSet_12_)
- else:
- raise
- return e
-
- public def attribute_parameter_value_reference_expression() as Expression : //throws RecognitionException, TokenStreamException
- e as Expression
-
-
- try: // for error handling
- e=reference_expression()
- except ex as RecognitionException:
- if (0 == inputState.guessing):
- reportError(ex)
- recover(ex,tokenSet_14_)
- else:
- raise
- return e
-
- public def reference_expression() as Expression : //throws RecognitionException, TokenStreamException
- e as Expression
-
- lbrack as IToken = null
-
- try: // for error handling
- e=simple_reference_expression()
- while true:
- if ((LA(1)==DOT)):
- match(DOT)
- _givenValue = LA(1)
- if ((_givenValue == GET)
- or (_givenValue ==SET)
- or (_givenValue ==ID)
- ): // 1827
- memberName=member()
- if 0 == inputState.guessing:
- e = MemberReferenceExpression(ToLexicalInfo(memberName), Target: e, Name: memberName.getText())
- elif ((_givenValue == LESS_THAN)): // 1831
- lbrack = LT(1)
- match(LESS_THAN)
- if 0 == inputState.guessing:
- e = gre = GenericReferenceExpression(ToLexicalInfo(lbrack), Target: e)
- genericArguments = gre.GenericArguments
- type_reference_list(genericArguments)
- match(GREATER_THAN)
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
- else:
- goto _loop196_breakloop
- :_loop196_breakloop
- except ex as RecognitionException:
- if (0 == inputState.guessing):
- reportError(ex)
- recover(ex,tokenSet_15_)
- else:
- raise
- return e
-
- public def attribute_parameter(
- attr as Ast.Attribute
- ) as void: //throws RecognitionException, TokenStreamException
-
-
- try: // for error handling
- synPredMatched14 as bool = false
- if ((LA(1)==ID) and (LA(2)==DOT or LA(2)==ASSIGN)):
- _m14 as int = mark()
- synPredMatched14 = true
- ++inputState.guessing
- try:
- match(ID)
- match(ASSIGN)
- except x as RecognitionException:
- synPredMatched14 = false
- rewind(_m14)
- --inputState.guessing
- if synPredMatched14:
- name=reference_expression()
- match(ASSIGN)
- value=attribute_parameter_value()
- if 0 == inputState.guessing:
- attr.NamedArguments.Add(ExpressionPair(name, value))
- elif ((tokenSet_16_.member(cast(int, LA(1)))) and (tokenSet_17_.member(cast(int, LA(2))))): // line 2102
- value=attribute_parameter_value()
- if 0 == inputState.guessing:
- attr.Arguments.Add(value)
- else:
- raise NoViableAltException(LT(1), getFilename())
- except ex as RecognitionException:
- if (0 == inputState.guessing):
- reportError(ex)
- recover(ex,tokenSet_11_)
- else:
- raise
-
- public def attribute() as void: //throws RecognitionException, TokenStreamException
-
-
- try: // for error handling
- match(AT)
- attr=attribute_constructor()
- if 0 == inputState.guessing:
- _attributes.Add(attr)
- except ex as RecognitionException:
- if (0 == inputState.guessing):
- reportError(ex)
- recover(ex,tokenSet_18_)
- else:
- raise
-
- public def attribute_constructor() as Boo.Lang.Compiler.Ast.Attribute : //throws RecognitionException, TokenStreamException
- attr as Boo.Lang.Compiler.Ast.Attribute
+ public def attribute_constructor() as Boo.Lang.Compiler.Ast.Attribute : //throws RecognitionException, TokenStreamException
+ attr as Boo.Lang.Compiler.Ast.Attribute
try: // for error handling
name=qname()
if 0 == inputState.guessing:
attr = Ast.Attribute(ToLexicalInfo(name), name.getText())
- if ((LA(1)==LPAREN) and (tokenSet_19_.member(cast(int, LA(2))))):
+ if ((LA(1)==LPAREN) and (tokenSet_22_.member(cast(int, LA(2))))):
match(LPAREN)
_givenValue = LA(1)
- if ((_givenValue == FALSE)
+ if ((_givenValue == EACH)
+ or (_givenValue ==FALSE)
or (_givenValue ==FUNCTION)
+ or (_givenValue ==NEW)
or (_givenValue ==NULL)
+ or (_givenValue ==SUPER)
+ or (_givenValue ==THIS)
or (_givenValue ==TRUE)
or (_givenValue ==TYPEOF)
or (_givenValue ==ID)
or (_givenValue ==DOUBLE_QUOTED_STRING)
+ or (_givenValue ==LBRACE)
or (_givenValue ==LPAREN)
+ or (_givenValue ==LBRACK)
+ or (_givenValue ==INCREMENT)
+ or (_givenValue ==DECREMENT)
+ or (_givenValue ==SUBTRACT)
+ or (_givenValue ==BITWISE_NOT)
+ or (_givenValue ==LOGICAL_NOT)
+ or (_givenValue ==RE_LITERAL)
or (_givenValue ==DOUBLE)
or (_givenValue ==INT)
or (_givenValue ==LONG)
+ or (_givenValue ==SINGLE_QUOTED_STRING)
): // 1827
attribute_parameter(attr)
while true:
@@ -885,21 +680,21 @@ class UnityScriptParser(antlr.LLkParser):
match(COMMA)
attribute_parameter(attr)
else:
- goto _loop25_breakloop
- :_loop25_breakloop
+ goto _loop24_breakloop
+ :_loop24_breakloop
elif ((_givenValue == RPAREN)): // 1831
pass // 947
else: // line 1969
raise NoViableAltException(LT(1), getFilename())
match(RPAREN)
- elif ((tokenSet_20_.member(cast(int, LA(1)))) and (tokenSet_21_.member(cast(int, LA(2))))): // line 2102
+ elif ((tokenSet_23_.member(cast(int, LA(1)))) and (tokenSet_24_.member(cast(int, LA(2))))): // line 2102
pass // 947
else:
raise NoViableAltException(LT(1), getFilename())
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_20_)
+ recover(ex,tokenSet_23_)
else:
raise
return attr
@@ -926,293 +721,23 @@ class UnityScriptParser(antlr.LLkParser):
buffer.Append(".")
buffer.Append(other.getText())
else:
- goto _loop38_breakloop
- :_loop38_breakloop
+ goto _loop35_breakloop
+ :_loop35_breakloop
if 0 == inputState.guessing:
id.setText(buffer.ToString())
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_22_)
+ recover(ex,tokenSet_25_)
else:
raise
return id
- public def class_declaration(
- parent as TypeDefinition
- ) as void: //throws RecognitionException, TokenStreamException
+ public def module_member_modifiers() as TypeMemberModifiers : //throws RecognitionException, TokenStreamException
+ m as TypeMemberModifiers
- p as IToken = null
- name as IToken = null
- rbrace as IToken = null
-
- try: // for error handling
- _givenValue = LA(1)
- if ((_givenValue == PARTIAL)): // 1831
- p = LT(1)
- match(PARTIAL)
- elif ((_givenValue == CLASS)): // 1831
- pass // 947
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
- match(CLASS)
- name = LT(1)
- match(ID)
- _givenValue = LA(1)
- if ((_givenValue == EXTENDS)): // 1831
- match(EXTENDS)
- baseType=type_reference()
- elif ((_givenValue == IMPLEMENTS)
- or (_givenValue ==LBRACE)
- ): // 1827
- pass // 947
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
- if 0 == inputState.guessing:
- cd = ClassDefinition(ToLexicalInfo(name), Name: name.getText())
- baseTypes = cd.BaseTypes
- if baseType is not null:
- baseTypes.Add(baseType)
- cd.Modifiers |= TypeMemberModifiers.Partial if p is not null
- FlushAttributes(cd)
- parent.Members.Add(cd)
- _givenValue = LA(1)
- if ((_givenValue == IMPLEMENTS)): // 1831
- match(IMPLEMENTS)
- type_reference_list(baseTypes)
- elif ((_givenValue == LBRACE)): // 1831
- pass // 947
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
- if 0 == inputState.guessing:
- for typeRef in baseTypes:
- if typeRef is baseType:
- BaseTypeAnnotations.AnnotateExtends(typeRef)
- else:
- BaseTypeAnnotations.AnnotateImplements(typeRef)
- match(LBRACE)
- while true:
- if ((tokenSet_23_.member(cast(int, LA(1))))):
- if 0 == inputState.guessing:
- mod = TypeMemberModifiers.None
- _givenValue = LA(1)
- if ((_givenValue == AT)): // 1831
- attributes()
- elif ((_givenValue == FINAL)
- or (_givenValue ==FUNCTION)
- or (_givenValue ==NEW)
- or (_givenValue ==PUBLIC)
- or (_givenValue ==PROTECTED)
- or (_givenValue ==INTERNAL)
- or (_givenValue ==OVERRIDE)
- or (_givenValue ==PRIVATE)
- or (_givenValue ==STATIC)
- or (_givenValue ==VAR)
- or (_givenValue ==VIRTUAL)
- ): // 1827
- pass // 947
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
- if ((tokenSet_24_.member(cast(int, LA(1)))) and (tokenSet_25_.member(cast(int, LA(2))))):
- mod=member_modifiers()
- elif ((LA(1)==FUNCTION or LA(1)==VAR) and (tokenSet_26_.member(cast(int, LA(2))))): // line 2102
- pass // 947
- else:
- raise NoViableAltException(LT(1), getFilename())
- _givenValue = LA(1)
- if ((_givenValue == FUNCTION)): // 1831
- m=function_member(cd)
- elif ((_givenValue == VAR)): // 1831
- m=field_member(cd)
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
- if 0 == inputState.guessing:
- m.Modifiers |= mod if m is not null
- else:
- goto _loop59_breakloop
- :_loop59_breakloop
- rbrace = LT(1)
- match(RBRACE)
- if 0 == inputState.guessing:
- SetEndSourceLocation(cd, rbrace)
- while true:
- if ((LA(1)==EOS)):
- match(EOS)
- else:
- goto _loop61_breakloop
- :_loop61_breakloop
- except ex as RecognitionException:
- if (0 == inputState.guessing):
- reportError(ex)
- recover(ex,tokenSet_7_)
- else:
- raise
-
- public def interface_declaration(
- parent as TypeDefinition
- ) as void: //throws RecognitionException, TokenStreamException
-
- name as IToken = null
- rbrace as IToken = null
-
- try: // for error handling
- match(INTERFACE)
- name = LT(1)
- match(ID)
- if 0 == inputState.guessing:
- td = InterfaceDefinition(ToLexicalInfo(name), Name: name.getText())
- baseTypes = td.BaseTypes
- FlushAttributes(td)
- parent.Members.Add(td)
- _givenValue = LA(1)
- if ((_givenValue == EXTENDS)): // 1831
- match(EXTENDS)
- type_reference_list(baseTypes)
- elif ((_givenValue == LBRACE)): // 1831
- pass // 947
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
- match(LBRACE)
- while true:
- if ((LA(1)==FUNCTION or LA(1)==AT)):
- _givenValue = LA(1)
- if ((_givenValue == AT)): // 1831
- attributes()
- elif ((_givenValue == FUNCTION)): // 1831
- pass // 947
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
- interface_member(td)
- else:
- goto _loop66_breakloop
- :_loop66_breakloop
- rbrace = LT(1)
- match(RBRACE)
- if 0 == inputState.guessing:
- SetEndSourceLocation(td, rbrace)
- while true:
- if ((LA(1)==EOS)):
- match(EOS)
- else:
- goto _loop68_breakloop
- :_loop68_breakloop
- except ex as RecognitionException:
- if (0 == inputState.guessing):
- reportError(ex)
- recover(ex,tokenSet_7_)
- else:
- raise
-
- public def enum_declaration(
- container as TypeDefinition
- ) as void: //throws RecognitionException, TokenStreamException
-
- name as IToken = null
- rbrace as IToken = null
-
- try: // for error handling
- match(ENUM)
- name = LT(1)
- match(ID)
- if 0 == inputState.guessing:
- ed = EnumDefinition(ToLexicalInfo(name), Name: name.getText())
- container.Members.Add(ed)
- match(LBRACE)
- _givenValue = LA(1)
- if ((_givenValue == ID)): // 1831
- enum_member(ed)
- while true:
- if ((LA(1)==COMMA) and (LA(2)==ID)):
- match(COMMA)
- enum_member(ed)
- else:
- goto _loop77_breakloop
- :_loop77_breakloop
- _givenValue = LA(1)
- if ((_givenValue == COMMA)): // 1831
- match(COMMA)
- elif ((_givenValue == RBRACE)): // 1831
- pass // 947
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
- elif ((_givenValue == RBRACE)): // 1831
- pass // 947
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
- rbrace = LT(1)
- match(RBRACE)
- if 0 == inputState.guessing:
- SetEndSourceLocation(ed, rbrace)
- while true:
- if ((LA(1)==EOS)):
- match(EOS)
- else:
- goto _loop80_breakloop
- :_loop80_breakloop
- except ex as RecognitionException:
- if (0 == inputState.guessing):
- reportError(ex)
- recover(ex,tokenSet_7_)
- else:
- raise
-
- public def module_function_or_field(
- m as Module
- ) as void: //throws RecognitionException, TokenStreamException
-
- globals = m.Globals
-
- try: // for error handling
- synPredMatched30 as bool = false
- if (((tokenSet_27_.member(cast(int, LA(1)))) and (tokenSet_28_.member(cast(int, LA(2))))) and (GlobalVariablesBecomeFields())):
- _m30 as int = mark()
- synPredMatched30 = true
- ++inputState.guessing
- try:
- module_member_modifiers()
- match(VAR)
- except x as RecognitionException:
- synPredMatched30 = false
- rewind(_m30)
- --inputState.guessing
- if synPredMatched30:
- module_field(m)
- elif ((LA(1)==VAR) and (LA(2)==ID)): // line 2102
- declaration_statement(globals)
- eos()
- elif ((tokenSet_29_.member(cast(int, LA(1)))) and (tokenSet_30_.member(cast(int, LA(2))))): // line 2102
- module_function(m)
- else:
- raise NoViableAltException(LT(1), getFilename())
- except ex as RecognitionException:
- if (0 == inputState.guessing):
- reportError(ex)
- recover(ex,tokenSet_7_)
- else:
- raise
-
- public def script_attribute(
- m as Module
- ) as void: //throws RecognitionException, TokenStreamException
-
-
- try: // for error handling
- match(SCRIPT_ATTRIBUTE_MARKER)
- attr=attribute_constructor()
- if 0 == inputState.guessing:
- m.Attributes.Add(attr);
- except ex as RecognitionException:
- if (0 == inputState.guessing):
- reportError(ex)
- recover(ex,tokenSet_7_)
- else:
- raise
-
- public def module_member_modifiers() as TypeMemberModifiers : //throws RecognitionException, TokenStreamException
- m as TypeMemberModifiers
-
- v as IToken = null
- m = TypeMemberModifiers.None
+ v as IToken = null
+ m = TypeMemberModifiers.None
try: // for error handling
while true:
@@ -1247,12 +772,12 @@ class UnityScriptParser(antlr.LLkParser):
if 0 == inputState.guessing:
VirtualKeywordHasNoEffect(v)
else: // line 1969
- goto _loop47_breakloop
- :_loop47_breakloop
+ goto _loop45_breakloop
+ :_loop45_breakloop
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_31_)
+ recover(ex,tokenSet_26_)
else:
raise
return m
@@ -1270,7 +795,7 @@ class UnityScriptParser(antlr.LLkParser):
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_7_)
+ recover(ex,tokenSet_12_)
else:
raise
@@ -1290,17 +815,19 @@ class UnityScriptParser(antlr.LLkParser):
or (_givenValue ==CATCH)
or (_givenValue ==CLASS)
or (_givenValue ==CONTINUE)
+ or (_givenValue ==DO)
or (_givenValue ==ELSE)
+ or (_givenValue ==EACH)
or (_givenValue ==ENUM)
or (_givenValue ==FALSE)
or (_givenValue ==FINAL)
or (_givenValue ==FINALLY)
or (_givenValue ==FOR)
or (_givenValue ==FUNCTION)
+ or (_givenValue ==GET)
or (_givenValue ==IF)
or (_givenValue ==INTERFACE)
or (_givenValue ==NEW)
- or (_givenValue ==NOT)
or (_givenValue ==NULL)
or (_givenValue ==RETURN)
or (_givenValue ==PUBLIC)
@@ -1308,6 +835,7 @@ class UnityScriptParser(antlr.LLkParser):
or (_givenValue ==INTERNAL)
or (_givenValue ==PARTIAL)
or (_givenValue ==PRIVATE)
+ or (_givenValue ==SET)
or (_givenValue ==STATIC)
or (_givenValue ==SUPER)
or (_givenValue ==THIS)
@@ -1332,13 +860,14 @@ class UnityScriptParser(antlr.LLkParser):
or (_givenValue ==INCREMENT)
or (_givenValue ==DECREMENT)
or (_givenValue ==SUBTRACT)
- or (_givenValue ==ONES_COMPLEMENT)
+ or (_givenValue ==BITWISE_NOT)
or (_givenValue ==AT)
- or (_givenValue ==SCRIPT_ATTRIBUTE_MARKER)
+ or (_givenValue ==LOGICAL_NOT)
or (_givenValue ==RE_LITERAL)
or (_givenValue ==DOUBLE)
or (_givenValue ==INT)
or (_givenValue ==LONG)
+ or (_givenValue ==SINGLE_QUOTED_STRING)
): // 1827
pass // 947
else: // line 1969
@@ -1349,27 +878,32 @@ class UnityScriptParser(antlr.LLkParser):
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_32_)
+ recover(ex,tokenSet_15_)
else:
raise
- public def eos() as void: //throws RecognitionException, TokenStreamException
+ public def eos() as antlr.IToken : //throws RecognitionException, TokenStreamException
+ firstEOS as antlr.IToken
+ t as IToken = null
try: // for error handling
- if ((LA(1)==EOS) and (tokenSet_33_.member(cast(int, LA(2))))):
- _cnt44 as int = 0
+ if ((LA(1)==EOS) and (tokenSet_27_.member(cast(int, LA(2))))):
+ _cnt42 as int = 0
while true:
- if ((LA(1)==EOS) and (tokenSet_33_.member(cast(int, LA(2))))):
+ if ((LA(1)==EOS) and (tokenSet_27_.member(cast(int, LA(2))))):
+ t = LT(1)
match(EOS)
+ if 0 == inputState.guessing:
+ if firstEOS is null: firstEOS = t
else:
- if (_cnt44 >= 1):
- goto _loop44_breakloop
+ if (_cnt42 >= 1):
+ goto _loop42_breakloop
else:
raise NoViableAltException(LT(1), getFilename())
- ++_cnt44
- :_loop44_breakloop
- elif ((tokenSet_33_.member(cast(int, LA(1)))) and (tokenSet_34_.member(cast(int, LA(2))))): // line 2102
+ ++_cnt42
+ :_loop42_breakloop
+ elif ((tokenSet_27_.member(cast(int, LA(1)))) and (tokenSet_28_.member(cast(int, LA(2))))): // line 2102
if 0 == inputState.guessing:
SemicolonExpected()
else:
@@ -1377,61 +911,318 @@ class UnityScriptParser(antlr.LLkParser):
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_33_)
+ recover(ex,tokenSet_27_)
else:
raise
+ return firstEOS
- public def module_function(
+ public def class_declaration(
parent as TypeDefinition
- ) as void: //throws RecognitionException, TokenStreamException
+ ) as TypeMember : //throws RecognitionException, TokenStreamException
+ member as TypeMember
+ p as IToken = null
name as IToken = null
+ rbrace as IToken = null
try: // for error handling
- mod=module_member_modifiers()
- match(FUNCTION)
+ _givenValue = LA(1)
+ if ((_givenValue == PARTIAL)): // 1831
+ p = LT(1)
+ match(PARTIAL)
+ elif ((_givenValue == CLASS)): // 1831
+ pass // 947
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
+ match(CLASS)
name = LT(1)
match(ID)
+ _givenValue = LA(1)
+ if ((_givenValue == EXTENDS)): // 1831
+ match(EXTENDS)
+ baseType=type_reference()
+ elif ((_givenValue == IMPLEMENTS)
+ or (_givenValue ==LBRACE)
+ ): // 1827
+ pass // 947
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
if 0 == inputState.guessing:
- method = Method(ToLexicalInfo(name), Name: name.getText())
- method.Modifiers = mod
- FlushAttributes(method)
- parent.Members.Add(method)
- function_body(method)
- except ex as RecognitionException:
- if (0 == inputState.guessing):
- reportError(ex)
- recover(ex,tokenSet_7_)
- else:
- raise
-
- public def field_member(
- cd as TypeDefinition
- ) as TypeMember : //throws RecognitionException, TokenStreamException
- member as TypeMember
-
-
- try: // for error handling
- match(VAR)
- name=member_name()
+ member = cd = ClassDefinition(ToLexicalInfo(name), Name: name.getText())
+ baseTypes = cd.BaseTypes
+ if baseType is not null:
+ baseTypes.Add(baseType)
+ cd.Modifiers |= TypeMemberModifiers.Partial if p is not null
+ FlushAttributes(cd)
+ parent.Members.Add(cd)
_givenValue = LA(1)
- if ((_givenValue == COLON)): // 1831
- match(COLON)
- tr=type_reference()
- elif ((_givenValue == EOF)
- or (_givenValue ==BREAK)
- or (_givenValue ==CLASS)
- or (_givenValue ==CONTINUE)
- or (_givenValue ==ENUM)
- or (_givenValue ==FALSE)
- or (_givenValue ==FINAL)
- or (_givenValue ==FINALLY)
- or (_givenValue ==FOR)
+ if ((_givenValue == IMPLEMENTS)): // 1831
+ match(IMPLEMENTS)
+ type_reference_list(baseTypes)
+ elif ((_givenValue == LBRACE)): // 1831
+ pass // 947
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
+ if 0 == inputState.guessing:
+ for typeRef in baseTypes:
+ if typeRef is baseType:
+ BaseTypeAnnotations.AnnotateExtends(typeRef)
+ else:
+ BaseTypeAnnotations.AnnotateImplements(typeRef)
+ match(LBRACE)
+ while true:
+ if ((tokenSet_29_.member(cast(int, LA(1))))):
+ if 0 == inputState.guessing:
+ mod = TypeMemberModifiers.None
+ _givenValue = LA(1)
+ if ((_givenValue == AT)): // 1831
+ attributes()
+ elif ((_givenValue == CLASS)
+ or (_givenValue ==ENUM)
+ or (_givenValue ==FINAL)
+ or (_givenValue ==FUNCTION)
+ or (_givenValue ==INTERFACE)
+ or (_givenValue ==NEW)
+ or (_givenValue ==PUBLIC)
+ or (_givenValue ==PROTECTED)
+ or (_givenValue ==INTERNAL)
+ or (_givenValue ==OVERRIDE)
+ or (_givenValue ==PARTIAL)
+ or (_givenValue ==PRIVATE)
+ or (_givenValue ==STATIC)
+ or (_givenValue ==VAR)
+ or (_givenValue ==VIRTUAL)
+ ): // 1827
+ pass // 947
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
+ if ((tokenSet_30_.member(cast(int, LA(1)))) and (tokenSet_31_.member(cast(int, LA(2))))):
+ mod=member_modifiers()
+ elif ((tokenSet_26_.member(cast(int, LA(1)))) and (tokenSet_32_.member(cast(int, LA(2))))): // line 2102
+ pass // 947
+ else:
+ raise NoViableAltException(LT(1), getFilename())
+ _givenValue = LA(1)
+ if ((_givenValue == FUNCTION)): // 1831
+ m=function_member(cd)
+ elif ((_givenValue == VAR)): // 1831
+ m=field_member(cd)
+ elif ((_givenValue == ENUM)): // 1831
+ m=enum_declaration(cd)
+ elif ((_givenValue == CLASS)
+ or (_givenValue ==PARTIAL)
+ ): // 1827
+ m=class_declaration(cd)
+ elif ((_givenValue == INTERFACE)): // 1831
+ m=interface_declaration(cd)
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
+ if 0 == inputState.guessing:
+ m.Modifiers |= mod if m is not null
+ else:
+ goto _loop57_breakloop
+ :_loop57_breakloop
+ rbrace = LT(1)
+ match(RBRACE)
+ if 0 == inputState.guessing:
+ SetEndSourceLocation(cd, rbrace)
+ while true:
+ if ((LA(1)==EOS) and (tokenSet_33_.member(cast(int, LA(2))))):
+ match(EOS)
+ else:
+ goto _loop59_breakloop
+ :_loop59_breakloop
+ except ex as RecognitionException:
+ if (0 == inputState.guessing):
+ reportError(ex)
+ recover(ex,tokenSet_33_)
+ else:
+ raise
+ return member
+
+ public def interface_declaration(
+ parent as TypeDefinition
+ ) as TypeMember : //throws RecognitionException, TokenStreamException
+ member as TypeMember
+
+ name as IToken = null
+ rbrace as IToken = null
+
+ try: // for error handling
+ match(INTERFACE)
+ name = LT(1)
+ match(ID)
+ if 0 == inputState.guessing:
+ member = td = InterfaceDefinition(ToLexicalInfo(name), Name: name.getText())
+ baseTypes = td.BaseTypes
+ FlushAttributes(td)
+ parent.Members.Add(td)
+ _givenValue = LA(1)
+ if ((_givenValue == EXTENDS)): // 1831
+ match(EXTENDS)
+ type_reference_list(baseTypes)
+ elif ((_givenValue == LBRACE)): // 1831
+ pass // 947
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
+ match(LBRACE)
+ while true:
+ if ((LA(1)==FUNCTION or LA(1)==AT)):
+ _givenValue = LA(1)
+ if ((_givenValue == AT)): // 1831
+ attributes()
+ elif ((_givenValue == FUNCTION)): // 1831
+ pass // 947
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
+ interface_member(td)
+ else:
+ goto _loop64_breakloop
+ :_loop64_breakloop
+ rbrace = LT(1)
+ match(RBRACE)
+ if 0 == inputState.guessing:
+ SetEndSourceLocation(td, rbrace)
+ while true:
+ if ((LA(1)==EOS) and (tokenSet_33_.member(cast(int, LA(2))))):
+ match(EOS)
+ else:
+ goto _loop66_breakloop
+ :_loop66_breakloop
+ except ex as RecognitionException:
+ if (0 == inputState.guessing):
+ reportError(ex)
+ recover(ex,tokenSet_33_)
+ else:
+ raise
+ return member
+
+ public def enum_declaration(
+ container as TypeDefinition
+ ) as TypeMember : //throws RecognitionException, TokenStreamException
+ member as TypeMember
+
+ name as IToken = null
+ rbrace as IToken = null
+
+ try: // for error handling
+ match(ENUM)
+ name = LT(1)
+ match(ID)
+ if 0 == inputState.guessing:
+ member = ed = EnumDefinition(ToLexicalInfo(name), Name: name.getText())
+ FlushAttributes(member);
+ container.Members.Add(ed)
+ match(LBRACE)
+ _givenValue = LA(1)
+ if ((_givenValue == EACH)
+ or (_givenValue ==FINAL)
+ or (_givenValue ==INTERNAL)
+ or (_givenValue ==ID)
+ or (_givenValue ==AT)
+ ): // 1827
+ enum_member(ed)
+ while true:
+ if ((LA(1)==COMMA) and (tokenSet_34_.member(cast(int, LA(2))))):
+ match(COMMA)
+ enum_member(ed)
+ else:
+ goto _loop76_breakloop
+ :_loop76_breakloop
+ _givenValue = LA(1)
+ if ((_givenValue == COMMA)): // 1831
+ match(COMMA)
+ elif ((_givenValue == RBRACE)): // 1831
+ pass // 947
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
+ elif ((_givenValue == RBRACE)): // 1831
+ pass // 947
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
+ rbrace = LT(1)
+ match(RBRACE)
+ if 0 == inputState.guessing:
+ SetEndSourceLocation(ed, rbrace)
+ while true:
+ if ((LA(1)==EOS) and (tokenSet_33_.member(cast(int, LA(2))))):
+ match(EOS)
+ else:
+ goto _loop79_breakloop
+ :_loop79_breakloop
+ except ex as RecognitionException:
+ if (0 == inputState.guessing):
+ reportError(ex)
+ recover(ex,tokenSet_33_)
+ else:
+ raise
+ return member
+
+ public def function_member(
+ cd as TypeDefinition
+ ) as TypeMember : //throws RecognitionException, TokenStreamException
+ member as TypeMember
+
+ getter as IToken = null
+ setter as IToken = null
+
+ try: // for error handling
+ match(FUNCTION)
+ _givenValue = LA(1)
+ if ((_givenValue == GET)): // 1831
+ getter = LT(1)
+ match(GET)
+ elif ((_givenValue == SET)): // 1831
+ setter = LT(1)
+ match(SET)
+ elif ((_givenValue == EACH)
+ or (_givenValue ==FINAL)
+ or (_givenValue ==INTERNAL)
+ or (_givenValue ==ID)
+ ): // 1827
+ pass // 947
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
+ memberName=identifier()
+ if 0 == inputState.guessing:
+ member = function = AddFunctionTo(cd, memberName, getter, setter)
+ function_body(function)
+ except ex as RecognitionException:
+ if (0 == inputState.guessing):
+ reportError(ex)
+ recover(ex,tokenSet_33_)
+ else:
+ raise
+ return member
+
+ public def field_member(
+ cd as TypeDefinition
+ ) as TypeMember : //throws RecognitionException, TokenStreamException
+ member as TypeMember
+
+
+ try: // for error handling
+ match(VAR)
+ name=identifier()
+ _givenValue = LA(1)
+ if ((_givenValue == COLON)): // 1831
+ match(COLON)
+ tr=type_reference()
+ elif ((_givenValue == EOF)
+ or (_givenValue ==BREAK)
+ or (_givenValue ==CLASS)
+ or (_givenValue ==CONTINUE)
+ or (_givenValue ==DO)
+ or (_givenValue ==EACH)
+ or (_givenValue ==ENUM)
+ or (_givenValue ==FALSE)
+ or (_givenValue ==FINAL)
+ or (_givenValue ==FOR)
or (_givenValue ==FUNCTION)
+ or (_givenValue ==GET)
or (_givenValue ==IF)
or (_givenValue ==INTERFACE)
or (_givenValue ==NEW)
- or (_givenValue ==NOT)
or (_givenValue ==NULL)
or (_givenValue ==RETURN)
or (_givenValue ==PUBLIC)
@@ -1440,6 +1231,7 @@ class UnityScriptParser(antlr.LLkParser):
or (_givenValue ==OVERRIDE)
or (_givenValue ==PARTIAL)
or (_givenValue ==PRIVATE)
+ or (_givenValue ==SET)
or (_givenValue ==STATIC)
or (_givenValue ==SUPER)
or (_givenValue ==THIS)
@@ -1463,13 +1255,14 @@ class UnityScriptParser(antlr.LLkParser):
or (_givenValue ==INCREMENT)
or (_givenValue ==DECREMENT)
or (_givenValue ==SUBTRACT)
- or (_givenValue ==ONES_COMPLEMENT)
+ or (_givenValue ==BITWISE_NOT)
or (_givenValue ==AT)
- or (_givenValue ==SCRIPT_ATTRIBUTE_MARKER)
+ or (_givenValue ==LOGICAL_NOT)
or (_givenValue ==RE_LITERAL)
or (_givenValue ==DOUBLE)
or (_givenValue ==INT)
or (_givenValue ==LONG)
+ or (_givenValue ==SINGLE_QUOTED_STRING)
): // 1827
pass // 947
else: // line 1969
@@ -1482,16 +1275,17 @@ class UnityScriptParser(antlr.LLkParser):
or (_givenValue ==BREAK)
or (_givenValue ==CLASS)
or (_givenValue ==CONTINUE)
+ or (_givenValue ==DO)
+ or (_givenValue ==EACH)
or (_givenValue ==ENUM)
or (_givenValue ==FALSE)
or (_givenValue ==FINAL)
- or (_givenValue ==FINALLY)
or (_givenValue ==FOR)
or (_givenValue ==FUNCTION)
+ or (_givenValue ==GET)
or (_givenValue ==IF)
or (_givenValue ==INTERFACE)
or (_givenValue ==NEW)
- or (_givenValue ==NOT)
or (_givenValue ==NULL)
or (_givenValue ==RETURN)
or (_givenValue ==PUBLIC)
@@ -1500,6 +1294,7 @@ class UnityScriptParser(antlr.LLkParser):
or (_givenValue ==OVERRIDE)
or (_givenValue ==PARTIAL)
or (_givenValue ==PRIVATE)
+ or (_givenValue ==SET)
or (_givenValue ==STATIC)
or (_givenValue ==SUPER)
or (_givenValue ==THIS)
@@ -1522,1001 +1317,1119 @@ class UnityScriptParser(antlr.LLkParser):
or (_givenValue ==INCREMENT)
or (_givenValue ==DECREMENT)
or (_givenValue ==SUBTRACT)
- or (_givenValue ==ONES_COMPLEMENT)
+ or (_givenValue ==BITWISE_NOT)
or (_givenValue ==AT)
- or (_givenValue ==SCRIPT_ATTRIBUTE_MARKER)
+ or (_givenValue ==LOGICAL_NOT)
or (_givenValue ==RE_LITERAL)
or (_givenValue ==DOUBLE)
or (_givenValue ==INT)
or (_givenValue ==LONG)
+ or (_givenValue ==SINGLE_QUOTED_STRING)
): // 1827
pass // 947
else: // line 1969
raise NoViableAltException(LT(1), getFilename())
- eos()
+ finalToken=eos()
if 0 == inputState.guessing:
member = Field(ToLexicalInfo(name),
Name: name.getText(),
Type: tr,
Initializer: initializer)
+ if finalToken is not null: SetEndSourceLocation(member, finalToken)
FlushAttributes(member)
cd.Members.Add(member)
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_35_)
+ recover(ex,tokenSet_33_)
else:
raise
return member
- public def while_statement(
- container as Block
- ) as void: //throws RecognitionException, TokenStreamException
+ public def member_modifiers() as TypeMemberModifiers : //throws RecognitionException, TokenStreamException
+ m as TypeMemberModifiers
- w as IToken = null
+ v as IToken = null
+ m = TypeMemberModifiers.None
try: // for error handling
- w = LT(1)
- match(WHILE)
- e=paren_expression()
- if 0 == inputState.guessing:
- ws = WhileStatement(ToLexicalInfo(w), Condition: e)
- b = ws.Block
- container.Add(ws)
- EnterLoop(ws)
- compound_or_single_stmt(b)
- if 0 == inputState.guessing:
- LeaveLoop(ws)
- except ex as RecognitionException:
- if (0 == inputState.guessing):
- reportError(ex)
- recover(ex,tokenSet_32_)
- else:
- raise
-
- public def for_statement(
- container as Block
- ) as void: //throws RecognitionException, TokenStreamException
-
- f as IToken = null
-
- try: // for error handling
- f = LT(1)
- match(FOR)
- match(LPAREN)
- synPredMatched127 as bool = false
- if ((LA(1)==VAR or LA(1)==ID) and (LA(2)==IN or LA(2)==ID)):
- _m127 as int = mark()
- synPredMatched127 = true
- ++inputState.guessing
- try:
- _givenValue = LA(1)
- if ((_givenValue == ID)): // 1831
- match(ID)
- elif ((_givenValue == VAR)): // 1831
- declaration()
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
- match(IN)
- except x as RecognitionException:
- synPredMatched127 = false
- rewind(_m127)
- --inputState.guessing
- if synPredMatched127:
- stmt=for_in(container)
- elif ((tokenSet_36_.member(cast(int, LA(1)))) and (tokenSet_37_.member(cast(int, LA(2))))): // line 2102
- stmt=for_c(container)
- else:
- raise NoViableAltException(LT(1), getFilename())
- if 0 == inputState.guessing:
- stmt.LexicalInfo = ToLexicalInfo(f) if stmt is not null
+ while true:
+ _givenValue = LA(1)
+ if ((_givenValue == FINAL)): // 1831
+ match(FINAL)
+ if 0 == inputState.guessing:
+ m |= TypeMemberModifiers.Final
+ elif ((_givenValue == OVERRIDE)): // 1831
+ match(OVERRIDE)
+ if 0 == inputState.guessing:
+ m |= TypeMemberModifiers.Override
+ elif ((_givenValue == PUBLIC)): // 1831
+ match(PUBLIC)
+ if 0 == inputState.guessing:
+ m |= TypeMemberModifiers.Public
+ elif ((_givenValue == PRIVATE)): // 1831
+ match(PRIVATE)
+ if 0 == inputState.guessing:
+ m |= TypeMemberModifiers.Private
+ elif ((_givenValue == PROTECTED)): // 1831
+ match(PROTECTED)
+ if 0 == inputState.guessing:
+ m |= TypeMemberModifiers.Protected
+ elif ((_givenValue == INTERNAL)): // 1831
+ match(INTERNAL)
+ if 0 == inputState.guessing:
+ m |= TypeMemberModifiers.Internal
+ elif ((_givenValue == STATIC)): // 1831
+ match(STATIC)
+ if 0 == inputState.guessing:
+ m |= TypeMemberModifiers.Static
+ elif ((_givenValue == NEW)): // 1831
+ match(NEW)
+ if 0 == inputState.guessing:
+ m |= TypeMemberModifiers.New
+ elif ((_givenValue == VIRTUAL)): // 1831
+ v = LT(1)
+ match(VIRTUAL)
+ if 0 == inputState.guessing:
+ VirtualKeywordHasNoEffect(v)
+ else: // line 1969
+ goto _loop48_breakloop
+ :_loop48_breakloop
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_32_)
+ recover(ex,tokenSet_26_)
else:
raise
+ return m
- public def if_statement(
- container as Block
- ) as void: //throws RecognitionException, TokenStreamException
+ public def type_reference() as TypeReference : //throws RecognitionException, TokenStreamException
+ tr as TypeReference
- it as IToken = null
- et as IToken = null
+ lbrack as IToken = null
+ rank = 1
try: // for error handling
- it = LT(1)
- match(IF)
- e=paren_expression()
- if 0 == inputState.guessing:
- s = IfStatement(ToLexicalInfo(it), Condition: e)
- b = s.TrueBlock = Block()
- container.Add(s)
- compound_or_single_stmt(b)
- if ((LA(1)==ELSE) and (tokenSet_38_.member(cast(int, LA(2))))):
- et = LT(1)
- match(ELSE)
+ _givenValue = LA(1)
+ if ((_givenValue == ID)): // 1831
+ tr=simple_type_reference()
+ elif ((_givenValue == FUNCTION)): // 1831
+ tr=anonymous_function_type()
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
+ if ((LA(1)==LBRACK) and (LA(2)==COMMA or LA(2)==RBRACK)):
+ lbrack = LT(1)
+ match(LBRACK)
+ while true:
+ if ((LA(1)==COMMA)):
+ match(COMMA)
+ if 0 == inputState.guessing:
+ ++rank
+ else:
+ goto _loop179_breakloop
+ :_loop179_breakloop
+ match(RBRACK)
if 0 == inputState.guessing:
- b = s.FalseBlock = Block(ToLexicalInfo(et))
- compound_or_single_stmt(b)
- elif ((tokenSet_32_.member(cast(int, LA(1)))) and (tokenSet_12_.member(cast(int, LA(2))))): // line 2102
+ tr = ArrayTypeReference(tr.LexicalInfo, tr, IntegerLiteralExpression(ToLexicalInfo(lbrack), rank))
+ elif ((tokenSet_35_.member(cast(int, LA(1)))) and (tokenSet_25_.member(cast(int, LA(2))))): // line 2102
pass // 947
else:
raise NoViableAltException(LT(1), getFilename())
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_32_)
+ recover(ex,tokenSet_35_)
else:
raise
+ return tr
- public def try_statement(
- container as Block
+ public def type_reference_list(
+ typeReferences as TypeReferenceCollection
) as void: //throws RecognitionException, TokenStreamException
- tt as IToken = null
- ct as IToken = null
- id as IToken = null
try: // for error handling
- _givenValue = LA(1)
- if ((_givenValue == TRY)): // 1831
- tt = LT(1)
- match(TRY)
- if 0 == inputState.guessing:
- s = TryStatement(ToLexicalInfo(tt))
- b = s.ProtectedBlock
- container.Add(s)
- compound_or_single_stmt(b)
- _cnt154 as int = 0
- while true:
- if ((LA(1)==CATCH) and (LA(2)==LPAREN)):
- ct = LT(1)
- match(CATCH)
- match(LPAREN)
- id = LT(1)
- match(ID)
- _givenValue = LA(1)
- if ((_givenValue == COLON)): // 1831
- match(COLON)
- tr=type_reference()
- elif ((_givenValue == RPAREN)): // 1831
- pass // 947
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
- match(RPAREN)
- if 0 == inputState.guessing:
- tr = SimpleTypeReference(ToLexicalInfo(id), "System.Exception") if tr is null
- handler = ExceptionHandler(
- ToLexicalInfo(ct),
- Declaration: Declaration(
- ToLexicalInfo(id),
- Name: id.getText(),
- Type: tr))
- s.ExceptionHandlers.Add(handler)
- b = handler.Block
- tr = null
- compound_or_single_stmt(b)
- else:
- if (_cnt154 >= 1):
- goto _loop154_breakloop
- else:
- raise NoViableAltException(LT(1), getFilename())
- ++_cnt154
- :_loop154_breakloop
- if ((LA(1)==FINALLY) and (tokenSet_38_.member(cast(int, LA(2))))):
- finally_block(s)
- elif ((tokenSet_32_.member(cast(int, LA(1)))) and (tokenSet_12_.member(cast(int, LA(2))))): // line 2102
- pass // 947
+ tr=type_reference()
+ if 0 == inputState.guessing:
+ typeReferences.Add(tr)
+ while true:
+ if ((LA(1)==COMMA)):
+ match(COMMA)
+ tr=type_reference()
+ if 0 == inputState.guessing:
+ typeReferences.Add(tr)
else:
- raise NoViableAltException(LT(1), getFilename())
- elif ((_givenValue == FINALLY)): // 1831
- finally_block(s)
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
+ goto _loop195_breakloop
+ :_loop195_breakloop
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_32_)
+ recover(ex,tokenSet_36_)
else:
raise
- public def switch_statement(
- container as Block
+ public def interface_member(
+ parent as TypeDefinition
) as void: //throws RecognitionException, TokenStreamException
- s as IToken = null
- c as IToken = null
- fallthrough as IToken = null
- d as IToken = null
+ getter as IToken = null
+ setter as IToken = null
try: // for error handling
- s = LT(1)
- match(SWITCH)
- e=paren_expression()
+ match(FUNCTION)
+ _givenValue = LA(1)
+ if ((_givenValue == GET)): // 1831
+ getter = LT(1)
+ match(GET)
+ elif ((_givenValue == SET)): // 1831
+ setter = LT(1)
+ match(SET)
+ elif ((_givenValue == EACH)
+ or (_givenValue ==FINAL)
+ or (_givenValue ==INTERNAL)
+ or (_givenValue ==ID)
+ ): // 1827
+ pass // 947
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
+ memberName=identifier()
if 0 == inputState.guessing:
- switchMacro = MacroStatement(ToLexicalInfo(s), Name: MacroName(s.getText()))
- switchMacro.Arguments.Add(e)
- switchBlock = switchMacro.Body
- container.Add(switchMacro)
- match(LBRACE)
- while true:
- if ((LA(1)==CASE)):
- c = LT(1)
- match(CASE)
- e=expression()
- match(COLON)
- if 0 == inputState.guessing:
- item = MacroStatement(ToLexicalInfo(c), Name: c.getText())
- item.Arguments.Add(e)
- itemBlock = item.Body
- switchBlock.Add(item)
- while true:
- if ((LA(1)==CASE)):
- fallthrough = LT(1)
- match(CASE)
- e=expression()
- match(COLON)
- if 0 == inputState.guessing:
- item.Arguments.Add(e);
- else:
- goto _loop141_breakloop
- :_loop141_breakloop
- _cnt143 as int = 0
- while true:
- if ((tokenSet_38_.member(cast(int, LA(1))))):
- statement(itemBlock)
- else:
- if (_cnt143 >= 1):
- goto _loop143_breakloop
- else:
- raise NoViableAltException(LT(1), getFilename())
- ++_cnt143
- :_loop143_breakloop
- else:
- goto _loop144_breakloop
- :_loop144_breakloop
+ function = AddFunctionTo(parent, memberName, getter, setter)
+ match(LPAREN)
_givenValue = LA(1)
- if ((_givenValue == DEFAULT)): // 1831
- d = LT(1)
- match(DEFAULT)
+ if ((_givenValue == EACH)
+ or (_givenValue ==FINAL)
+ or (_givenValue ==INTERNAL)
+ or (_givenValue ==ID)
+ or (_givenValue ==AT)
+ ): // 1827
+ parameter_declaration_list(function)
+ elif ((_givenValue == RPAREN)): // 1831
+ pass // 947
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
+ match(RPAREN)
+ _givenValue = LA(1)
+ if ((_givenValue == COLON)): // 1831
match(COLON)
+ tr=type_reference()
if 0 == inputState.guessing:
- item = MacroStatement(ToLexicalInfo(d), Name: d.getText())
- itemBlock = item.Body
- switchBlock.Add(item)
- _cnt147 as int = 0
- while true:
- if ((tokenSet_38_.member(cast(int, LA(1))))):
- statement(itemBlock)
- else:
- if (_cnt147 >= 1):
- goto _loop147_breakloop
- else:
- raise NoViableAltException(LT(1), getFilename())
- ++_cnt147
- :_loop147_breakloop
- elif ((_givenValue == RBRACE)): // 1831
+ function.ReturnType = tr;
+ elif ((_givenValue == FUNCTION)
+ or (_givenValue ==RBRACE)
+ or (_givenValue ==EOS)
+ or (_givenValue ==AT)
+ ): // 1827
pass // 947
else: // line 1969
raise NoViableAltException(LT(1), getFilename())
- match(RBRACE)
while true:
- if ((LA(1)==EOS) and (tokenSet_32_.member(cast(int, LA(2))))):
+ if ((LA(1)==EOS)):
match(EOS)
else:
- goto _loop149_breakloop
- :_loop149_breakloop
+ goto _loop72_breakloop
+ :_loop72_breakloop
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_32_)
+ recover(ex,tokenSet_37_)
else:
raise
- public def expression_statement(
- b as Block
- ) as void: //throws RecognitionException, TokenStreamException
+ public def identifier() as antlr.IToken : //throws RecognitionException, TokenStreamException
+ token as antlr.IToken
+ name as IToken = null
+ f as IToken = null
+ i as IToken = null
+ e as IToken = null
try: // for error handling
- e=assignment_expression()
- if 0 == inputState.guessing:
- b.Add(ExpressionStatement(e))
+ _givenValue = LA(1)
+ if ((_givenValue == ID)): // 1831
+ name = LT(1)
+ match(ID)
+ if 0 == inputState.guessing:
+ token = name;
+ elif ((_givenValue == FINAL)): // 1831
+ f = LT(1)
+ match(FINAL)
+ if 0 == inputState.guessing:
+ token = f; KeywordCannotBeUsedAsAnIdentifier(token);
+ elif ((_givenValue == INTERNAL)): // 1831
+ i = LT(1)
+ match(INTERNAL)
+ if 0 == inputState.guessing:
+ token = i; KeywordCannotBeUsedAsAnIdentifier(token);
+ elif ((_givenValue == EACH)): // 1831
+ e = LT(1)
+ match(EACH)
+ if 0 == inputState.guessing:
+ token = e;
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_32_)
+ recover(ex,tokenSet_38_)
else:
raise
+ return token
- public def yield_statement(
- b as Block
+ public def parameter_declaration_list(
+ m as INodeWithParameters
) as void: //throws RecognitionException, TokenStreamException
- yt as IToken = null
try: // for error handling
- yt = LT(1)
- match(YIELD)
- if ((tokenSet_13_.member(cast(int, LA(1)))) and (tokenSet_39_.member(cast(int, LA(2))))):
- e=expression()
- elif ((tokenSet_32_.member(cast(int, LA(1)))) and (tokenSet_12_.member(cast(int, LA(2))))): // line 2102
- pass // 947
- else:
- raise NoViableAltException(LT(1), getFilename())
- if 0 == inputState.guessing:
- b.Add(YieldStatement(ToLexicalInfo(yt), Expression: e))
+ parameter_declaration(m)
+ while true:
+ if ((LA(1)==COMMA)):
+ match(COMMA)
+ parameter_declaration(m)
+ else:
+ goto _loop94_breakloop
+ :_loop94_breakloop
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_32_)
+ recover(ex,tokenSet_39_)
else:
raise
- public def return_statement(
- b as Block
+ public def enum_member(
+ container as EnumDefinition
) as void: //throws RecognitionException, TokenStreamException
- ret as IToken = null
try: // for error handling
- ret = LT(1)
- match(RETURN)
- if ((tokenSet_13_.member(cast(int, LA(1)))) and (tokenSet_39_.member(cast(int, LA(2))))):
- e=expression()
- elif ((tokenSet_32_.member(cast(int, LA(1)))) and (tokenSet_12_.member(cast(int, LA(2))))): // line 2102
+ _givenValue = LA(1)
+ if ((_givenValue == AT)): // 1831
+ attributes()
+ elif ((_givenValue == EACH)
+ or (_givenValue ==FINAL)
+ or (_givenValue ==INTERNAL)
+ or (_givenValue ==ID)
+ ): // 1827
pass // 947
- else:
- raise NoViableAltException(LT(1), getFilename())
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
+ name=identifier()
+ _givenValue = LA(1)
+ if ((_givenValue == ASSIGN)): // 1831
+ match(ASSIGN)
+ initializer=integer_literal()
+ elif ((_givenValue == RBRACE)
+ or (_givenValue ==COMMA)
+ ): // 1827
+ pass // 947
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
if 0 == inputState.guessing:
- b.Add(ReturnStatement(ToLexicalInfo(ret), Expression: e))
+ em = EnumMember(ToLexicalInfo(name), Name: name.getText(), Initializer: initializer)
+ FlushAttributes(em)
+ container.Members.Add(em)
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_32_)
+ recover(ex,tokenSet_40_)
else:
raise
- public def break_statement(
- b as Block
- ) as void: //throws RecognitionException, TokenStreamException
+ public def integer_literal() as IntegerLiteralExpression : //throws RecognitionException, TokenStreamException
+ e as IntegerLiteralExpression
- t as IToken = null
+ i as IToken = null
+ l as IToken = null
try: // for error handling
- t = LT(1)
- match(BREAK)
- if 0 == inputState.guessing:
- b.Add(BreakStatement(ToLexicalInfo(t)))
+ _givenValue = LA(1)
+ if ((_givenValue == INT)): // 1831
+ i = LT(1)
+ match(INT)
+ if 0 == inputState.guessing:
+ e = ParseIntegerLiteralExpression(i, i.getText(), false);
+ elif ((_givenValue == LONG)): // 1831
+ l = LT(1)
+ match(LONG)
+ if 0 == inputState.guessing:
+ s = l.getText()
+ e = ParseIntegerLiteralExpression(l, s[:-1], true)
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_32_)
+ recover(ex,tokenSet_20_)
else:
raise
+ return e
- public def continue_statement(
- b as Block
+ public def function_body(
+ method as Method
) as void: //throws RecognitionException, TokenStreamException
- t as IToken = null
try: // for error handling
- t = LT(1)
- match(CONTINUE)
+ match(LPAREN)
+ _givenValue = LA(1)
+ if ((_givenValue == EACH)
+ or (_givenValue ==FINAL)
+ or (_givenValue ==INTERNAL)
+ or (_givenValue ==ID)
+ or (_givenValue ==AT)
+ ): // 1827
+ parameter_declaration_list(method)
+ elif ((_givenValue == RPAREN)): // 1831
+ pass // 947
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
+ match(RPAREN)
+ _givenValue = LA(1)
+ if ((_givenValue == COLON)): // 1831
+ match(COLON)
+ tr=type_reference()
+ if 0 == inputState.guessing:
+ method.ReturnType = tr;
+ elif ((_givenValue == LBRACE)): // 1831
+ pass // 947
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
+ compound_statement(method.Body)
if 0 == inputState.guessing:
- gotoLabel = GetCurrentLoopLabel()
- if gotoLabel is not null:
- // we might be inside a c style for statement
- b.Add(GotoStatement(ToLexicalInfo(t), Label: ReferenceExpression(gotoLabel)))
- else:
- b.Add(ContinueStatement(ToLexicalInfo(t)))
+ method.EndSourceLocation = method.Body.EndSourceLocation
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_32_)
+ recover(ex,tokenSet_33_)
else:
raise
- public def throw_statement(
+ public def compound_statement(
b as Block
) as void: //throws RecognitionException, TokenStreamException
- t as IToken = null
try: // for error handling
- t = LT(1)
- match(THROW)
- if ((tokenSet_13_.member(cast(int, LA(1)))) and (tokenSet_39_.member(cast(int, LA(2))))):
- e=expression()
- elif ((tokenSet_32_.member(cast(int, LA(1)))) and (tokenSet_12_.member(cast(int, LA(2))))): // line 2102
- pass // 947
- else:
- raise NoViableAltException(LT(1), getFilename())
- if 0 == inputState.guessing:
- b.Add(RaiseStatement(ToLexicalInfo(t), Exception: e))
+ block(b)
+ while true:
+ if ((LA(1)==EOS) and (tokenSet_41_.member(cast(int, LA(2))))):
+ match(EOS)
+ else:
+ goto _loop101_breakloop
+ :_loop101_breakloop
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_32_)
+ recover(ex,tokenSet_41_)
else:
raise
- public def member_modifiers() as TypeMemberModifiers : //throws RecognitionException, TokenStreamException
- m as TypeMemberModifiers
+ public def parameter_declaration(
+ m as INodeWithParameters
+ ) as void: //throws RecognitionException, TokenStreamException
- v as IToken = null
- m = TypeMemberModifiers.None
try: // for error handling
- while true:
- _givenValue = LA(1)
- if ((_givenValue == FINAL)): // 1831
- match(FINAL)
- if 0 == inputState.guessing:
- m |= TypeMemberModifiers.Final
- elif ((_givenValue == OVERRIDE)): // 1831
- match(OVERRIDE)
- if 0 == inputState.guessing:
- m |= TypeMemberModifiers.Override
- elif ((_givenValue == PUBLIC)): // 1831
- match(PUBLIC)
- if 0 == inputState.guessing:
- m |= TypeMemberModifiers.Public
- elif ((_givenValue == PRIVATE)): // 1831
- match(PRIVATE)
- if 0 == inputState.guessing:
- m |= TypeMemberModifiers.Private
- elif ((_givenValue == PROTECTED)): // 1831
- match(PROTECTED)
- if 0 == inputState.guessing:
- m |= TypeMemberModifiers.Protected
- elif ((_givenValue == INTERNAL)): // 1831
- match(INTERNAL)
- if 0 == inputState.guessing:
- m |= TypeMemberModifiers.Internal
- elif ((_givenValue == STATIC)): // 1831
- match(STATIC)
- if 0 == inputState.guessing:
- m |= TypeMemberModifiers.Static
- elif ((_givenValue == NEW)): // 1831
- match(NEW)
- if 0 == inputState.guessing:
- m |= TypeMemberModifiers.New
- elif ((_givenValue == VIRTUAL)): // 1831
- v = LT(1)
- match(VIRTUAL)
- if 0 == inputState.guessing:
- VirtualKeywordHasNoEffect(v)
- else: // line 1969
- goto _loop50_breakloop
- :_loop50_breakloop
+ _givenValue = LA(1)
+ if ((_givenValue == AT)): // 1831
+ attributes()
+ elif ((_givenValue == EACH)
+ or (_givenValue ==FINAL)
+ or (_givenValue ==INTERNAL)
+ or (_givenValue ==ID)
+ ): // 1827
+ pass // 947
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
+ id=identifier()
+ _givenValue = LA(1)
+ if ((_givenValue == COLON)): // 1831
+ match(COLON)
+ tr=type_reference()
+ elif ((_givenValue == RPAREN)
+ or (_givenValue ==COMMA)
+ ): // 1827
+ pass // 947
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
+ if 0 == inputState.guessing:
+ parameter = ParameterDeclaration(ToLexicalInfo(id), Name: id.getText(), Type: tr)
+ m.Parameters.Add(parameter)
+ FlushAttributes(parameter)
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_31_)
+ recover(ex,tokenSet_18_)
else:
raise
- return m
- public def type_reference() as TypeReference : //throws RecognitionException, TokenStreamException
- tr as TypeReference
+ public def statement(
+ b as Block
+ ) as void: //throws RecognitionException, TokenStreamException
try: // for error handling
- _givenValue = LA(1)
- if ((_givenValue == ID)): // 1831
- tr=simple_type_reference()
- elif ((_givenValue == FUNCTION)): // 1831
- tr=anonymous_function_type()
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
- if ((LA(1)==LBRACK) and (LA(2)==RBRACK)):
- match(LBRACK)
- match(RBRACK)
- if 0 == inputState.guessing:
- tr = ArrayTypeReference(tr.LexicalInfo, tr);
- elif ((tokenSet_40_.member(cast(int, LA(1)))) and (tokenSet_41_.member(cast(int, LA(2))))): // line 2102
- pass // 947
+ synPredMatched107 as bool = false
+ if ((tokenSet_42_.member(cast(int, LA(1)))) and (tokenSet_16_.member(cast(int, LA(2))))):
+ _m107 as int = mark()
+ synPredMatched107 = true
+ ++inputState.guessing
+ try:
+ macro_application_test()
+ except x as RecognitionException:
+ synPredMatched107 = false
+ rewind(_m107)
+ --inputState.guessing
+ if synPredMatched107:
+ macro_application_block(b)
+ elif ((tokenSet_43_.member(cast(int, LA(1)))) and (tokenSet_14_.member(cast(int, LA(2))))): // line 2102
+ builtin_statement(b)
+ elif ((LA(1)==EOS)): // line 2102
+ _cnt109 as int = 0
+ while true:
+ if ((LA(1)==EOS) and (tokenSet_15_.member(cast(int, LA(2))))):
+ match(EOS)
+ else:
+ if (_cnt109 >= 1):
+ goto _loop109_breakloop
+ else:
+ raise NoViableAltException(LT(1), getFilename())
+ ++_cnt109
+ :_loop109_breakloop
else:
raise NoViableAltException(LT(1), getFilename())
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_40_)
+ recover(ex,tokenSet_15_)
else:
raise
- return tr
- public def type_reference_list(
- typeReferences as TypeReferenceCollection
+ public def block(
+ b as Block
) as void: //throws RecognitionException, TokenStreamException
+ rbrace as IToken = null
try: // for error handling
- tr=type_reference()
- if 0 == inputState.guessing:
- typeReferences.Add(tr)
+ match(LBRACE)
while true:
- if ((LA(1)==COMMA)):
- match(COMMA)
- tr=type_reference()
- if 0 == inputState.guessing:
- typeReferences.Add(tr)
+ if ((tokenSet_2_.member(cast(int, LA(1))))):
+ compound_or_single_stmt(b)
else:
- goto _loop179_breakloop
- :_loop179_breakloop
+ goto _loop104_breakloop
+ :_loop104_breakloop
+ rbrace = LT(1)
+ match(RBRACE)
+ if 0 == inputState.guessing:
+ SetEndSourceLocation(b, rbrace)
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_42_)
+ recover(ex,tokenSet_20_)
else:
raise
- public def function_member(
- cd as ClassDefinition
- ) as TypeMember : //throws RecognitionException, TokenStreamException
- member as TypeMember
+ public def macro_application_test() as void: //throws RecognitionException, TokenStreamException
- getter as IToken = null
- setter as IToken = null
try: // for error handling
- match(FUNCTION)
- _givenValue = LA(1)
- if ((_givenValue == GET)): // 1831
- getter = LT(1)
- match(GET)
- elif ((_givenValue == SET)): // 1831
- setter = LT(1)
- match(SET)
- elif ((_givenValue == FINAL)
- or (_givenValue ==ID)
- ): // 1827
- pass // 947
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
- memberName=member_name()
- if 0 == inputState.guessing:
- method as Method
- if memberName.getText() == cd.Name:
- member = method = Constructor(ToLexicalInfo(memberName))
- else:
- member = method = Method(ToLexicalInfo(memberName), Name: memberName.getText())
- if getter is not null or setter is not null:
- p = cd.Members[memberName.getText()] as Property
- if p is null:
- p = Property(ToLexicalInfo(memberName), Name: memberName.getText())
- cd.Members.Add(p)
- if getter is not null:
- p.Getter = method
- else:
- p.Setter = method
- FlushAttributes(p)
- else:
- cd.Members.Add(method)
- FlushAttributes(method)
- function_body(method)
- if 0 == inputState.guessing:
- // TODO: move this error checking to a compiler step
- // as well as properly checking the type of the accessors
- // against the type of the property
- if setter is not null:
- if method.Parameters.Count != 1 or method.Parameters[0].Name != "value":
- ReportError(UnityScriptCompilerErrors.InvalidPropertySetter(ToLexicalInfo(memberName)))
- method.Parameters.Clear()
- if getter is not null:
- if method.Parameters.Count > 0:
- ReportError(UnityScriptCompilerErrors.InvalidPropertySetter(ToLexicalInfo(memberName)))
+ if ((tokenSet_42_.member(cast(int, LA(1)))) and (LA(2)==LBRACE)):
+ member()
+ match(LBRACE)
+ elif ((tokenSet_42_.member(cast(int, LA(1)))) and (tokenSet_16_.member(cast(int, LA(2))))): // line 2102
+ member()
+ expression_list(null)
+ match(LBRACE)
+ else:
+ raise NoViableAltException(LT(1), getFilename())
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_43_)
+ recover(ex,tokenSet_4_)
else:
raise
- return member
- public def interface_member(
- parent as TypeDefinition
+ public def macro_application_block(
+ container as Block
) as void: //throws RecognitionException, TokenStreamException
- name as IToken = null
+ m = MacroStatement()
+ args = m.Arguments
+ b = m.Body
try: // for error handling
- match(FUNCTION)
- name = LT(1)
- match(ID)
+ macroName=member()
+ synPredMatched148 as bool = false
+ if ((LA(1)==LBRACE) and (tokenSet_13_.member(cast(int, LA(2))))):
+ _m148 as int = mark()
+ synPredMatched148 = true
+ ++inputState.guessing
+ try:
+ match(LBRACE)
+ except x as RecognitionException:
+ synPredMatched148 = false
+ rewind(_m148)
+ --inputState.guessing
+ if synPredMatched148:
+ compound_statement(b)
+ elif ((tokenSet_16_.member(cast(int, LA(1)))) and (tokenSet_44_.member(cast(int, LA(2))))): // line 2102
+ expression_list(args)
+ compound_statement(b)
+ else:
+ raise NoViableAltException(LT(1), getFilename())
if 0 == inputState.guessing:
- method = Method(ToLexicalInfo(name), Name: name.getText())
- FlushAttributes(method)
- parent.Members.Add(method)
- match(LPAREN)
- _givenValue = LA(1)
- if ((_givenValue == ID)): // 1831
- parameter_declaration_list(method)
- elif ((_givenValue == RPAREN)): // 1831
- pass // 947
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
- match(RPAREN)
+ m.LexicalInfo = ToLexicalInfo(macroName)
+ m.Name = macroName.getText()
+ container.Add(m)
+ except ex as RecognitionException:
+ if (0 == inputState.guessing):
+ reportError(ex)
+ recover(ex,tokenSet_15_)
+ else:
+ raise
+
+ public def builtin_statement(
+ b as Block
+ ) as void: //throws RecognitionException, TokenStreamException
+
+
+ try: // for error handling
_givenValue = LA(1)
- if ((_givenValue == COLON)): // 1831
- match(COLON)
- tr=type_reference()
- if 0 == inputState.guessing:
- method.ReturnType = tr;
- elif ((_givenValue == FUNCTION)
- or (_givenValue ==RBRACE)
- or (_givenValue ==EOS)
- or (_givenValue ==AT)
+ if ((_givenValue == DO)
+ or (_givenValue ==FOR)
+ or (_givenValue ==IF)
+ or (_givenValue ==TRY)
+ or (_givenValue ==WHILE)
+ or (_givenValue ==SWITCH)
): // 1827
- pass // 947
+ _givenValue = LA(1)
+ if ((_givenValue == DO)): // 1831
+ do_while_statement(b)
+ elif ((_givenValue == WHILE)): // 1831
+ while_statement(b)
+ elif ((_givenValue == FOR)): // 1831
+ for_statement(b)
+ elif ((_givenValue == IF)): // 1831
+ if_statement(b)
+ elif ((_givenValue == TRY)): // 1831
+ try_statement(b)
+ elif ((_givenValue == SWITCH)): // 1831
+ switch_statement(b)
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
+ elif ((_givenValue == BREAK)
+ or (_givenValue ==CONTINUE)
+ or (_givenValue ==EACH)
+ or (_givenValue ==FALSE)
+ or (_givenValue ==FUNCTION)
+ or (_givenValue ==NEW)
+ or (_givenValue ==NULL)
+ or (_givenValue ==RETURN)
+ or (_givenValue ==SUPER)
+ or (_givenValue ==THIS)
+ or (_givenValue ==THROW)
+ or (_givenValue ==TRUE)
+ or (_givenValue ==TYPEOF)
+ or (_givenValue ==VAR)
+ or (_givenValue ==YIELD)
+ or (_givenValue ==ID)
+ or (_givenValue ==DOUBLE_QUOTED_STRING)
+ or (_givenValue ==LBRACE)
+ or (_givenValue ==LPAREN)
+ or (_givenValue ==LBRACK)
+ or (_givenValue ==INCREMENT)
+ or (_givenValue ==DECREMENT)
+ or (_givenValue ==SUBTRACT)
+ or (_givenValue ==BITWISE_NOT)
+ or (_givenValue ==LOGICAL_NOT)
+ or (_givenValue ==RE_LITERAL)
+ or (_givenValue ==DOUBLE)
+ or (_givenValue ==INT)
+ or (_givenValue ==LONG)
+ or (_givenValue ==SINGLE_QUOTED_STRING)
+ ): // 1827
+ _givenValue = LA(1)
+ if ((_givenValue == EACH)
+ or (_givenValue ==FALSE)
+ or (_givenValue ==FUNCTION)
+ or (_givenValue ==NEW)
+ or (_givenValue ==NULL)
+ or (_givenValue ==SUPER)
+ or (_givenValue ==THIS)
+ or (_givenValue ==TRUE)
+ or (_givenValue ==TYPEOF)
+ or (_givenValue ==ID)
+ or (_givenValue ==DOUBLE_QUOTED_STRING)
+ or (_givenValue ==LBRACE)
+ or (_givenValue ==LPAREN)
+ or (_givenValue ==LBRACK)
+ or (_givenValue ==INCREMENT)
+ or (_givenValue ==DECREMENT)
+ or (_givenValue ==SUBTRACT)
+ or (_givenValue ==BITWISE_NOT)
+ or (_givenValue ==LOGICAL_NOT)
+ or (_givenValue ==RE_LITERAL)
+ or (_givenValue ==DOUBLE)
+ or (_givenValue ==INT)
+ or (_givenValue ==LONG)
+ or (_givenValue ==SINGLE_QUOTED_STRING)
+ ): // 1827
+ expression_statement(b)
+ elif ((_givenValue == YIELD)): // 1831
+ yield_statement(b)
+ elif ((_givenValue == RETURN)): // 1831
+ return_statement(b)
+ elif ((_givenValue == BREAK)): // 1831
+ break_statement(b)
+ elif ((_givenValue == CONTINUE)): // 1831
+ continue_statement(b)
+ elif ((_givenValue == THROW)): // 1831
+ throw_statement(b)
+ elif ((_givenValue == VAR)): // 1831
+ declaration_statement(b)
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
+ eos()
else: // line 1969
raise NoViableAltException(LT(1), getFilename())
- while true:
- if ((LA(1)==EOS)):
- match(EOS)
- else:
- goto _loop73_breakloop
- :_loop73_breakloop
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_44_)
+ recover(ex,tokenSet_15_)
else:
raise
- public def parameter_declaration_list(
- m as INodeWithParameters
+ public def do_while_statement(
+ container as Block
) as void: //throws RecognitionException, TokenStreamException
+ d as IToken = null
+ w as IToken = null
try: // for error handling
- parameter_declaration(m)
- while true:
- if ((LA(1)==COMMA)):
- match(COMMA)
- parameter_declaration(m)
- else:
- goto _loop95_breakloop
- :_loop95_breakloop
+ d = LT(1)
+ match(DO)
+ if 0 == inputState.guessing:
+ ws = WhileStatement(ToLexicalInfo(d), Condition: BoolLiteralExpression(true))
+ b = ws.Block
+ container.Add(ws)
+ EnterLoop(ws)
+ block(b)
+ w = LT(1)
+ match(WHILE)
+ e=paren_expression()
+ eos()
+ if 0 == inputState.guessing:
+ b.Add(BreakStatement(ToLexicalInfo(w), Modifier: StatementModifier(StatementModifierType.Unless, e)))
+ LeaveLoop(ws)
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_45_)
+ recover(ex,tokenSet_15_)
else:
raise
- public def enum_member(
- container as EnumDefinition
+ public def while_statement(
+ container as Block
) as void: //throws RecognitionException, TokenStreamException
- name as IToken = null
+ w as IToken = null
try: // for error handling
- name = LT(1)
- match(ID)
- _givenValue = LA(1)
- if ((_givenValue == ASSIGN)): // 1831
- match(ASSIGN)
- initializer=integer_literal()
- elif ((_givenValue == RBRACE)
- or (_givenValue ==COMMA)
- ): // 1827
- pass // 947
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
+ w = LT(1)
+ match(WHILE)
+ e=paren_expression()
if 0 == inputState.guessing:
- em = EnumMember(ToLexicalInfo(name),
- Name: name.getText(),
- Initializer: initializer)
- container.Members.Add(em)
+ ws = WhileStatement(ToLexicalInfo(w), Condition: e)
+ b = ws.Block
+ container.Add(ws)
+ EnterLoop(ws)
+ compound_or_single_stmt(b)
+ if 0 == inputState.guessing:
+ LeaveLoop(ws)
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_46_)
+ recover(ex,tokenSet_15_)
else:
raise
- public def member_name() as antlr.IToken : //throws RecognitionException, TokenStreamException
- token as antlr.IToken
+ public def for_statement(
+ container as Block
+ ) as void: //throws RecognitionException, TokenStreamException
- name as IToken = null
f as IToken = null
try: // for error handling
+ f = LT(1)
+ match(FOR)
_givenValue = LA(1)
- if ((_givenValue == ID)): // 1831
- name = LT(1)
- match(ID)
- if 0 == inputState.guessing:
- token = name;
- elif ((_givenValue == FINAL)): // 1831
- f = LT(1)
- match(FINAL)
- if 0 == inputState.guessing:
- token = f; KeywordCannotBeUsedAsAnIdentifier(token);
+ if ((_givenValue == EACH)): // 1831
+ match(EACH)
+ match(LPAREN)
+ stmt=for_in(container)
+ elif ((_givenValue == LPAREN)): // 1831
+ match(LPAREN)
+ synPredMatched132 as bool = false
+ if ((tokenSet_45_.member(cast(int, LA(1)))) and (tokenSet_46_.member(cast(int, LA(2))))):
+ _m132 as int = mark()
+ synPredMatched132 = true
+ ++inputState.guessing
+ try:
+ _givenValue = LA(1)
+ if ((_givenValue == EACH)
+ or (_givenValue ==FINAL)
+ or (_givenValue ==INTERNAL)
+ or (_givenValue ==ID)
+ ): // 1827
+ identifier()
+ elif ((_givenValue == VAR)): // 1831
+ declaration()
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
+ match(IN)
+ except x as RecognitionException:
+ synPredMatched132 = false
+ rewind(_m132)
+ --inputState.guessing
+ if synPredMatched132:
+ stmt=for_in(container)
+ elif ((tokenSet_47_.member(cast(int, LA(1)))) and (tokenSet_48_.member(cast(int, LA(2))))): // line 2102
+ stmt=for_c(container)
+ else:
+ raise NoViableAltException(LT(1), getFilename())
else: // line 1969
raise NoViableAltException(LT(1), getFilename())
+ if 0 == inputState.guessing:
+ stmt.LexicalInfo = ToLexicalInfo(f) if stmt is not null
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_47_)
+ recover(ex,tokenSet_15_)
else:
raise
- return token
- public def expression() as Expression : //throws RecognitionException, TokenStreamException
- e as Expression
+ public def if_statement(
+ container as Block
+ ) as void: //throws RecognitionException, TokenStreamException
+ it as IToken = null
+ et as IToken = null
try: // for error handling
- e=conditional_expression()
+ it = LT(1)
+ match(IF)
+ e=paren_expression()
+ if 0 == inputState.guessing:
+ s = IfStatement(ToLexicalInfo(it), Condition: e)
+ b = s.TrueBlock = Block()
+ container.Add(s)
+ compound_or_single_stmt(b)
+ if ((LA(1)==ELSE) and (tokenSet_2_.member(cast(int, LA(2))))):
+ et = LT(1)
+ match(ELSE)
+ if 0 == inputState.guessing:
+ b = s.FalseBlock = Block(ToLexicalInfo(et))
+ compound_or_single_stmt(b)
+ elif ((tokenSet_15_.member(cast(int, LA(1)))) and (tokenSet_20_.member(cast(int, LA(2))))): // line 2102
+ pass // 947
+ else:
+ raise NoViableAltException(LT(1), getFilename())
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_12_)
+ recover(ex,tokenSet_15_)
else:
raise
- return e
- public def function_body(
- method as Method
+ public def try_statement(
+ container as Block
) as void: //throws RecognitionException, TokenStreamException
+ tt as IToken = null
+ ct as IToken = null
+ id as IToken = null
try: // for error handling
- match(LPAREN)
- _givenValue = LA(1)
- if ((_givenValue == ID)): // 1831
- parameter_declaration_list(method)
- elif ((_givenValue == RPAREN)): // 1831
+ tt = LT(1)
+ match(TRY)
+ if 0 == inputState.guessing:
+ s = TryStatement(ToLexicalInfo(tt))
+ b = s.ProtectedBlock
+ container.Add(s)
+ compound_or_single_stmt(b)
+ while true:
+ if ((LA(1)==CATCH) and (LA(2)==LPAREN)):
+ ct = LT(1)
+ match(CATCH)
+ match(LPAREN)
+ id = LT(1)
+ match(ID)
+ _givenValue = LA(1)
+ if ((_givenValue == COLON)): // 1831
+ match(COLON)
+ tr=type_reference()
+ elif ((_givenValue == RPAREN)): // 1831
+ pass // 947
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
+ match(RPAREN)
+ if 0 == inputState.guessing:
+ tr = SimpleTypeReference(ToLexicalInfo(id), "System.Exception") if tr is null
+ handler = ExceptionHandler(
+ ToLexicalInfo(ct),
+ Declaration: Declaration(ToLexicalInfo(id), Name: id.getText(), Type: tr))
+ s.ExceptionHandlers.Add(handler)
+ b = handler.Block
+ tr = null
+ compound_or_single_stmt(b)
+ else:
+ goto _loop167_breakloop
+ :_loop167_breakloop
+ if ((LA(1)==FINALLY) and (tokenSet_2_.member(cast(int, LA(2))))):
+ finally_block(s)
+ elif ((tokenSet_15_.member(cast(int, LA(1)))) and (tokenSet_20_.member(cast(int, LA(2))))): // line 2102
pass // 947
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
- match(RPAREN)
+ else:
+ raise NoViableAltException(LT(1), getFilename())
+ except ex as RecognitionException:
+ if (0 == inputState.guessing):
+ reportError(ex)
+ recover(ex,tokenSet_15_)
+ else:
+ raise
+
+ public def switch_statement(
+ container as Block
+ ) as void: //throws RecognitionException, TokenStreamException
+
+ s as IToken = null
+ c as IToken = null
+ fallthrough as IToken = null
+ d as IToken = null
+
+ try: // for error handling
+ s = LT(1)
+ match(SWITCH)
+ e=paren_expression()
+ if 0 == inputState.guessing:
+ switchMacro = MacroStatement(ToLexicalInfo(s), Name: MacroName(s.getText()))
+ switchMacro.Arguments.Add(e)
+ switchBlock = switchMacro.Body
+ container.Add(switchMacro)
+ match(LBRACE)
+ while true:
+ if ((LA(1)==CASE)):
+ c = LT(1)
+ match(CASE)
+ e=expression()
+ match(COLON)
+ if 0 == inputState.guessing:
+ item = MacroStatement(ToLexicalInfo(c), Name: c.getText())
+ item.Arguments.Add(e)
+ itemBlock = item.Body
+ switchBlock.Add(item)
+ while true:
+ if ((LA(1)==CASE)):
+ fallthrough = LT(1)
+ match(CASE)
+ e=expression()
+ match(COLON)
+ if 0 == inputState.guessing:
+ item.Arguments.Add(e);
+ else:
+ goto _loop155_breakloop
+ :_loop155_breakloop
+ _cnt157 as int = 0
+ while true:
+ if ((tokenSet_2_.member(cast(int, LA(1))))):
+ statement(itemBlock)
+ else:
+ if (_cnt157 >= 1):
+ goto _loop157_breakloop
+ else:
+ raise NoViableAltException(LT(1), getFilename())
+ ++_cnt157
+ :_loop157_breakloop
+ else:
+ goto _loop158_breakloop
+ :_loop158_breakloop
_givenValue = LA(1)
- if ((_givenValue == COLON)): // 1831
+ if ((_givenValue == DEFAULT)): // 1831
+ d = LT(1)
+ match(DEFAULT)
match(COLON)
- tr=type_reference()
if 0 == inputState.guessing:
- method.ReturnType = tr;
- elif ((_givenValue == LBRACE)): // 1831
+ item = MacroStatement(ToLexicalInfo(d), Name: d.getText())
+ itemBlock = item.Body
+ switchBlock.Add(item)
+ _cnt161 as int = 0
+ while true:
+ if ((tokenSet_2_.member(cast(int, LA(1))))):
+ statement(itemBlock)
+ else:
+ if (_cnt161 >= 1):
+ goto _loop161_breakloop
+ else:
+ raise NoViableAltException(LT(1), getFilename())
+ ++_cnt161
+ :_loop161_breakloop
+ elif ((_givenValue == RBRACE)): // 1831
pass // 947
else: // line 1969
raise NoViableAltException(LT(1), getFilename())
- compound_statement(method.Body)
- if 0 == inputState.guessing:
- method.EndSourceLocation = method.Body.EndSourceLocation
+ match(RBRACE)
+ while true:
+ if ((LA(1)==EOS) and (tokenSet_15_.member(cast(int, LA(2))))):
+ match(EOS)
+ else:
+ goto _loop163_breakloop
+ :_loop163_breakloop
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_35_)
+ recover(ex,tokenSet_15_)
else:
raise
- public def compound_statement(
+ public def expression_statement(
b as Block
) as void: //throws RecognitionException, TokenStreamException
try: // for error handling
- block(b)
- while true:
- if ((LA(1)==EOS) and (tokenSet_48_.member(cast(int, LA(2))))):
- match(EOS)
- else:
- goto _loop101_breakloop
- :_loop101_breakloop
+ e=assignment_expression()
+ if 0 == inputState.guessing:
+ b.Add(ExpressionStatement(e))
+ except ex as RecognitionException:
+ if (0 == inputState.guessing):
+ reportError(ex)
+ recover(ex,tokenSet_15_)
+ else:
+ raise
+
+ public def yield_statement(
+ b as Block
+ ) as void: //throws RecognitionException, TokenStreamException
+
+ yt as IToken = null
+
+ try: // for error handling
+ yt = LT(1)
+ match(YIELD)
+ if ((tokenSet_16_.member(cast(int, LA(1)))) and (tokenSet_49_.member(cast(int, LA(2))))):
+ e=expression()
+ elif ((tokenSet_15_.member(cast(int, LA(1)))) and (tokenSet_20_.member(cast(int, LA(2))))): // line 2102
+ pass // 947
+ else:
+ raise NoViableAltException(LT(1), getFilename())
+ if 0 == inputState.guessing:
+ b.Add(YieldStatement(ToLexicalInfo(yt), Expression: e))
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_48_)
+ recover(ex,tokenSet_15_)
else:
raise
- public def parameter_declaration(
- m as INodeWithParameters
+ public def return_statement(
+ b as Block
) as void: //throws RecognitionException, TokenStreamException
- id as IToken = null
+ ret as IToken = null
try: // for error handling
- id = LT(1)
- match(ID)
- _givenValue = LA(1)
- if ((_givenValue == COLON)): // 1831
- match(COLON)
- tr=type_reference()
- elif ((_givenValue == RPAREN)
- or (_givenValue ==COMMA)
- ): // 1827
+ ret = LT(1)
+ match(RETURN)
+ if ((tokenSet_16_.member(cast(int, LA(1)))) and (tokenSet_49_.member(cast(int, LA(2))))):
+ e=expression()
+ elif ((tokenSet_15_.member(cast(int, LA(1)))) and (tokenSet_20_.member(cast(int, LA(2))))): // line 2102
pass // 947
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
+ else:
+ raise NoViableAltException(LT(1), getFilename())
if 0 == inputState.guessing:
- parameter = ParameterDeclaration(ToLexicalInfo(id), Name: id.getText(), Type: tr)
- m.Parameters.Add(parameter)
+ b.Add(ReturnStatement(ToLexicalInfo(ret), Expression: e))
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_11_)
+ recover(ex,tokenSet_15_)
else:
raise
- public def compound_or_single_stmt(
+ public def break_statement(
b as Block
) as void: //throws RecognitionException, TokenStreamException
+ t as IToken = null
try: // for error handling
- if ((LA(1)==LBRACE) and (tokenSet_49_.member(cast(int, LA(2))))):
- compound_statement(b)
- elif ((tokenSet_38_.member(cast(int, LA(1)))) and (tokenSet_50_.member(cast(int, LA(2))))): // line 2102
- statement(b)
- else:
- raise NoViableAltException(LT(1), getFilename())
+ t = LT(1)
+ match(BREAK)
+ if 0 == inputState.guessing:
+ b.Add(BreakStatement(ToLexicalInfo(t)))
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_32_)
+ recover(ex,tokenSet_15_)
else:
raise
- public def statement(
+ public def continue_statement(
b as Block
) as void: //throws RecognitionException, TokenStreamException
+ t as IToken = null
try: // for error handling
- _givenValue = LA(1)
- if ((_givenValue == FINALLY)
- or (_givenValue ==FOR)
- or (_givenValue ==IF)
- or (_givenValue ==TRY)
- or (_givenValue ==WHILE)
- or (_givenValue ==SWITCH)
- ): // 1827
- _givenValue = LA(1)
- if ((_givenValue == WHILE)): // 1831
- while_statement(b)
- elif ((_givenValue == FOR)): // 1831
- for_statement(b)
- elif ((_givenValue == IF)): // 1831
- if_statement(b)
- elif ((_givenValue == FINALLY)
- or (_givenValue ==TRY)
- ): // 1827
- try_statement(b)
- elif ((_givenValue == SWITCH)): // 1831
- switch_statement(b)
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
- elif ((_givenValue == BREAK)
- or (_givenValue ==CONTINUE)
- or (_givenValue ==FALSE)
- or (_givenValue ==FUNCTION)
- or (_givenValue ==NEW)
- or (_givenValue ==NOT)
- or (_givenValue ==NULL)
- or (_givenValue ==RETURN)
- or (_givenValue ==SUPER)
- or (_givenValue ==THIS)
- or (_givenValue ==THROW)
- or (_givenValue ==TRUE)
- or (_givenValue ==TYPEOF)
- or (_givenValue ==VAR)
- or (_givenValue ==YIELD)
- or (_givenValue ==ID)
- or (_givenValue ==DOUBLE_QUOTED_STRING)
- or (_givenValue ==LBRACE)
- or (_givenValue ==LPAREN)
- or (_givenValue ==LBRACK)
- or (_givenValue ==INCREMENT)
- or (_givenValue ==DECREMENT)
- or (_givenValue ==SUBTRACT)
- or (_givenValue ==ONES_COMPLEMENT)
- or (_givenValue ==RE_LITERAL)
- or (_givenValue ==DOUBLE)
- or (_givenValue ==INT)
- or (_givenValue ==LONG)
- ): // 1827
- _givenValue = LA(1)
- if ((_givenValue == FALSE)
- or (_givenValue ==FUNCTION)
- or (_givenValue ==NEW)
- or (_givenValue ==NOT)
- or (_givenValue ==NULL)
- or (_givenValue ==SUPER)
- or (_givenValue ==THIS)
- or (_givenValue ==TRUE)
- or (_givenValue ==TYPEOF)
- or (_givenValue ==ID)
- or (_givenValue ==DOUBLE_QUOTED_STRING)
- or (_givenValue ==LBRACE)
- or (_givenValue ==LPAREN)
- or (_givenValue ==LBRACK)
- or (_givenValue ==INCREMENT)
- or (_givenValue ==DECREMENT)
- or (_givenValue ==SUBTRACT)
- or (_givenValue ==ONES_COMPLEMENT)
- or (_givenValue ==RE_LITERAL)
- or (_givenValue ==DOUBLE)
- or (_givenValue ==INT)
- or (_givenValue ==LONG)
- ): // 1827
- expression_statement(b)
- elif ((_givenValue == YIELD)): // 1831
- yield_statement(b)
- elif ((_givenValue == RETURN)): // 1831
- return_statement(b)
- elif ((_givenValue == BREAK)): // 1831
- break_statement(b)
- elif ((_givenValue == CONTINUE)): // 1831
- continue_statement(b)
- elif ((_givenValue == THROW)): // 1831
- throw_statement(b)
- elif ((_givenValue == VAR)): // 1831
- declaration_statement(b)
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
- eos()
- elif ((_givenValue == EOS)): // 1831
- _cnt111 as int = 0
- while true:
- if ((LA(1)==EOS) and (tokenSet_32_.member(cast(int, LA(2))))):
- match(EOS)
- else:
- if (_cnt111 >= 1):
- goto _loop111_breakloop
- else:
- raise NoViableAltException(LT(1), getFilename())
- ++_cnt111
- :_loop111_breakloop
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
+ t = LT(1)
+ match(CONTINUE)
+ if 0 == inputState.guessing:
+ gotoLabel = GetCurrentLoopLabel()
+ if gotoLabel is not null:
+ // we might be inside a c style for statement
+ b.Add(GotoStatement(ToLexicalInfo(t), Label: ReferenceExpression(gotoLabel)))
+ else:
+ b.Add(ContinueStatement(ToLexicalInfo(t)))
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_32_)
+ recover(ex,tokenSet_15_)
else:
raise
- public def block(
+ public def throw_statement(
b as Block
) as void: //throws RecognitionException, TokenStreamException
- rbrace as IToken = null
+ t as IToken = null
try: // for error handling
- match(LBRACE)
- while true:
- if ((tokenSet_38_.member(cast(int, LA(1))))):
- statement(b)
- else:
- goto _loop104_breakloop
- :_loop104_breakloop
- rbrace = LT(1)
- match(RBRACE)
+ t = LT(1)
+ match(THROW)
+ if ((tokenSet_16_.member(cast(int, LA(1)))) and (tokenSet_49_.member(cast(int, LA(2))))):
+ e=expression()
+ elif ((tokenSet_15_.member(cast(int, LA(1)))) and (tokenSet_20_.member(cast(int, LA(2))))): // line 2102
+ pass // 947
+ else:
+ raise NoViableAltException(LT(1), getFilename())
if 0 == inputState.guessing:
- SetEndSourceLocation(b, rbrace)
+ b.Add(RaiseStatement(ToLexicalInfo(t), Exception: e))
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_12_)
+ recover(ex,tokenSet_15_)
else:
raise
public def declaration() as Declaration : //throws RecognitionException, TokenStreamException
d as Declaration
- id as IToken = null
try: // for error handling
match(VAR)
- id = LT(1)
- match(ID)
+ id=identifier()
_givenValue = LA(1)
if ((_givenValue == COLON)): // 1831
match(COLON)
@@ -2526,18 +2439,20 @@ class UnityScriptParser(antlr.LLkParser):
or (_givenValue ==CATCH)
or (_givenValue ==CLASS)
or (_givenValue ==CONTINUE)
+ or (_givenValue ==DO)
or (_givenValue ==ELSE)
+ or (_givenValue ==EACH)
or (_givenValue ==ENUM)
or (_givenValue ==FALSE)
or (_givenValue ==FINAL)
or (_givenValue ==FINALLY)
or (_givenValue ==FOR)
or (_givenValue ==FUNCTION)
+ or (_givenValue ==GET)
or (_givenValue ==IF)
or (_givenValue ==IN)
or (_givenValue ==INTERFACE)
or (_givenValue ==NEW)
- or (_givenValue ==NOT)
or (_givenValue ==NULL)
or (_givenValue ==RETURN)
or (_givenValue ==PUBLIC)
@@ -2545,6 +2460,7 @@ class UnityScriptParser(antlr.LLkParser):
or (_givenValue ==INTERNAL)
or (_givenValue ==PARTIAL)
or (_givenValue ==PRIVATE)
+ or (_givenValue ==SET)
or (_givenValue ==STATIC)
or (_givenValue ==SUPER)
or (_givenValue ==THIS)
@@ -2570,25 +2486,24 @@ class UnityScriptParser(antlr.LLkParser):
or (_givenValue ==INCREMENT)
or (_givenValue ==DECREMENT)
or (_givenValue ==SUBTRACT)
- or (_givenValue ==ONES_COMPLEMENT)
+ or (_givenValue ==BITWISE_NOT)
or (_givenValue ==AT)
- or (_givenValue ==SCRIPT_ATTRIBUTE_MARKER)
+ or (_givenValue ==LOGICAL_NOT)
or (_givenValue ==RE_LITERAL)
or (_givenValue ==DOUBLE)
or (_givenValue ==INT)
or (_givenValue ==LONG)
+ or (_givenValue ==SINGLE_QUOTED_STRING)
): // 1827
pass // 947
else: // line 1969
raise NoViableAltException(LT(1), getFilename())
if 0 == inputState.guessing:
- d = Declaration(ToLexicalInfo(id))
- d.Name = id.getText()
- d.Type = tr
+ d = Declaration(ToLexicalInfo(id), Name: id.getText(), Type: tr)
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_51_)
+ recover(ex,tokenSet_50_)
else:
raise
return d
@@ -2686,17 +2601,19 @@ class UnityScriptParser(antlr.LLkParser):
or (_givenValue ==CATCH)
or (_givenValue ==CLASS)
or (_givenValue ==CONTINUE)
+ or (_givenValue ==DO)
or (_givenValue ==ELSE)
+ or (_givenValue ==EACH)
or (_givenValue ==ENUM)
or (_givenValue ==FALSE)
or (_givenValue ==FINAL)
or (_givenValue ==FINALLY)
or (_givenValue ==FOR)
or (_givenValue ==FUNCTION)
+ or (_givenValue ==GET)
or (_givenValue ==IF)
or (_givenValue ==INTERFACE)
or (_givenValue ==NEW)
- or (_givenValue ==NOT)
or (_givenValue ==NULL)
or (_givenValue ==RETURN)
or (_givenValue ==PUBLIC)
@@ -2704,6 +2621,7 @@ class UnityScriptParser(antlr.LLkParser):
or (_givenValue ==INTERNAL)
or (_givenValue ==PARTIAL)
or (_givenValue ==PRIVATE)
+ or (_givenValue ==SET)
or (_givenValue ==STATIC)
or (_givenValue ==SUPER)
or (_givenValue ==THIS)
@@ -2729,13 +2647,14 @@ class UnityScriptParser(antlr.LLkParser):
or (_givenValue ==INCREMENT)
or (_givenValue ==DECREMENT)
or (_givenValue ==SUBTRACT)
- or (_givenValue ==ONES_COMPLEMENT)
+ or (_givenValue ==BITWISE_NOT)
or (_givenValue ==AT)
- or (_givenValue ==SCRIPT_ATTRIBUTE_MARKER)
+ or (_givenValue ==LOGICAL_NOT)
or (_givenValue ==RE_LITERAL)
or (_givenValue ==DOUBLE)
or (_givenValue ==INT)
or (_givenValue ==LONG)
+ or (_givenValue ==SINGLE_QUOTED_STRING)
): // 1827
pass // 947
else: // line 1969
@@ -2743,7 +2662,7 @@ class UnityScriptParser(antlr.LLkParser):
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_52_)
+ recover(ex,tokenSet_51_)
else:
raise
return e
@@ -2753,17 +2672,21 @@ class UnityScriptParser(antlr.LLkParser):
) as Statement : //throws RecognitionException, TokenStreamException
stmt as Statement
- id as IToken = null
try: // for error handling
_givenValue = LA(1)
- if ((_givenValue == ID)): // 1831
- id = LT(1)
- match(ID)
+ if ((_givenValue == EACH)
+ or (_givenValue ==FINAL)
+ or (_givenValue ==INTERNAL)
+ or (_givenValue ==ID)
+ ): // 1827
+ id=identifier()
if 0 == inputState.guessing:
- d = Declaration(ToLexicalInfo(id), Name: id.getText())
+ d = Declaration(ToLexicalInfo(id), Name: id.getText())
elif ((_givenValue == VAR)): // 1831
d=declaration()
+ if 0 == inputState.guessing:
+ DeclarationAnnotations.ForceNewVariable(d)
else: // line 1969
raise NoViableAltException(LT(1), getFilename())
match(IN)
@@ -2782,7 +2705,7 @@ class UnityScriptParser(antlr.LLkParser):
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_32_)
+ recover(ex,tokenSet_15_)
else:
raise
return stmt
@@ -2800,10 +2723,10 @@ class UnityScriptParser(antlr.LLkParser):
if 0 == inputState.guessing:
stmt = container.Statements[-1] as DeclarationStatement
stmt.Annotate("PrivateScope") if stmt is not null
- elif ((_givenValue == FALSE)
+ elif ((_givenValue == EACH)
+ or (_givenValue ==FALSE)
or (_givenValue ==FUNCTION)
or (_givenValue ==NEW)
- or (_givenValue ==NOT)
or (_givenValue ==NULL)
or (_givenValue ==SUPER)
or (_givenValue ==THIS)
@@ -2817,11 +2740,13 @@ class UnityScriptParser(antlr.LLkParser):
or (_givenValue ==INCREMENT)
or (_givenValue ==DECREMENT)
or (_givenValue ==SUBTRACT)
- or (_givenValue ==ONES_COMPLEMENT)
+ or (_givenValue ==BITWISE_NOT)
+ or (_givenValue ==LOGICAL_NOT)
or (_givenValue ==RE_LITERAL)
or (_givenValue ==DOUBLE)
or (_givenValue ==INT)
or (_givenValue ==LONG)
+ or (_givenValue ==SINGLE_QUOTED_STRING)
): // 1827
expression_statement(container)
elif ((_givenValue == EOS)): // 1831
@@ -2830,10 +2755,10 @@ class UnityScriptParser(antlr.LLkParser):
raise NoViableAltException(LT(1), getFilename())
match(EOS)
_givenValue = LA(1)
- if ((_givenValue == FALSE)
+ if ((_givenValue == EACH)
+ or (_givenValue ==FALSE)
or (_givenValue ==FUNCTION)
or (_givenValue ==NEW)
- or (_givenValue ==NOT)
or (_givenValue ==NULL)
or (_givenValue ==SUPER)
or (_givenValue ==THIS)
@@ -2847,11 +2772,13 @@ class UnityScriptParser(antlr.LLkParser):
or (_givenValue ==INCREMENT)
or (_givenValue ==DECREMENT)
or (_givenValue ==SUBTRACT)
- or (_givenValue ==ONES_COMPLEMENT)
+ or (_givenValue ==BITWISE_NOT)
+ or (_givenValue ==LOGICAL_NOT)
or (_givenValue ==RE_LITERAL)
or (_givenValue ==DOUBLE)
or (_givenValue ==INT)
or (_givenValue ==LONG)
+ or (_givenValue ==SINGLE_QUOTED_STRING)
): // 1827
condition=expression()
elif ((_givenValue == EOS)): // 1831
@@ -2860,10 +2787,10 @@ class UnityScriptParser(antlr.LLkParser):
raise NoViableAltException(LT(1), getFilename())
match(EOS)
_givenValue = LA(1)
- if ((_givenValue == FALSE)
+ if ((_givenValue == EACH)
+ or (_givenValue ==FALSE)
or (_givenValue ==FUNCTION)
or (_givenValue ==NEW)
- or (_givenValue ==NOT)
or (_givenValue ==NULL)
or (_givenValue ==SUPER)
or (_givenValue ==THIS)
@@ -2877,41 +2804,113 @@ class UnityScriptParser(antlr.LLkParser):
or (_givenValue ==INCREMENT)
or (_givenValue ==DECREMENT)
or (_givenValue ==SUBTRACT)
- or (_givenValue ==ONES_COMPLEMENT)
+ or (_givenValue ==BITWISE_NOT)
+ or (_givenValue ==LOGICAL_NOT)
or (_givenValue ==RE_LITERAL)
or (_givenValue ==DOUBLE)
or (_givenValue ==INT)
or (_givenValue ==LONG)
+ or (_givenValue ==SINGLE_QUOTED_STRING)
): // 1827
update=assignment_expression()
elif ((_givenValue == RPAREN)): // 1831
pass // 947
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
- if 0 == inputState.guessing:
- ws = WhileStatement(Condition: condition)
- if condition is null:
- ws.Condition = BoolLiteralExpression(Value: true)
- b = ws.Block
- stmt = ws
- // support for 'continue'
- label = SetUpLoopLabel(ws)
- container.Add(stmt)
- EnterLoop(ws)
- match(RPAREN)
- compound_or_single_stmt(b)
- if 0 == inputState.guessing:
- LeaveLoop(ws)
- if IsLabelInUse(ws):
- b.Add(LabelStatement(Name: label))
- b.Add(update) if update is not null
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
+ if 0 == inputState.guessing:
+ ws = WhileStatement(Condition: condition)
+ if condition is null:
+ ws.Condition = BoolLiteralExpression(Value: true)
+ b = ws.Block
+ stmt = ws
+ // support for 'continue'
+ label = SetUpLoopLabel(ws)
+ container.Add(stmt)
+ EnterLoop(ws)
+ match(RPAREN)
+ compound_or_single_stmt(b)
+ if 0 == inputState.guessing:
+ LeaveLoop(ws)
+ if IsLabelInUse(ws):
+ b.Add(LabelStatement(Name: label))
+ b.Add(update) if update is not null
+ except ex as RecognitionException:
+ if (0 == inputState.guessing):
+ reportError(ex)
+ recover(ex,tokenSet_15_)
+ else:
+ raise
+ return stmt
+
+ public def member() as Token : //throws RecognitionException, TokenStreamException
+ name as Token
+
+ id as IToken = null
+ st as IToken = null
+ gt as IToken = null
+ eh as IToken = null
+
+ try: // for error handling
+ _givenValue = LA(1)
+ if ((_givenValue == ID)): // 1831
+ id = LT(1)
+ match(ID)
+ if 0 == inputState.guessing:
+ name=id;
+ elif ((_givenValue == SET)): // 1831
+ st = LT(1)
+ match(SET)
+ if 0 == inputState.guessing:
+ name=st;
+ elif ((_givenValue == GET)): // 1831
+ gt = LT(1)
+ match(GET)
+ if 0 == inputState.guessing:
+ name=gt;
+ elif ((_givenValue == EACH)): // 1831
+ eh = LT(1)
+ match(EACH)
+ if 0 == inputState.guessing:
+ name=eh;
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
+ except ex as RecognitionException:
+ if (0 == inputState.guessing):
+ reportError(ex)
+ recover(ex,tokenSet_20_)
+ else:
+ raise
+ return name
+
+ public def expression_list(
+ ec as ExpressionCollection
+ ) as void: //throws RecognitionException, TokenStreamException
+
+
+ try: // for error handling
+ if ((tokenSet_16_.member(cast(int, LA(1)))) and (tokenSet_17_.member(cast(int, LA(2))))):
+ e=expression()
+ if 0 == inputState.guessing:
+ ec.Add(e);
+ while true:
+ if ((LA(1)==COMMA)):
+ match(COMMA)
+ e=expression()
+ if 0 == inputState.guessing:
+ ec.Add(e);
+ else:
+ goto _loop229_breakloop
+ :_loop229_breakloop
+ elif ((LA(1)==LBRACE or LA(1)==RPAREN or LA(1)==RBRACK) and (tokenSet_20_.member(cast(int, LA(2))))): // line 2102
+ pass // 947
+ else:
+ raise NoViableAltException(LT(1), getFilename())
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_32_)
+ recover(ex,tokenSet_52_)
else:
raise
- return stmt
public def paren_expression() as Expression : //throws RecognitionException, TokenStreamException
e as Expression
@@ -2924,7 +2923,7 @@ class UnityScriptParser(antlr.LLkParser):
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_12_)
+ recover(ex,tokenSet_20_)
else:
raise
return e
@@ -2944,7 +2943,7 @@ class UnityScriptParser(antlr.LLkParser):
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_32_)
+ recover(ex,tokenSet_15_)
else:
raise
@@ -2954,11 +2953,11 @@ class UnityScriptParser(antlr.LLkParser):
qm as IToken = null
try: // for error handling
- e=logical_expression()
- if ((LA(1)==QUESTION_MARK) and (tokenSet_13_.member(cast(int, LA(2))))):
+ e=logical_or()
+ if ((LA(1)==QUESTION_MARK) and (tokenSet_16_.member(cast(int, LA(2))))):
qm = LT(1)
match(QUESTION_MARK)
- trueValue=logical_expression()
+ trueValue=logical_or()
match(COLON)
falseValue=conditional_expression()
if 0 == inputState.guessing:
@@ -2966,52 +2965,18 @@ class UnityScriptParser(antlr.LLkParser):
Condition: e,
TrueValue: trueValue,
FalseValue: falseValue)
- elif ((tokenSet_12_.member(cast(int, LA(1)))) and (tokenSet_53_.member(cast(int, LA(2))))): // line 2102
+ elif ((tokenSet_20_.member(cast(int, LA(1)))) and (tokenSet_28_.member(cast(int, LA(2))))): // line 2102
pass // 947
else:
raise NoViableAltException(LT(1), getFilename())
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_12_)
+ recover(ex,tokenSet_20_)
else:
raise
return e
- public def member() as Token : //throws RecognitionException, TokenStreamException
- name as Token
-
- id as IToken = null
- st as IToken = null
- gt as IToken = null
-
- try: // for error handling
- _givenValue = LA(1)
- if ((_givenValue == ID)): // 1831
- id = LT(1)
- match(ID)
- if 0 == inputState.guessing:
- name=id;
- elif ((_givenValue == SET)): // 1831
- st = LT(1)
- match(SET)
- if 0 == inputState.guessing:
- name=st;
- elif ((_givenValue == GET)): // 1831
- gt = LT(1)
- match(GET)
- if 0 == inputState.guessing:
- name=gt;
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
- except ex as RecognitionException:
- if (0 == inputState.guessing):
- reportError(ex)
- recover(ex,tokenSet_12_)
- else:
- raise
- return name
-
public def simple_type_reference() as TypeReference : //throws RecognitionException, TokenStreamException
tr as TypeReference
@@ -3026,7 +2991,7 @@ class UnityScriptParser(antlr.LLkParser):
arguments = gtr.GenericArguments
type_reference_list(arguments)
match(GREATER_THAN)
- elif ((tokenSet_40_.member(cast(int, LA(1)))) and (tokenSet_41_.member(cast(int, LA(2))))): // line 2102
+ elif ((tokenSet_35_.member(cast(int, LA(1)))) and (tokenSet_25_.member(cast(int, LA(2))))): // line 2102
if 0 == inputState.guessing:
tr = SimpleTypeReference(ToLexicalInfo(typeName), Name: typeName.getText())
else:
@@ -3034,7 +2999,7 @@ class UnityScriptParser(antlr.LLkParser):
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_40_)
+ recover(ex,tokenSet_35_)
else:
raise
return tr
@@ -3056,14 +3021,14 @@ class UnityScriptParser(antlr.LLkParser):
returnType=type_reference()
if 0 == inputState.guessing:
callableTypeRef.ReturnType = returnType
- elif ((tokenSet_40_.member(cast(int, LA(1)))) and (tokenSet_41_.member(cast(int, LA(2))))): // line 2102
+ elif ((tokenSet_35_.member(cast(int, LA(1)))) and (tokenSet_25_.member(cast(int, LA(2))))): // line 2102
pass // 947
else:
raise NoViableAltException(LT(1), getFilename())
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_40_)
+ recover(ex,tokenSet_35_)
else:
raise
return tr
@@ -3089,8 +3054,8 @@ class UnityScriptParser(antlr.LLkParser):
if 0 == inputState.guessing:
parameters.Add(ParameterDeclaration(Type: parameterType, Name: "arg" + len(parameters)))
else:
- goto _loop171_breakloop
- :_loop171_breakloop
+ goto _loop185_breakloop
+ :_loop185_breakloop
elif ((_givenValue == RPAREN)): // 1831
pass // 947
else: // line 1969
@@ -3099,25 +3064,37 @@ class UnityScriptParser(antlr.LLkParser):
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_40_)
+ recover(ex,tokenSet_35_)
else:
raise
public def array_initializer() as Expression : //throws RecognitionException, TokenStreamException
e as Expression
+ dimensions = List of Expression(1)
try: // for error handling
tr=simple_type_reference()
match(LBRACK)
- count=sum()
+ size=sum()
+ if 0 == inputState.guessing:
+ dimensions.Add(size)
+ while true:
+ if ((LA(1)==COMMA)):
+ match(COMMA)
+ size=sum()
+ if 0 == inputState.guessing:
+ dimensions.Add(size)
+ else:
+ goto _loop188_breakloop
+ :_loop188_breakloop
match(RBRACK)
if 0 == inputState.guessing:
- e = CodeFactory.NewArrayInitializer(tr.LexicalInfo, tr, count)
+ e = CodeFactory.NewArrayInitializer(tr.LexicalInfo, tr, dimensions)
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_12_)
+ recover(ex,tokenSet_20_)
else:
raise
return e
@@ -3127,14 +3104,12 @@ class UnityScriptParser(antlr.LLkParser):
add as IToken = null
sub as IToken = null
- bitor as IToken = null
- eo as IToken = null
bOperator = BinaryOperatorType.None;
try: // for error handling
e=term()
while true:
- if ((tokenSet_54_.member(cast(int, LA(1)))) and (tokenSet_13_.member(cast(int, LA(2))))):
+ if ((LA(1)==ADD or LA(1)==SUBTRACT) and (tokenSet_16_.member(cast(int, LA(2))))):
_givenValue = LA(1)
if ((_givenValue == ADD)): // 1831
add = LT(1)
@@ -3146,16 +3121,6 @@ class UnityScriptParser(antlr.LLkParser):
match(SUBTRACT)
if 0 == inputState.guessing:
op=sub; bOperator = BinaryOperatorType.Subtraction;
- elif ((_givenValue == BITWISE_OR)): // 1831
- bitor = LT(1)
- match(BITWISE_OR)
- if 0 == inputState.guessing:
- op=bitor; bOperator = BinaryOperatorType.BitwiseOr;
- elif ((_givenValue == EXCLUSIVE_OR)): // 1831
- eo = LT(1)
- match(EXCLUSIVE_OR)
- if 0 == inputState.guessing:
- op=eo; bOperator = BinaryOperatorType.ExclusiveOr;
else: // line 1969
raise NoViableAltException(LT(1), getFilename())
r=term()
@@ -3166,12 +3131,12 @@ class UnityScriptParser(antlr.LLkParser):
be.Right = r
e = be
else:
- goto _loop253_breakloop
- :_loop253_breakloop
+ goto _loop263_breakloop
+ :_loop263_breakloop
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_12_)
+ recover(ex,tokenSet_20_)
else:
raise
return e
@@ -3186,7 +3151,7 @@ class UnityScriptParser(antlr.LLkParser):
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_12_)
+ recover(ex,tokenSet_20_)
else:
raise
return e
@@ -3196,20 +3161,20 @@ class UnityScriptParser(antlr.LLkParser):
try: // for error handling
- synPredMatched183 as bool = false
+ synPredMatched199 as bool = false
if ((LA(1)==NEW) and (LA(2)==ID)):
- _m183 as int = mark()
- synPredMatched183 = true
+ _m199 as int = mark()
+ synPredMatched199 = true
++inputState.guessing
try:
new_array_expression()
except x as RecognitionException:
- synPredMatched183 = false
- rewind(_m183)
+ synPredMatched199 = false
+ rewind(_m199)
--inputState.guessing
- if synPredMatched183:
+ if synPredMatched199:
e=new_array_expression()
- elif ((LA(1)==NEW) and (LA(2)==ID)): // line 2102
+ elif ((LA(1)==NEW) and (LA(2)==EACH or LA(2)==ID)): // line 2102
match(NEW)
r=reference_expression()
if 0 == inputState.guessing:
@@ -3223,22 +3188,132 @@ class UnityScriptParser(antlr.LLkParser):
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_12_)
+ recover(ex,tokenSet_20_)
else:
raise
return e
- public def expression_list(
- ec as ExpressionCollection
- ) as void: //throws RecognitionException, TokenStreamException
+ public def atom() as Expression : //throws RecognitionException, TokenStreamException
+ e as Expression
try: // for error handling
_givenValue = LA(1)
if ((_givenValue == FALSE)
+ or (_givenValue ==NULL)
+ or (_givenValue ==SUPER)
+ or (_givenValue ==THIS)
+ or (_givenValue ==TRUE)
+ or (_givenValue ==DOUBLE_QUOTED_STRING)
+ or (_givenValue ==LBRACE)
+ or (_givenValue ==LBRACK)
+ or (_givenValue ==RE_LITERAL)
+ or (_givenValue ==DOUBLE)
+ or (_givenValue ==INT)
+ or (_givenValue ==LONG)
+ or (_givenValue ==SINGLE_QUOTED_STRING)
+ ): // 1827
+ e=literal()
+ elif ((_givenValue == FUNCTION)): // 1831
+ e=function_expression()
+ elif ((_givenValue == EACH)
+ or (_givenValue ==ID)
+ ): // 1827
+ e=simple_reference_expression()
+ elif ((_givenValue == LPAREN)): // 1831
+ e=paren_expression()
+ elif ((_givenValue == NEW)): // 1831
+ e=new_expression()
+ elif ((_givenValue == TYPEOF)): // 1831
+ e=typeof_expression()
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
+ except ex as RecognitionException:
+ if (0 == inputState.guessing):
+ reportError(ex)
+ recover(ex,tokenSet_20_)
+ else:
+ raise
+ return e
+
+ public def literal() as Expression : //throws RecognitionException, TokenStreamException
+ e as Expression
+
+
+ try: // for error handling
+ _givenValue = LA(1)
+ if ((_givenValue == INT)
+ or (_givenValue ==LONG)
+ ): // 1827
+ e=integer_literal()
+ elif ((_givenValue == DOUBLE_QUOTED_STRING)
+ or (_givenValue ==SINGLE_QUOTED_STRING)
+ ): // 1827
+ e=string_literal()
+ elif ((_givenValue == LBRACK)): // 1831
+ e=array_literal()
+ elif ((_givenValue == LBRACE)): // 1831
+ e=hash_literal()
+ elif ((_givenValue == RE_LITERAL)): // 1831
+ e=re_literal()
+ elif ((_givenValue == FALSE)
+ or (_givenValue ==TRUE)
+ ): // 1827
+ e=bool_literal()
+ elif ((_givenValue == NULL)): // 1831
+ e=null_literal()
+ elif ((_givenValue == THIS)): // 1831
+ e=self_literal()
+ elif ((_givenValue == SUPER)): // 1831
+ e=super_literal()
+ elif ((_givenValue == DOUBLE)): // 1831
+ e=double_literal()
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
+ except ex as RecognitionException:
+ if (0 == inputState.guessing):
+ reportError(ex)
+ recover(ex,tokenSet_20_)
+ else:
+ raise
+ return e
+
+ public def function_expression() as BlockExpression : //throws RecognitionException, TokenStreamException
+ e as BlockExpression
+
+ fn as IToken = null
+
+ try: // for error handling
+ fn = LT(1)
+ match(FUNCTION)
+ if 0 == inputState.guessing:
+ e = BlockExpression(ToLexicalInfo(fn))
+ e.Annotate("inline");
+ body = e.Body
+ match(LPAREN)
+ _givenValue = LA(1)
+ if ((_givenValue == EACH)
+ or (_givenValue ==FINAL)
+ or (_givenValue ==INTERNAL)
+ or (_givenValue ==ID)
+ or (_givenValue ==AT)
+ ): // 1827
+ parameter_declaration_list(e)
+ elif ((_givenValue == RPAREN)): // 1831
+ pass // 947
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
+ match(RPAREN)
+ _givenValue = LA(1)
+ if ((_givenValue == COLON)): // 1831
+ match(COLON)
+ tr=type_reference()
+ if 0 == inputState.guessing:
+ e.ReturnType = tr;
+ elif ((_givenValue == EACH)
+ or (_givenValue ==FALSE)
or (_givenValue ==FUNCTION)
or (_givenValue ==NEW)
- or (_givenValue ==NOT)
or (_givenValue ==NULL)
or (_givenValue ==SUPER)
or (_givenValue ==THIS)
@@ -3252,171 +3327,209 @@ class UnityScriptParser(antlr.LLkParser):
or (_givenValue ==INCREMENT)
or (_givenValue ==DECREMENT)
or (_givenValue ==SUBTRACT)
- or (_givenValue ==ONES_COMPLEMENT)
+ or (_givenValue ==BITWISE_NOT)
+ or (_givenValue ==LOGICAL_NOT)
or (_givenValue ==RE_LITERAL)
or (_givenValue ==DOUBLE)
or (_givenValue ==INT)
or (_givenValue ==LONG)
- ): // 1827
- e=expression()
- if 0 == inputState.guessing:
- ec.Add(e);
- while true:
- if ((LA(1)==COMMA)):
- match(COMMA)
- e=expression()
- if 0 == inputState.guessing:
- ec.Add(e);
- else:
- goto _loop211_breakloop
- :_loop211_breakloop
- elif ((_givenValue == RPAREN)
- or (_givenValue ==RBRACK)
+ or (_givenValue ==SINGLE_QUOTED_STRING)
): // 1827
pass // 947
else: // line 1969
raise NoViableAltException(LT(1), getFilename())
+ if ((LA(1)==LBRACE) and (tokenSet_13_.member(cast(int, LA(2))))):
+ block(body)
+ elif ((tokenSet_16_.member(cast(int, LA(1)))) and (tokenSet_20_.member(cast(int, LA(2))))): // line 2102
+ returnValue=expression()
+ if 0 == inputState.guessing:
+ body.Add(returnValue)
+ else:
+ raise NoViableAltException(LT(1), getFilename())
+ except ex as RecognitionException:
+ if (0 == inputState.guessing):
+ reportError(ex)
+ recover(ex,tokenSet_20_)
+ else:
+ raise
+ return e
+
+ public def simple_reference_expression() as Expression : //throws RecognitionException, TokenStreamException
+ e as Expression
+
+ id as IToken = null
+ each as IToken = null
+
+ try: // for error handling
+ _givenValue = LA(1)
+ if ((_givenValue == ID)): // 1831
+ id = LT(1)
+ match(ID)
+ elif ((_givenValue == EACH)): // 1831
+ each = LT(1)
+ match(EACH)
+ if 0 == inputState.guessing:
+ id = each
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
+ if 0 == inputState.guessing:
+ e = ReferenceExpression(ToLexicalInfo(id), Name: id.getText())
+ except ex as RecognitionException:
+ if (0 == inputState.guessing):
+ reportError(ex)
+ recover(ex,tokenSet_20_)
+ else:
+ raise
+ return e
+
+ public def typeof_expression() as Expression : //throws RecognitionException, TokenStreamException
+ e as Expression
+
+
+ try: // for error handling
+ synPredMatched218 as bool = false
+ if ((LA(1)==TYPEOF) and (tokenSet_16_.member(cast(int, LA(2))))):
+ _m218 as int = mark()
+ synPredMatched218 = true
+ ++inputState.guessing
+ try:
+ match(TYPEOF)
+ match(LPAREN)
+ expression()
+ match(RPAREN)
+ except x as RecognitionException:
+ synPredMatched218 = false
+ rewind(_m218)
+ --inputState.guessing
+ if synPredMatched218:
+ e=typeof_with_expression()
+ elif ((LA(1)==TYPEOF) and (tokenSet_16_.member(cast(int, LA(2))))): // line 2102
+ e=typeof_expression_alt()
+ else:
+ raise NoViableAltException(LT(1), getFilename())
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_55_)
+ recover(ex,tokenSet_20_)
else:
raise
+ return e
- public def atom() as Expression : //throws RecognitionException, TokenStreamException
+ public def member_reference_expression(
+ target as Expression
+ ) as Expression : //throws RecognitionException, TokenStreamException
e as Expression
+ lbrack as IToken = null
+ e = target;
try: // for error handling
_givenValue = LA(1)
- if ((_givenValue == FALSE)
- or (_givenValue ==NULL)
- or (_givenValue ==SUPER)
- or (_givenValue ==THIS)
- or (_givenValue ==TRUE)
- or (_givenValue ==DOUBLE_QUOTED_STRING)
- or (_givenValue ==LBRACE)
- or (_givenValue ==LBRACK)
- or (_givenValue ==RE_LITERAL)
- or (_givenValue ==DOUBLE)
- or (_givenValue ==INT)
- or (_givenValue ==LONG)
+ if ((_givenValue == LESS_THAN)): // 1831
+ lbrack = LT(1)
+ match(LESS_THAN)
+ if 0 == inputState.guessing:
+ e = gre = GenericReferenceExpression(ToLexicalInfo(lbrack), Target: e)
+ genericArguments = gre.GenericArguments
+ type_reference_list(genericArguments)
+ match(GREATER_THAN)
+ elif ((_givenValue == EACH)
+ or (_givenValue ==GET)
+ or (_givenValue ==SET)
+ or (_givenValue ==ID)
): // 1827
- e=literal()
- elif ((_givenValue == NEW)): // 1831
- e=new_expression()
+ memberName=member()
+ if 0 == inputState.guessing:
+ e = MemberReferenceExpression(ToLexicalInfo(memberName), Target: e, Name: memberName.getText())
else: // line 1969
- if ((LA(1)==FUNCTION) and (LA(2)==LPAREN)):
- e=function_expression()
- elif ((LA(1)==ID) and (tokenSet_12_.member(cast(int, LA(2))))): // line 2102
- e=simple_reference_expression()
- elif ((LA(1)==LPAREN) and (tokenSet_13_.member(cast(int, LA(2))))): // line 2102
- e=paren_expression()
- elif ((tokenSet_9_.member(cast(int, LA(1)))) and (tokenSet_12_.member(cast(int, LA(2))))): // line 2102
- e=typeof_expression()
- else:
raise NoViableAltException(LT(1), getFilename())
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_12_)
+ recover(ex,tokenSet_20_)
else:
raise
return e
- public def literal() as Expression : //throws RecognitionException, TokenStreamException
+ protected def typeof_with_expression() as Expression : //throws RecognitionException, TokenStreamException
e as Expression
+ t as IToken = null
try: // for error handling
- _givenValue = LA(1)
- if ((_givenValue == INT)
- or (_givenValue ==LONG)
- ): // 1827
- e=integer_literal()
- elif ((_givenValue == DOUBLE_QUOTED_STRING)): // 1831
- e=string_literal()
- elif ((_givenValue == LBRACK)): // 1831
- e=array_literal()
- elif ((_givenValue == LBRACE)): // 1831
- e=hash_literal()
- elif ((_givenValue == RE_LITERAL)): // 1831
- e=re_literal()
- elif ((_givenValue == FALSE)
- or (_givenValue ==TRUE)
- ): // 1827
- e=bool_literal()
- elif ((_givenValue == NULL)): // 1831
- e=null_literal()
- elif ((_givenValue == THIS)): // 1831
- e=self_literal()
- elif ((_givenValue == SUPER)): // 1831
- e=super_literal()
- elif ((_givenValue == DOUBLE)): // 1831
- e=double_literal()
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
+ t = LT(1)
+ match(TYPEOF)
+ if ((LA(1)==LPAREN) and (tokenSet_16_.member(cast(int, LA(2))))):
+ match(LPAREN)
+ arg=expression()
+ match(RPAREN)
+ elif ((tokenSet_16_.member(cast(int, LA(1)))) and (tokenSet_20_.member(cast(int, LA(2))))): // line 2102
+ arg=expression()
+ else:
+ raise NoViableAltException(LT(1), getFilename())
+ if 0 == inputState.guessing:
+ mie = MethodInvocationExpression(ToLexicalInfo(t));
+ mie.Target = ReferenceExpression(ToLexicalInfo(t), Name: t.getText())
+ mie.Arguments.Add(arg)
+ e = mie
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_12_)
+ recover(ex,tokenSet_20_)
else:
raise
return e
- public def function_expression() as BlockExpression : //throws RecognitionException, TokenStreamException
- e as BlockExpression
+ protected def typeof_expression_alt() as Expression : //throws RecognitionException, TokenStreamException
+ e as Expression
- fn as IToken = null
try: // for error handling
- fn = LT(1)
- match(FUNCTION)
- if 0 == inputState.guessing:
- e = BlockExpression(ToLexicalInfo(fn))
- body = e.Body
- match(LPAREN)
- _givenValue = LA(1)
- if ((_givenValue == ID)): // 1831
- parameter_declaration_list(e)
- elif ((_givenValue == RPAREN)): // 1831
- pass // 947
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
- match(RPAREN)
- _givenValue = LA(1)
- if ((_givenValue == COLON)): // 1831
- match(COLON)
- tr=type_reference()
- if 0 == inputState.guessing:
- e.ReturnType = tr;
- elif ((_givenValue == LBRACE)): // 1831
- pass // 947
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
- block(body)
+ synPredMatched221 as bool = false
+ if ((LA(1)==TYPEOF) and (LA(2)==LPAREN)):
+ _m221 as int = mark()
+ synPredMatched221 = true
+ ++inputState.guessing
+ try:
+ match(TYPEOF)
+ match(LPAREN)
+ type_reference()
+ match(RPAREN)
+ except x as RecognitionException:
+ synPredMatched221 = false
+ rewind(_m221)
+ --inputState.guessing
+ if synPredMatched221:
+ e=typeof_with_typeref()
+ elif ((LA(1)==TYPEOF) and (tokenSet_16_.member(cast(int, LA(2))))): // line 2102
+ e=typeof_with_expression()
+ else:
+ raise NoViableAltException(LT(1), getFilename())
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_12_)
+ recover(ex,tokenSet_20_)
else:
raise
return e
- public def simple_reference_expression() as Expression : //throws RecognitionException, TokenStreamException
+ protected def typeof_with_typeref() as Expression : //throws RecognitionException, TokenStreamException
e as Expression
- id as IToken = null
+ t as IToken = null
try: // for error handling
- id = LT(1)
- match(ID)
+ t = LT(1)
+ match(TYPEOF)
+ match(LPAREN)
+ tr=type_reference()
+ match(RPAREN)
if 0 == inputState.guessing:
- e = ReferenceExpression(ToLexicalInfo(id), Name: id.getText())
+ e = TypeofExpression(ToLexicalInfo(t), tr);
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_12_)
+ recover(ex,tokenSet_20_)
else:
raise
return e
@@ -3436,10 +3549,10 @@ class UnityScriptParser(antlr.LLkParser):
if 0 == inputState.guessing:
begin = OmittedExpression.Default;
_givenValue = LA(1)
- if ((_givenValue == FALSE)
+ if ((_givenValue == EACH)
+ or (_givenValue ==FALSE)
or (_givenValue ==FUNCTION)
or (_givenValue ==NEW)
- or (_givenValue ==NOT)
or (_givenValue ==NULL)
or (_givenValue ==SUPER)
or (_givenValue ==THIS)
@@ -3453,11 +3566,13 @@ class UnityScriptParser(antlr.LLkParser):
or (_givenValue ==INCREMENT)
or (_givenValue ==DECREMENT)
or (_givenValue ==SUBTRACT)
- or (_givenValue ==ONES_COMPLEMENT)
+ or (_givenValue ==BITWISE_NOT)
+ or (_givenValue ==LOGICAL_NOT)
or (_givenValue ==RE_LITERAL)
or (_givenValue ==DOUBLE)
or (_givenValue ==INT)
or (_givenValue ==LONG)
+ or (_givenValue ==SINGLE_QUOTED_STRING)
): // 1827
end=expression()
elif ((_givenValue == COLON)): // 1831
@@ -3471,10 +3586,200 @@ class UnityScriptParser(antlr.LLkParser):
pass // 947
else: // line 1969
raise NoViableAltException(LT(1), getFilename())
- elif ((_givenValue == FALSE)
+ elif ((_givenValue == EACH)
+ or (_givenValue ==FALSE)
+ or (_givenValue ==FUNCTION)
+ or (_givenValue ==NEW)
+ or (_givenValue ==NULL)
+ or (_givenValue ==SUPER)
+ or (_givenValue ==THIS)
+ or (_givenValue ==TRUE)
+ or (_givenValue ==TYPEOF)
+ or (_givenValue ==ID)
+ or (_givenValue ==DOUBLE_QUOTED_STRING)
+ or (_givenValue ==LBRACE)
+ or (_givenValue ==LPAREN)
+ or (_givenValue ==LBRACK)
+ or (_givenValue ==INCREMENT)
+ or (_givenValue ==DECREMENT)
+ or (_givenValue ==SUBTRACT)
+ or (_givenValue ==BITWISE_NOT)
+ or (_givenValue ==LOGICAL_NOT)
+ or (_givenValue ==RE_LITERAL)
+ or (_givenValue ==DOUBLE)
+ or (_givenValue ==INT)
+ or (_givenValue ==LONG)
+ or (_givenValue ==SINGLE_QUOTED_STRING)
+ ): // 1827
+ begin=expression()
+ _givenValue = LA(1)
+ if ((_givenValue == COLON)): // 1831
+ match(COLON)
+ _givenValue = LA(1)
+ if ((_givenValue == EACH)
+ or (_givenValue ==FALSE)
+ or (_givenValue ==FUNCTION)
+ or (_givenValue ==NEW)
+ or (_givenValue ==NULL)
+ or (_givenValue ==SUPER)
+ or (_givenValue ==THIS)
+ or (_givenValue ==TRUE)
+ or (_givenValue ==TYPEOF)
+ or (_givenValue ==ID)
+ or (_givenValue ==DOUBLE_QUOTED_STRING)
+ or (_givenValue ==LBRACE)
+ or (_givenValue ==LPAREN)
+ or (_givenValue ==LBRACK)
+ or (_givenValue ==INCREMENT)
+ or (_givenValue ==DECREMENT)
+ or (_givenValue ==SUBTRACT)
+ or (_givenValue ==BITWISE_NOT)
+ or (_givenValue ==LOGICAL_NOT)
+ or (_givenValue ==RE_LITERAL)
+ or (_givenValue ==DOUBLE)
+ or (_givenValue ==INT)
+ or (_givenValue ==LONG)
+ or (_givenValue ==SINGLE_QUOTED_STRING)
+ ): // 1827
+ end=expression()
+ elif ((_givenValue == COLON)
+ or (_givenValue ==COMMA)
+ or (_givenValue ==RBRACK)
+ ): // 1827
+ if 0 == inputState.guessing:
+ end = OmittedExpression.Default;
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
+ _givenValue = LA(1)
+ if ((_givenValue == COLON)): // 1831
+ match(COLON)
+ step=expression()
+ elif ((_givenValue == COMMA)
+ or (_givenValue ==RBRACK)
+ ): // 1827
+ pass // 947
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
+ elif ((_givenValue == COMMA)
+ or (_givenValue ==RBRACK)
+ ): // 1827
+ pass // 947
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
+ if 0 == inputState.guessing:
+ se.Indices.Add(Slice(begin, end, step))
+ except ex as RecognitionException:
+ if (0 == inputState.guessing):
+ reportError(ex)
+ recover(ex,tokenSet_53_)
+ else:
+ raise
+
+ public def slicing_expression() as Expression : //throws RecognitionException, TokenStreamException
+ e as Expression
+
+ lbrack as IToken = null
+ lparen as IToken = null
+ se as SlicingExpression
+ mce as MethodInvocationExpression
+ args as ExpressionCollection
+
+ try: // for error handling
+ e=atom()
+ while true:
+ if ((LA(1)==LBRACK) and (tokenSet_54_.member(cast(int, LA(2))))):
+ lbrack = LT(1)
+ match(LBRACK)
+ if 0 == inputState.guessing:
+ se = SlicingExpression(ToLexicalInfo(lbrack))
+ se.Target = e
+ e = se
+ slice(se)
+ while true:
+ if ((LA(1)==COMMA)):
+ match(COMMA)
+ slice(se)
+ else:
+ goto _loop245_breakloop
+ :_loop245_breakloop
+ match(RBRACK)
+ elif ((LA(1)==DOT) and (tokenSet_55_.member(cast(int, LA(2))))): // line 2102
+ match(DOT)
+ e=member_reference_expression(e)
+ elif ((LA(1)==LPAREN) and (tokenSet_22_.member(cast(int, LA(2))))): // line 2102
+ lparen = LT(1)
+ match(LPAREN)
+ if 0 == inputState.guessing:
+ mce = MethodInvocationExpression(ToLexicalInfo(lparen))
+ mce.Target = e
+ e = mce
+ args = mce.Arguments
+ expression_list(args)
+ match(RPAREN)
+ else:
+ goto _loop248_breakloop
+ :_loop248_breakloop
+ except ex as RecognitionException:
+ if (0 == inputState.guessing):
+ reportError(ex)
+ recover(ex,tokenSet_20_)
+ else:
+ raise
+ return e
+
+ public def postfix_unary_expression() as Expression : //throws RecognitionException, TokenStreamException
+ e as Expression
+
+ postinc as IToken = null
+ preinc as IToken = null
+
+ try: // for error handling
+ e=slicing_expression()
+ if ((LA(1)==INCREMENT) and (tokenSet_20_.member(cast(int, LA(2))))):
+ postinc = LT(1)
+ match(INCREMENT)
+ if 0 == inputState.guessing:
+ token = postinc; operator = UnaryOperatorType.PostIncrement;
+ elif ((LA(1)==DECREMENT) and (tokenSet_20_.member(cast(int, LA(2))))): // line 2102
+ preinc = LT(1)
+ match(DECREMENT)
+ if 0 == inputState.guessing:
+ token = preinc; operator= UnaryOperatorType.PostDecrement;
+ elif ((tokenSet_20_.member(cast(int, LA(1)))) and (tokenSet_28_.member(cast(int, LA(2))))): // line 2102
+ pass // 947
+ else:
+ raise NoViableAltException(LT(1), getFilename())
+ if 0 == inputState.guessing:
+ e = UnaryExpression(ToLexicalInfo(token), operator, e) if token is not null
+ except ex as RecognitionException:
+ if (0 == inputState.guessing):
+ reportError(ex)
+ recover(ex,tokenSet_20_)
+ else:
+ raise
+ return e
+
+ public def unary_expression() as Expression : //throws RecognitionException, TokenStreamException
+ e as Expression
+
+ tc as IToken = null
+ c as IToken = null
+
+ try: // for error handling
+ _givenValue = LA(1)
+ if ((_givenValue == INCREMENT)
+ or (_givenValue ==DECREMENT)
+ or (_givenValue ==SUBTRACT)
+ or (_givenValue ==BITWISE_NOT)
+ or (_givenValue ==LOGICAL_NOT)
+ ): // 1827
+ e=prefix_unary_expression()
+ elif ((_givenValue == EACH)
+ or (_givenValue ==FALSE)
or (_givenValue ==FUNCTION)
or (_givenValue ==NEW)
- or (_givenValue ==NOT)
or (_givenValue ==NULL)
or (_givenValue ==SUPER)
or (_givenValue ==THIS)
@@ -3485,178 +3790,212 @@ class UnityScriptParser(antlr.LLkParser):
or (_givenValue ==LBRACE)
or (_givenValue ==LPAREN)
or (_givenValue ==LBRACK)
- or (_givenValue ==INCREMENT)
- or (_givenValue ==DECREMENT)
- or (_givenValue ==SUBTRACT)
- or (_givenValue ==ONES_COMPLEMENT)
or (_givenValue ==RE_LITERAL)
or (_givenValue ==DOUBLE)
or (_givenValue ==INT)
or (_givenValue ==LONG)
+ or (_givenValue ==SINGLE_QUOTED_STRING)
): // 1827
- begin=expression()
- _givenValue = LA(1)
- if ((_givenValue == COLON)): // 1831
- match(COLON)
- _givenValue = LA(1)
- if ((_givenValue == FALSE)
- or (_givenValue ==FUNCTION)
- or (_givenValue ==NEW)
- or (_givenValue ==NOT)
- or (_givenValue ==NULL)
- or (_givenValue ==SUPER)
- or (_givenValue ==THIS)
- or (_givenValue ==TRUE)
- or (_givenValue ==TYPEOF)
- or (_givenValue ==ID)
- or (_givenValue ==DOUBLE_QUOTED_STRING)
- or (_givenValue ==LBRACE)
- or (_givenValue ==LPAREN)
- or (_givenValue ==LBRACK)
- or (_givenValue ==INCREMENT)
- or (_givenValue ==DECREMENT)
- or (_givenValue ==SUBTRACT)
- or (_givenValue ==ONES_COMPLEMENT)
- or (_givenValue ==RE_LITERAL)
- or (_givenValue ==DOUBLE)
- or (_givenValue ==INT)
- or (_givenValue ==LONG)
- ): // 1827
- end=expression()
- elif ((_givenValue == COLON)
- or (_givenValue ==COMMA)
- or (_givenValue ==RBRACK)
- ): // 1827
- if 0 == inputState.guessing:
- end = OmittedExpression.Default;
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
- _givenValue = LA(1)
- if ((_givenValue == COLON)): // 1831
- match(COLON)
- step=expression()
- elif ((_givenValue == COMMA)
- or (_givenValue ==RBRACK)
- ): // 1827
- pass // 947
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
- elif ((_givenValue == COMMA)
- or (_givenValue ==RBRACK)
- ): // 1827
- pass // 947
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
+ e=postfix_unary_expression()
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
+ if ((LA(1)==AS) and (LA(2)==FUNCTION or LA(2)==ID)):
+ tc = LT(1)
+ match(AS)
+ tr=type_reference()
+ if 0 == inputState.guessing:
+ e = TryCastExpression(ToLexicalInfo(tc), Target: e, Type: tr)
+ elif ((LA(1)==CAST) and (LA(2)==FUNCTION or LA(2)==ID)): // line 2102
+ c = LT(1)
+ match(CAST)
+ tr=type_reference()
+ if 0 == inputState.guessing:
+ e = CastExpression(ToLexicalInfo(c), Target: e, Type: tr)
+ elif ((tokenSet_20_.member(cast(int, LA(1)))) and (tokenSet_28_.member(cast(int, LA(2))))): // line 2102
+ pass // 947
+ else:
+ raise NoViableAltException(LT(1), getFilename())
+ except ex as RecognitionException:
+ if (0 == inputState.guessing):
+ reportError(ex)
+ recover(ex,tokenSet_20_)
+ else:
+ raise
+ return e
+
+ public def prefix_unary_expression() as Expression : //throws RecognitionException, TokenStreamException
+ e as Expression
+
+ sub as IToken = null
+ inc as IToken = null
+ dec as IToken = null
+ nt as IToken = null
+ oc as IToken = null
+ uOperator = UnaryOperatorType.None
+
+ try: // for error handling
+ _givenValue = LA(1)
+ if ((_givenValue == SUBTRACT)): // 1831
+ sub = LT(1)
+ match(SUBTRACT)
+ if 0 == inputState.guessing:
+ op = sub; uOperator = UnaryOperatorType.UnaryNegation;
+ elif ((_givenValue == INCREMENT)): // 1831
+ inc = LT(1)
+ match(INCREMENT)
+ if 0 == inputState.guessing:
+ op = inc; uOperator = UnaryOperatorType.Increment;
+ elif ((_givenValue == DECREMENT)): // 1831
+ dec = LT(1)
+ match(DECREMENT)
+ if 0 == inputState.guessing:
+ op = dec; uOperator = UnaryOperatorType.Decrement;
+ elif ((_givenValue == LOGICAL_NOT)): // 1831
+ nt = LT(1)
+ match(LOGICAL_NOT)
+ if 0 == inputState.guessing:
+ op = nt; uOperator = UnaryOperatorType.LogicalNot;
+ elif ((_givenValue == BITWISE_NOT)): // 1831
+ oc = LT(1)
+ match(BITWISE_NOT)
+ if 0 == inputState.guessing:
+ op = oc; uOperator = UnaryOperatorType.OnesComplement;
else: // line 1969
raise NoViableAltException(LT(1), getFilename())
+ e=unary_expression()
if 0 == inputState.guessing:
- se.Indices.Add(Slice(begin, end, step))
+ e = UnaryExpression(ToLexicalInfo(op), uOperator, e)
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_56_)
+ recover(ex,tokenSet_20_)
else:
raise
+ return e
- public def logical_expression() as Expression : //throws RecognitionException, TokenStreamException
+ public def term() as Expression : //throws RecognitionException, TokenStreamException
e as Expression
- op as IToken = null
+ m as IToken = null
+ d as IToken = null
+ md as IToken = null
+ op = BinaryOperatorType.None
try: // for error handling
- e=boolean_term()
+ e=unary_expression()
while true:
- if ((LA(1)==LOGICAL_OR) and (tokenSet_13_.member(cast(int, LA(2))))):
- op = LT(1)
- match(LOGICAL_OR)
- rhs=boolean_term()
+ if ((LA(1)==MODULUS or LA(1)==MULTIPLY or LA(1)==DIVISION) and (tokenSet_16_.member(cast(int, LA(2))))):
+ _givenValue = LA(1)
+ if ((_givenValue == MULTIPLY)): // 1831
+ m = LT(1)
+ match(MULTIPLY)
+ if 0 == inputState.guessing:
+ op=BinaryOperatorType.Multiply; token=m;
+ elif ((_givenValue == DIVISION)): // 1831
+ d = LT(1)
+ match(DIVISION)
+ if 0 == inputState.guessing:
+ op=BinaryOperatorType.Division; token=d;
+ elif ((_givenValue == MODULUS)): // 1831
+ md = LT(1)
+ match(MODULUS)
+ if 0 == inputState.guessing:
+ op=BinaryOperatorType.Modulus; token=md;
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
+ r=unary_expression()
if 0 == inputState.guessing:
- e = BinaryExpression(ToLexicalInfo(op),
- Operator: BinaryOperatorType.Or,
- Left: e,
- Right: rhs)
+ be = BinaryExpression(ToLexicalInfo(token))
+ be.Operator = op
+ be.Left = e
+ be.Right = r
+ e = be
else:
- goto _loop227_breakloop
- :_loop227_breakloop
+ goto _loop259_breakloop
+ :_loop259_breakloop
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_12_)
+ recover(ex,tokenSet_20_)
else:
raise
return e
- public def boolean_term() as Expression : //throws RecognitionException, TokenStreamException
+ public def shift() as Expression : //throws RecognitionException, TokenStreamException
e as Expression
- op as IToken = null
+ sl as IToken = null
+ sr as IToken = null
try: // for error handling
- e=comparison_expression()
+ e=sum()
while true:
- if ((LA(1)==LOGICAL_AND) and (tokenSet_13_.member(cast(int, LA(2))))):
- op = LT(1)
- match(LOGICAL_AND)
- rhs=comparison_expression()
+ if ((LA(1)==SHIFT_LEFT or LA(1)==SHIFT_RIGHT) and (tokenSet_16_.member(cast(int, LA(2))))):
+ _givenValue = LA(1)
+ if ((_givenValue == SHIFT_LEFT)): // 1831
+ sl = LT(1)
+ match(SHIFT_LEFT)
+ if 0 == inputState.guessing:
+ op = BinaryOperatorType.ShiftLeft; token = sl
+ elif ((_givenValue == SHIFT_RIGHT)): // 1831
+ sr = LT(1)
+ match(SHIFT_RIGHT)
+ if 0 == inputState.guessing:
+ op = BinaryOperatorType.ShiftRight; token = sr
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
+ r=sum()
if 0 == inputState.guessing:
- e=BinaryExpression(ToLexicalInfo(op),
- Operator: BinaryOperatorType.And,
- Left: e,
- Right: rhs)
+ e = BinaryExpression(ToLexicalInfo(token), Operator: op, Left: e, Right: r)
else:
- goto _loop230_breakloop
- :_loop230_breakloop
+ goto _loop267_breakloop
+ :_loop267_breakloop
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_12_)
+ recover(ex,tokenSet_20_)
else:
raise
return e
- public def comparison_expression() as Expression : //throws RecognitionException, TokenStreamException
+ public def comparison() as Expression : //throws RecognitionException, TokenStreamException
e as Expression
- te as IToken = null
- ti as IToken = null
+ tni as IToken = null
+ tin as IToken = null
tgt as IToken = null
tgte as IToken = null
tlt as IToken = null
tlte as IToken = null
- re as IToken = null
- rie as IToken = null
- tin as IToken = null
- tnint as IToken = null
tisa as IToken = null
r as Expression
op = BinaryOperatorType.None;
token as IToken
try: // for error handling
- e=sum()
+ e=shift()
while true:
- if ((tokenSet_57_.member(cast(int, LA(1)))) and (tokenSet_58_.member(cast(int, LA(2))))):
+ if ((tokenSet_56_.member(cast(int, LA(1)))) and (tokenSet_57_.member(cast(int, LA(2))))):
_givenValue = LA(1)
- if ((_givenValue == EQUALITY)
- or (_givenValue ==INEQUALITY)
- or (_givenValue ==REFERENCE_EQUALITY)
- or (_givenValue ==REFERENCE_INEQUALITY)
+ if ((_givenValue == IN)
+ or (_givenValue ==NOT)
or (_givenValue ==LESS_THAN)
or (_givenValue ==LESS_THAN_OR_EQUAL)
or (_givenValue ==GREATER_THAN)
or (_givenValue ==GREATER_THAN_OR_EQUAL)
): // 1827
_givenValue = LA(1)
- if ((_givenValue == EQUALITY)): // 1831
- te = LT(1)
- match(EQUALITY)
+ if ((_givenValue == NOT)): // 1831
+ tni = LT(1)
+ match(NOT)
+ match(IN)
if 0 == inputState.guessing:
- op = BinaryOperatorType.Equality; token = te;
- elif ((_givenValue == INEQUALITY)): // 1831
- ti = LT(1)
- match(INEQUALITY)
+ op = BinaryOperatorType.NotMember; token = tni;
+ elif ((_givenValue == IN)): // 1831
+ tin = LT(1)
+ match(IN)
if 0 == inputState.guessing:
- op = BinaryOperatorType.Inequality; token =ti
+ op = BinaryOperatorType.Member; token = tin;
elif ((_givenValue == GREATER_THAN)): // 1831
tgt = LT(1)
match(GREATER_THAN)
@@ -3677,37 +4016,9 @@ class UnityScriptParser(antlr.LLkParser):
match(LESS_THAN_OR_EQUAL)
if 0 == inputState.guessing:
op = BinaryOperatorType.LessThanOrEqual; token = tlte;
- elif ((_givenValue == REFERENCE_EQUALITY)): // 1831
- re = LT(1)
- match(REFERENCE_EQUALITY)
- if 0 == inputState.guessing:
- op = BinaryOperatorType.ReferenceEquality; token = re
- elif ((_givenValue == REFERENCE_INEQUALITY)): // 1831
- rie = LT(1)
- match(REFERENCE_INEQUALITY)
- if 0 == inputState.guessing:
- op = BinaryOperatorType.ReferenceInequality; token = rie
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
- r=sum()
- elif ((_givenValue == IN)
- or (_givenValue ==NOT)
- ): // 1827
- _givenValue = LA(1)
- if ((_givenValue == IN)): // 1831
- tin = LT(1)
- match(IN)
- if 0 == inputState.guessing:
- op = BinaryOperatorType.Member; token = tin;
- elif ((_givenValue == NOT)): // 1831
- tnint = LT(1)
- match(NOT)
- match(IN)
- if 0 == inputState.guessing:
- op = BinaryOperatorType.NotMember; token = tnint;
else: // line 1969
raise NoViableAltException(LT(1), getFilename())
- r=expression()
+ r=shift()
elif ((_givenValue == INSTANCEOF)): // 1831
tisa = LT(1)
match(INSTANCEOF)
@@ -3725,124 +4036,88 @@ class UnityScriptParser(antlr.LLkParser):
be.Right = r
e = be
else:
- goto _loop249_breakloop
- :_loop249_breakloop
+ goto _loop280_breakloop
+ :_loop280_breakloop
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_12_)
+ recover(ex,tokenSet_20_)
else:
raise
return e
- public def term() as Expression : //throws RecognitionException, TokenStreamException
+ public def equality() as Expression : //throws RecognitionException, TokenStreamException
e as Expression
- m as IToken = null
- d as IToken = null
- md as IToken = null
- op = BinaryOperatorType.None
+ te as IToken = null
+ ti as IToken = null
+ re as IToken = null
+ rie as IToken = null
try: // for error handling
- e=factor()
+ e=comparison()
while true:
- if ((LA(1)==MODULUS or LA(1)==MULTIPLY or LA(1)==DIVISION) and (tokenSet_13_.member(cast(int, LA(2))))):
+ if ((tokenSet_58_.member(cast(int, LA(1)))) and (tokenSet_16_.member(cast(int, LA(2))))):
_givenValue = LA(1)
- if ((_givenValue == MULTIPLY)): // 1831
- m = LT(1)
- match(MULTIPLY)
- if 0 == inputState.guessing:
- op=BinaryOperatorType.Multiply; token=m;
- elif ((_givenValue == DIVISION)): // 1831
- d = LT(1)
- match(DIVISION)
+ if ((_givenValue == EQUALITY)): // 1831
+ te = LT(1)
+ match(EQUALITY)
if 0 == inputState.guessing:
- op=BinaryOperatorType.Division; token=d;
- elif ((_givenValue == MODULUS)): // 1831
- md = LT(1)
- match(MODULUS)
+ op = BinaryOperatorType.Equality; token = te;
+ elif ((_givenValue == INEQUALITY)): // 1831
+ ti = LT(1)
+ match(INEQUALITY)
if 0 == inputState.guessing:
- op=BinaryOperatorType.Modulus; token=md;
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
- r=factor()
- if 0 == inputState.guessing:
- be = BinaryExpression(ToLexicalInfo(token))
- be.Operator = op
- be.Left = e
- be.Right = r
- e = be
- else:
- goto _loop257_breakloop
- :_loop257_breakloop
- except ex as RecognitionException:
- if (0 == inputState.guessing):
- reportError(ex)
- recover(ex,tokenSet_12_)
- else:
- raise
- return e
-
- public def factor() as Expression : //throws RecognitionException, TokenStreamException
- e as Expression
-
- sl as IToken = null
- sr as IToken = null
-
- try: // for error handling
- e=bitwise_or()
- while true:
- if ((LA(1)==SHIFT_LEFT or LA(1)==SHIFT_RIGHT) and (tokenSet_13_.member(cast(int, LA(2))))):
- _givenValue = LA(1)
- if ((_givenValue == SHIFT_LEFT)): // 1831
- sl = LT(1)
- match(SHIFT_LEFT)
+ op = BinaryOperatorType.Inequality; token = ti
+ elif ((_givenValue == REFERENCE_EQUALITY)): // 1831
+ re = LT(1)
+ match(REFERENCE_EQUALITY)
if 0 == inputState.guessing:
- op = BinaryOperatorType.ShiftLeft; token = sl
- elif ((_givenValue == SHIFT_RIGHT)): // 1831
- sr = LT(1)
- match(SHIFT_RIGHT)
+ op = BinaryOperatorType.ReferenceEquality; token = re
+ elif ((_givenValue == REFERENCE_INEQUALITY)): // 1831
+ rie = LT(1)
+ match(REFERENCE_INEQUALITY)
if 0 == inputState.guessing:
- op = BinaryOperatorType.ShiftRight; token = sr
+ op = BinaryOperatorType.ReferenceInequality; token = rie
else: // line 1969
raise NoViableAltException(LT(1), getFilename())
- r=bitwise_or()
+ r=comparison()
if 0 == inputState.guessing:
- e = BinaryExpression(ToLexicalInfo(token), Operator: op, Left: e, Right: r)
+ e = BinaryExpression(ToLexicalInfo(token), op, e, r)
else:
- goto _loop261_breakloop
- :_loop261_breakloop
+ goto _loop288_breakloop
+ :_loop288_breakloop
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_12_)
+ recover(ex,tokenSet_20_)
else:
raise
return e
- public def bitwise_or() as Expression : //throws RecognitionException, TokenStreamException
+ public def bitwise_and() as Expression : //throws RecognitionException, TokenStreamException
e as Expression
token as IToken = null
try: // for error handling
- e=bitwise_xor()
+ e=equality()
while true:
- if ((LA(1)==BITWISE_OR) and (tokenSet_13_.member(cast(int, LA(2))))):
+ if ((LA(1)==BITWISE_AND) and (tokenSet_16_.member(cast(int, LA(2))))):
token = LT(1)
- match(BITWISE_OR)
+ match(BITWISE_AND)
if 0 == inputState.guessing:
- op = BinaryOperatorType.BitwiseOr;
- r=bitwise_xor()
+ op = BinaryOperatorType.BitwiseAnd;
+ r=equality()
if 0 == inputState.guessing:
e = BinaryExpression(ToLexicalInfo(token), Operator: op, Left: e, Right: r)
else:
- goto _loop264_breakloop
- :_loop264_breakloop
+ goto _loop291_breakloop
+ :_loop291_breakloop
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_12_)
+ recover(ex,tokenSet_20_)
else:
raise
return e
@@ -3855,7 +4130,7 @@ class UnityScriptParser(antlr.LLkParser):
try: // for error handling
e=bitwise_and()
while true:
- if ((LA(1)==BITWISE_XOR) and (tokenSet_13_.member(cast(int, LA(2))))):
+ if ((LA(1)==BITWISE_XOR) and (tokenSet_16_.member(cast(int, LA(2))))):
token = LT(1)
match(BITWISE_XOR)
if 0 == inputState.guessing:
@@ -3864,204 +4139,125 @@ class UnityScriptParser(antlr.LLkParser):
if 0 == inputState.guessing:
e = BinaryExpression(ToLexicalInfo(token), Operator: op, Left: e, Right: r)
else:
- goto _loop267_breakloop
- :_loop267_breakloop
+ goto _loop294_breakloop
+ :_loop294_breakloop
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_12_)
+ recover(ex,tokenSet_20_)
else:
raise
return e
- public def bitwise_and() as Expression : //throws RecognitionException, TokenStreamException
+ public def bitwise_or() as Expression : //throws RecognitionException, TokenStreamException
e as Expression
token as IToken = null
try: // for error handling
- e=unary_expression()
+ e=bitwise_xor()
while true:
- if ((LA(1)==BITWISE_AND) and (tokenSet_13_.member(cast(int, LA(2))))):
+ if ((LA(1)==BITWISE_OR) and (tokenSet_16_.member(cast(int, LA(2))))):
token = LT(1)
- match(BITWISE_AND)
+ match(BITWISE_OR)
if 0 == inputState.guessing:
- op = BinaryOperatorType.BitwiseAnd;
- r=unary_expression()
+ op = BinaryOperatorType.BitwiseOr;
+ r=bitwise_xor()
if 0 == inputState.guessing:
e = BinaryExpression(ToLexicalInfo(token), Operator: op, Left: e, Right: r)
else:
- goto _loop270_breakloop
- :_loop270_breakloop
+ goto _loop297_breakloop
+ :_loop297_breakloop
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_12_)
+ recover(ex,tokenSet_20_)
else:
raise
return e
- public def unary_expression() as Expression : //throws RecognitionException, TokenStreamException
+ public def logical_and() as Expression : //throws RecognitionException, TokenStreamException
e as Expression
- sub as IToken = null
- inc as IToken = null
- dec as IToken = null
- nt as IToken = null
- oc as IToken = null
- postinc as IToken = null
- preinc as IToken = null
- t as IToken = null
- uOperator = UnaryOperatorType.None
+ op as IToken = null
try: // for error handling
- _givenValue = LA(1)
- if ((_givenValue == NOT)
- or (_givenValue ==INCREMENT)
- or (_givenValue ==DECREMENT)
- or (_givenValue ==SUBTRACT)
- or (_givenValue ==ONES_COMPLEMENT)
- ): // 1827
- _givenValue = LA(1)
- if ((_givenValue == SUBTRACT)): // 1831
- sub = LT(1)
- match(SUBTRACT)
- if 0 == inputState.guessing:
- op = sub; uOperator = UnaryOperatorType.UnaryNegation;
- elif ((_givenValue == INCREMENT)): // 1831
- inc = LT(1)
- match(INCREMENT)
- if 0 == inputState.guessing:
- op = inc; uOperator = UnaryOperatorType.Increment;
- elif ((_givenValue == DECREMENT)): // 1831
- dec = LT(1)
- match(DECREMENT)
- if 0 == inputState.guessing:
- op = dec; uOperator = UnaryOperatorType.Decrement;
- elif ((_givenValue == NOT)): // 1831
- nt = LT(1)
- match(NOT)
- if 0 == inputState.guessing:
- op = nt; uOperator = UnaryOperatorType.LogicalNot;
- elif ((_givenValue == ONES_COMPLEMENT)): // 1831
- oc = LT(1)
- match(ONES_COMPLEMENT)
- if 0 == inputState.guessing:
- op = oc; uOperator = UnaryOperatorType.OnesComplement;
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
- e=slicing_expression()
- elif ((_givenValue == FALSE)
- or (_givenValue ==FUNCTION)
- or (_givenValue ==NEW)
- or (_givenValue ==NULL)
- or (_givenValue ==SUPER)
- or (_givenValue ==THIS)
- or (_givenValue ==TRUE)
- or (_givenValue ==TYPEOF)
- or (_givenValue ==ID)
- or (_givenValue ==DOUBLE_QUOTED_STRING)
- or (_givenValue ==LBRACE)
- or (_givenValue ==LPAREN)
- or (_givenValue ==LBRACK)
- or (_givenValue ==RE_LITERAL)
- or (_givenValue ==DOUBLE)
- or (_givenValue ==INT)
- or (_givenValue ==LONG)
- ): // 1827
- e=slicing_expression()
- if ((LA(1)==INCREMENT) and (tokenSet_12_.member(cast(int, LA(2))))):
- postinc = LT(1)
- match(INCREMENT)
- if 0 == inputState.guessing:
- op = postinc; uOperator = UnaryOperatorType.PostIncrement;
- elif ((LA(1)==DECREMENT) and (tokenSet_12_.member(cast(int, LA(2))))): // line 2102
- preinc = LT(1)
- match(DECREMENT)
+ e=bitwise_or()
+ while true:
+ if ((LA(1)==LOGICAL_AND) and (tokenSet_16_.member(cast(int, LA(2))))):
+ op = LT(1)
+ match(LOGICAL_AND)
+ rhs=bitwise_or()
if 0 == inputState.guessing:
- op = preinc; uOperator= UnaryOperatorType.PostDecrement;
- elif ((tokenSet_12_.member(cast(int, LA(1)))) and (tokenSet_53_.member(cast(int, LA(2))))): // line 2102
- pass // 947
+ e=BinaryExpression(ToLexicalInfo(op),
+ Operator: BinaryOperatorType.And,
+ Left: e,
+ Right: rhs)
else:
- raise NoViableAltException(LT(1), getFilename())
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
- if 0 == inputState.guessing:
- if op is not null:
- ue = UnaryExpression(ToLexicalInfo(op))
- ue.Operator = uOperator
- ue.Operand = e
- e = ue
- if ((LA(1)==AS) and (LA(2)==FUNCTION or LA(2)==ID)):
- t = LT(1)
- match(AS)
- tr=type_reference()
- if 0 == inputState.guessing:
- ae = TryCastExpression(ToLexicalInfo(t), Target: e, Type: tr)
- e = ae
- elif ((tokenSet_12_.member(cast(int, LA(1)))) and (tokenSet_53_.member(cast(int, LA(2))))): // line 2102
- pass // 947
- else:
- raise NoViableAltException(LT(1), getFilename())
+ goto _loop300_breakloop
+ :_loop300_breakloop
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_12_)
+ recover(ex,tokenSet_20_)
else:
raise
return e
- public def slicing_expression() as Expression : //throws RecognitionException, TokenStreamException
+ public def logical_or() as Expression : //throws RecognitionException, TokenStreamException
e as Expression
- lbrack as IToken = null
- lparen as IToken = null
- se as SlicingExpression
- mce as MethodInvocationExpression
- args as ExpressionCollection
- memberName as IToken
+ op as IToken = null
try: // for error handling
- e=atom()
+ e=logical_and()
while true:
- if ((LA(1)==LBRACK) and (tokenSet_59_.member(cast(int, LA(2))))):
- lbrack = LT(1)
- match(LBRACK)
- if 0 == inputState.guessing:
- se = SlicingExpression(ToLexicalInfo(lbrack))
- se.Target = e
- e = se
- slice(se)
- while true:
- if ((LA(1)==COMMA)):
- match(COMMA)
- slice(se)
- else:
- goto _loop282_breakloop
- :_loop282_breakloop
- match(RBRACK)
- elif ((LA(1)==DOT) and (LA(2)==GET or LA(2)==SET or LA(2)==ID)): // line 2102
- match(DOT)
- memberName=member()
- if 0 == inputState.guessing:
- e = MemberReferenceExpression(ToLexicalInfo(memberName), Target: e, Name: memberName.getText())
- elif ((LA(1)==LPAREN) and (tokenSet_60_.member(cast(int, LA(2))))): // line 2102
- lparen = LT(1)
- match(LPAREN)
+ if ((LA(1)==LOGICAL_OR) and (tokenSet_16_.member(cast(int, LA(2))))):
+ op = LT(1)
+ match(LOGICAL_OR)
+ rhs=logical_and()
if 0 == inputState.guessing:
- mce = MethodInvocationExpression(ToLexicalInfo(lparen))
- mce.Target = e
- e = mce
- args = mce.Arguments
- expression_list(args)
- match(RPAREN)
+ e = BinaryExpression(ToLexicalInfo(op),
+ Operator: BinaryOperatorType.Or,
+ Left: e,
+ Right: rhs)
else:
- goto _loop285_breakloop
- :_loop285_breakloop
+ goto _loop303_breakloop
+ :_loop303_breakloop
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_12_)
+ recover(ex,tokenSet_20_)
+ else:
+ raise
+ return e
+
+ public def string_literal() as Expression : //throws RecognitionException, TokenStreamException
+ e as Expression
+
+ dqs as IToken = null
+ sqs as IToken = null
+
+ try: // for error handling
+ _givenValue = LA(1)
+ if ((_givenValue == DOUBLE_QUOTED_STRING)): // 1831
+ dqs = LT(1)
+ match(DOUBLE_QUOTED_STRING)
+ if 0 == inputState.guessing:
+ s = dqs;
+ elif ((_givenValue == SINGLE_QUOTED_STRING)): // 1831
+ sqs = LT(1)
+ match(SINGLE_QUOTED_STRING)
+ if 0 == inputState.guessing:
+ s = sqs;
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
+ if 0 == inputState.guessing:
+ e = StringLiteralExpression(ToLexicalInfo(s), s.getText())
+ except ex as RecognitionException:
+ if (0 == inputState.guessing):
+ reportError(ex)
+ recover(ex,tokenSet_20_)
else:
raise
return e
@@ -4070,19 +4266,62 @@ class UnityScriptParser(antlr.LLkParser):
e as Expression
lbrack as IToken = null
- lle as ListLiteralExpression
try: // for error handling
lbrack = LT(1)
match(LBRACK)
- if 0 == inputState.guessing:
- e = lle = ArrayLiteralExpression(ToLexicalInfo(lbrack))
- expression_list(lle.Items)
+ synPredMatched311 as bool = false
+ if ((tokenSet_16_.member(cast(int, LA(1)))) and (tokenSet_59_.member(cast(int, LA(2))))):
+ _m311 as int = mark()
+ synPredMatched311 = true
+ ++inputState.guessing
+ try:
+ expression()
+ match(FOR)
+ except x as RecognitionException:
+ synPredMatched311 = false
+ rewind(_m311)
+ --inputState.guessing
+ if synPredMatched311:
+ projection=expression()
+ match(FOR)
+ match(LPAREN)
+ _givenValue = LA(1)
+ if ((_givenValue == EACH)
+ or (_givenValue ==FINAL)
+ or (_givenValue ==INTERNAL)
+ or (_givenValue ==ID)
+ ): // 1827
+ id=identifier()
+ elif ((_givenValue == VAR)): // 1831
+ variable=declaration()
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
+ match(IN)
+ iterator=expression()
+ match(RPAREN)
+ _givenValue = LA(1)
+ if ((_givenValue == IF)): // 1831
+ match(IF)
+ filter=expression()
+ elif ((_givenValue == RBRACK)): // 1831
+ pass // 947
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
+ if 0 == inputState.guessing:
+ if id is not null: variable = Declaration(ToLexicalInfo(id), Name: id.getText())
+ e = CodeFactory.NewArrayComprehension(ToLexicalInfo(lbrack), projection, variable, iterator, filter)
+ elif ((tokenSet_60_.member(cast(int, LA(1)))) and (tokenSet_20_.member(cast(int, LA(2))))): // line 2102
+ if 0 == inputState.guessing:
+ e = ale = ArrayLiteralExpression(ToLexicalInfo(lbrack)); items = ale.Items;
+ expression_list(items)
+ else:
+ raise NoViableAltException(LT(1), getFilename())
match(RBRACK)
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_12_)
+ recover(ex,tokenSet_20_)
else:
raise
return e
@@ -4099,10 +4338,10 @@ class UnityScriptParser(antlr.LLkParser):
if 0 == inputState.guessing:
dle = HashLiteralExpression(ToLexicalInfo(lbrace));
_givenValue = LA(1)
- if ((_givenValue == FALSE)
+ if ((_givenValue == EACH)
+ or (_givenValue ==FALSE)
or (_givenValue ==FUNCTION)
or (_givenValue ==NEW)
- or (_givenValue ==NOT)
or (_givenValue ==NULL)
or (_givenValue ==SUPER)
or (_givenValue ==THIS)
@@ -4116,11 +4355,13 @@ class UnityScriptParser(antlr.LLkParser):
or (_givenValue ==INCREMENT)
or (_givenValue ==DECREMENT)
or (_givenValue ==SUBTRACT)
- or (_givenValue ==ONES_COMPLEMENT)
+ or (_givenValue ==BITWISE_NOT)
+ or (_givenValue ==LOGICAL_NOT)
or (_givenValue ==RE_LITERAL)
or (_givenValue ==DOUBLE)
or (_givenValue ==INT)
or (_givenValue ==LONG)
+ or (_givenValue ==SINGLE_QUOTED_STRING)
): // 1827
pair=expression_pair()
if 0 == inputState.guessing:
@@ -4132,8 +4373,8 @@ class UnityScriptParser(antlr.LLkParser):
if 0 == inputState.guessing:
dle.Items.Add(pair);
else:
- goto _loop292_breakloop
- :_loop292_breakloop
+ goto _loop319_breakloop
+ :_loop319_breakloop
elif ((_givenValue == RBRACE)): // 1831
pass // 947
else: // line 1969
@@ -4142,7 +4383,7 @@ class UnityScriptParser(antlr.LLkParser):
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_12_)
+ recover(ex,tokenSet_20_)
else:
raise
return dle
@@ -4160,11 +4401,57 @@ class UnityScriptParser(antlr.LLkParser):
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_12_)
+ recover(ex,tokenSet_20_)
else:
raise
return re
+ public def bool_literal() as BoolLiteralExpression : //throws RecognitionException, TokenStreamException
+ e as BoolLiteralExpression
+
+ t as IToken = null
+ f as IToken = null
+
+ try: // for error handling
+ _givenValue = LA(1)
+ if ((_givenValue == TRUE)): // 1831
+ t = LT(1)
+ match(TRUE)
+ if 0 == inputState.guessing:
+ e = BoolLiteralExpression(ToLexicalInfo(t), Value: true)
+ elif ((_givenValue == FALSE)): // 1831
+ f = LT(1)
+ match(FALSE)
+ if 0 == inputState.guessing:
+ e = BoolLiteralExpression(ToLexicalInfo(f), Value: false)
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
+ except ex as RecognitionException:
+ if (0 == inputState.guessing):
+ reportError(ex)
+ recover(ex,tokenSet_20_)
+ else:
+ raise
+ return e
+
+ public def null_literal() as NullLiteralExpression : //throws RecognitionException, TokenStreamException
+ e as NullLiteralExpression
+
+ t as IToken = null
+
+ try: // for error handling
+ t = LT(1)
+ match(NULL)
+ if 0 == inputState.guessing:
+ e = NullLiteralExpression(ToLexicalInfo(t))
+ except ex as RecognitionException:
+ if (0 == inputState.guessing):
+ reportError(ex)
+ recover(ex,tokenSet_20_)
+ else:
+ raise
+ return e
+
public def self_literal() as SelfLiteralExpression : //throws RecognitionException, TokenStreamException
e as SelfLiteralExpression
@@ -4178,7 +4465,7 @@ class UnityScriptParser(antlr.LLkParser):
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_12_)
+ recover(ex,tokenSet_20_)
else:
raise
return e
@@ -4196,11 +4483,29 @@ class UnityScriptParser(antlr.LLkParser):
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_12_)
+ recover(ex,tokenSet_20_)
else:
raise
return e
+ public def double_literal() as DoubleLiteralExpression : //throws RecognitionException, TokenStreamException
+ rle as DoubleLiteralExpression
+
+ value as IToken = null
+
+ try: // for error handling
+ value = LT(1)
+ match(DOUBLE)
+ if 0 == inputState.guessing:
+ rle = CodeFactory.NewDoubleLiteralExpression(ToLexicalInfo(value), value.getText())
+ except ex as RecognitionException:
+ if (0 == inputState.guessing):
+ reportError(ex)
+ recover(ex,tokenSet_20_)
+ else:
+ raise
+ return rle
+
public def expression_pair() as ExpressionPair : //throws RecognitionException, TokenStreamException
ep as ExpressionPair
@@ -4216,7 +4521,7 @@ class UnityScriptParser(antlr.LLkParser):
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_46_)
+ recover(ex,tokenSet_40_)
else:
raise
return ep
@@ -4229,10 +4534,13 @@ class UnityScriptParser(antlr.LLkParser):
'NULL_TREE_LOOKAHEAD',
'as',
'break',
+ 'cast',
'catch',
'class',
'continue',
+ 'do',
'else',
+ 'each',
'enum',
'extends',
'false',
@@ -4256,7 +4564,6 @@ class UnityScriptParser(antlr.LLkParser):
'internal',
'override',
'partial',
- 'pragma',
'private',
'set',
'static',
@@ -4277,6 +4584,9 @@ class UnityScriptParser(antlr.LLkParser):
'+=',
'-=',
'*=',
+ '//',
+ 'pragma on',
+ 'pragma off',
'an identifier',
'a string',
'{',
@@ -4319,16 +4629,18 @@ class UnityScriptParser(antlr.LLkParser):
'>>=',
'@',
'@script',
- 'HASH',
+ '@assembly',
'INPLACE_BITWISE_XOR',
- 'EXCLUSIVE_OR',
+ 'LOGICAL_NOT',
'DIVISION',
'RE_LITERAL',
'DOUBLE',
'INT',
'LONG',
+ 'SINGLE_QUOTED_STRING',
'DOUBLE_SUFFIX',
'EXPONENT',
+ 'PRAGMA_WHITE_SPACE',
'WHITE_SPACE',
'DQS_ESC',
'SQS_ESC',
@@ -4343,19 +4655,19 @@ class UnityScriptParser(antlr.LLkParser):
)
private static def mk_tokenSet_0_() as (long):
- data = (26480356697216L, 2147483648L, 0L, 0L, )
+ data = (105946139926784L, 0L, )
return data
public static final tokenSet_0_ = BitSet(mk_tokenSet_0_())
private static def mk_tokenSet_1_() as (long):
- data = (18040874567016576L, 0L, )
+ data = (576566835883356416L, 0L, )
return data
public static final tokenSet_1_ = BitSet(mk_tokenSet_1_())
private static def mk_tokenSet_2_() as (long):
- data = (-8808777125532937952L, 1030792686592L, 0L, 0L, )
+ data = (-5187091650136205792L, 68719493881872L, 0L, 0L, )
return data
public static final tokenSet_2_ = BitSet(mk_tokenSet_2_())
private static def mk_tokenSet_3_() as (long):
- data = (-7494834249973500494L, 1095216660479L, 0L, 0L, )
+ data = (-507780875178625166L, 70162585747442L, 0L, 0L, )
return data
public static final tokenSet_3_ = BitSet(mk_tokenSet_3_())
private static def mk_tokenSet_4_() as (long):
@@ -4363,227 +4675,227 @@ class UnityScriptParser(antlr.LLkParser):
return data
public static final tokenSet_4_ = BitSet(mk_tokenSet_4_())
private static def mk_tokenSet_5_() as (long):
- data = (-8808759441268804190L, 1038308879360L, 0L, 0L, )
+ data = (-4754675324137130206L, 68753853620240L, 0L, 0L, )
return data
public static final tokenSet_5_ = BitSet(mk_tokenSet_5_())
private static def mk_tokenSet_6_() as (long):
- data = (26482520958080L, 2147483648L, 0L, 0L, )
+ data = (576566715757441280L, 0L, )
return data
public static final tokenSet_6_ = BitSet(mk_tokenSet_6_())
private static def mk_tokenSet_7_() as (long):
- data = (-8808759441269328478L, 1034013912064L, 0L, 0L, )
+ data = (105911746101248L, 0L, )
return data
public static final tokenSet_7_ = BitSet(mk_tokenSet_7_())
private static def mk_tokenSet_8_() as (long):
- data = (6341068275337658368L, 2L, 0L, 0L, )
+ data = (576566664049528832L, 0L, )
return data
public static final tokenSet_8_ = BitSet(mk_tokenSet_8_())
private static def mk_tokenSet_9_() as (long):
- data = (306249172707770368L, 0L, )
+ data = (576460760893427712L, 0L, )
return data
public static final tokenSet_9_ = BitSet(mk_tokenSet_9_())
private static def mk_tokenSet_10_() as (long):
- data = (-2467966685806522368L, 1030792686592L, 0L, 0L, )
+ data = (70761767837952L, 0L, )
return data
public static final tokenSet_10_ = BitSet(mk_tokenSet_10_())
private static def mk_tokenSet_11_() as (long):
- data = (5188146770730811392L, 0L, )
+ data = (576531651511267584L, 0L, )
return data
public static final tokenSet_11_ = BitSet(mk_tokenSet_11_())
private static def mk_tokenSet_12_() as (long):
- data = (-42951378958L, 1095216660479L, 0L, 0L, )
+ data = (-5187020888368892126L, 68753853620240L, 0L, 0L, )
return data
public static final tokenSet_12_ = BitSet(mk_tokenSet_12_())
private static def mk_tokenSet_13_() as (long):
- data = (-8809034961144180736L, 1030792686592L, 0L, 0L, )
+ data = (-575405631708817888L, 68719493881872L, 0L, 0L, )
return data
public static final tokenSet_13_ = BitSet(mk_tokenSet_13_())
private static def mk_tokenSet_14_() as (long):
- data = (5188146770730811392L, 2L, 0L, 0L, )
+ data = (-504403175457964046L, 70162585747442L, 0L, 0L, )
return data
public static final tokenSet_14_ = BitSet(mk_tokenSet_14_())
private static def mk_tokenSet_15_() as (long):
- data = (5476377146882523136L, 514L, 0L, 0L, )
+ data = (-571957170220843102L, 68753853620240L, 0L, 0L, )
return data
public static final tokenSet_15_ = BitSet(mk_tokenSet_15_())
private static def mk_tokenSet_16_() as (long):
- data = (342279069305475072L, 962072674304L, 0L, 0L, )
+ data = (-5188123130559164416L, 68719493873680L, 0L, 0L, )
return data
public static final tokenSet_16_ = BitSet(mk_tokenSet_16_())
private static def mk_tokenSet_17_() as (long):
- data = (-2467966685806522368L, 1030792686594L, 0L, 0L, )
+ data = (-576437111779454896L, 69835094465403L, 0L, 0L, )
return data
public static final tokenSet_17_ = BitSet(mk_tokenSet_17_())
private static def mk_tokenSet_18_() as (long):
- data = (26482520958080L, 3221225472L, 0L, 0L, )
+ data = (0L, 9L, 0L, 0L, )
return data
public static final tokenSet_18_ = BitSet(mk_tokenSet_18_())
private static def mk_tokenSet_19_() as (long):
- data = (918739821608898560L, 962072674304L, 0L, 0L, )
+ data = (-9223372036854775808L, 16384L, 0L, 0L, )
return data
public static final tokenSet_19_ = BitSet(mk_tokenSet_19_())
private static def mk_tokenSet_20_() as (long):
- data = (-8808759439121844830L, 1034013912064L, 0L, 0L, )
+ data = (-504403158278094862L, 70162585747455L, 0L, 0L, )
return data
public static final tokenSet_20_ = BitSet(mk_tokenSet_20_())
private static def mk_tokenSet_21_() as (long):
- data = (-7494834213466147406L, 1095216660479L, 0L, 0L, )
+ data = (576566715757441280L, 34359738368L, 0L, 0L, )
return data
public static final tokenSet_21_ = BitSet(mk_tokenSet_21_())
private static def mk_tokenSet_22_() as (long):
- data = (-42949806094L, 1099511627775L, 0L, 0L, )
+ data = (-5188123130559164416L, 68719493873681L, 0L, 0L, )
return data
public static final tokenSet_22_ = BitSet(mk_tokenSet_22_())
private static def mk_tokenSet_23_() as (long):
- data = (26478221795328L, 1073741824L, 0L, 0L, )
+ data = (-4754675306957261022L, 68753853620240L, 0L, 0L, )
return data
public static final tokenSet_23_ = BitSet(mk_tokenSet_23_())
private static def mk_tokenSet_24_() as (long):
- data = (26478221795328L, 0L, )
+ data = (-75435293766994062L, 70162585747455L, 0L, 0L, )
return data
public static final tokenSet_24_ = BitSet(mk_tokenSet_24_())
private static def mk_tokenSet_25_() as (long):
- data = (18040911091146752L, 0L, )
+ data = (-72057594037944334L, 70162585747455L, 0L, 0L, )
return data
public static final tokenSet_25_ = BitSet(mk_tokenSet_25_())
private static def mk_tokenSet_26_() as (long):
- data = (18014432869359616L, 0L, )
+ data = (35218765914368L, 0L, )
return data
public static final tokenSet_26_ = BitSet(mk_tokenSet_26_())
private static def mk_tokenSet_27_() as (long):
- data = (26476057468928L, 0L, )
+ data = (-139611588809211998L, 68753853620240L, 0L, 0L, )
return data
public static final tokenSet_27_ = BitSet(mk_tokenSet_27_())
private static def mk_tokenSet_28_() as (long):
- data = (18040874566950912L, 0L, )
+ data = (-72057594046332942L, 70162585747455L, 0L, 0L, )
return data
public static final tokenSet_28_ = BitSet(mk_tokenSet_28_())
private static def mk_tokenSet_29_() as (long):
- data = (17679964512256L, 0L, )
+ data = (105963454013696L, 34359738368L, 0L, 0L, )
return data
public static final tokenSet_29_ = BitSet(mk_tokenSet_29_())
private static def mk_tokenSet_30_() as (long):
- data = (18032078473994240L, 0L, )
+ data = (105963454013696L, 0L, )
return data
public static final tokenSet_30_ = BitSet(mk_tokenSet_30_())
private static def mk_tokenSet_31_() as (long):
- data = (8796093087744L, 0L, )
+ data = (576566853197443328L, 0L, )
return data
public static final tokenSet_31_ = BitSet(mk_tokenSet_31_())
private static def mk_tokenSet_32_() as (long):
- data = (-8663799828263340062L, 1034013912320L, 0L, 0L, )
+ data = (576460898333430016L, 0L, )
return data
public static final tokenSet_32_ = BitSet(mk_tokenSet_32_())
private static def mk_tokenSet_33_() as (long):
- data = (-8663799826115332126L, 1038308879616L, 0L, 0L, )
+ data = (-575334852761635038L, 68753853620240L, 0L, 0L, )
return data
public static final tokenSet_33_ = BitSet(mk_tokenSet_33_())
private static def mk_tokenSet_34_() as (long):
- data = (-1574926L, 1095216660479L, 0L, 0L, )
+ data = (576460760893427712L, 34359738368L, 0L, 0L, )
return data
public static final tokenSet_34_ = BitSet(mk_tokenSet_34_())
private static def mk_tokenSet_35_() as (long):
- data = (-8664644251045988958L, 1034013912064L, 0L, 0L, )
+ data = (-504403158269706254L, 70162585747455L, 0L, 0L, )
return data
public static final tokenSet_35_ = BitSet(mk_tokenSet_35_())
private static def mk_tokenSet_36_() as (long):
- data = (-8809026165051158528L, 1030792686848L, 0L, 0L, )
+ data = (2305843009213693952L, 2147483648L, 0L, 0L, )
return data
public static final tokenSet_36_ = BitSet(mk_tokenSet_36_())
private static def mk_tokenSet_37_() as (long):
- data = (-7495109769848352752L, 1091995435007L, 0L, 0L, )
+ data = (4611686018427912192L, 34359738368L, 0L, 0L, )
return data
public static final tokenSet_37_ = BitSet(mk_tokenSet_37_())
private static def mk_tokenSet_38_() as (long):
- data = (-8808777125532937952L, 1030792686848L, 0L, 0L, )
+ data = (-571957153024196702L, 68753853636637L, 0L, 0L, )
return data
public static final tokenSet_38_ = BitSet(mk_tokenSet_38_())
private static def mk_tokenSet_39_() as (long):
- data = (-7510878323646007310L, 1086056299995L, 0L, 0L, )
+ data = (0L, 1L, 0L, 0L, )
return data
public static final tokenSet_39_ = BitSet(mk_tokenSet_39_())
private static def mk_tokenSet_40_() as (long):
- data = (-42950330382L, 1095216660479L, 0L, 0L, )
+ data = (4611686018427387904L, 8L, 0L, 0L, )
return data
public static final tokenSet_40_ = BitSet(mk_tokenSet_40_())
private static def mk_tokenSet_41_() as (long):
- data = (-8590460942L, 1095216660479L, 0L, 0L, )
+ data = (-571957153040973918L, 68753853620240L, 0L, 0L, )
return data
public static final tokenSet_41_ = BitSet(mk_tokenSet_41_())
private static def mk_tokenSet_42_() as (long):
- data = (72057594037927936L, 67108864L, 0L, 0L, )
+ data = (576460889743429632L, 0L, )
return data
public static final tokenSet_42_ = BitSet(mk_tokenSet_42_())
private static def mk_tokenSet_43_() as (long):
- data = (144141666297651200L, 1073741824L, 0L, 0L, )
+ data = (-5187091787576207840L, 68719493873680L, 0L, 0L, )
return data
public static final tokenSet_43_ = BitSet(mk_tokenSet_43_())
private static def mk_tokenSet_44_() as (long):
- data = (144115188075921408L, 1073741824L, 0L, 0L, )
+ data = (-575405631356496272L, 69835094473594L, 0L, 0L, )
return data
public static final tokenSet_44_ = BitSet(mk_tokenSet_44_())
private static def mk_tokenSet_45_() as (long):
- data = (576460752303423488L, 0L, )
+ data = (576495945265516544L, 0L, )
return data
public static final tokenSet_45_ = BitSet(mk_tokenSet_45_())
private static def mk_tokenSet_46_() as (long):
- data = (4755801206503243776L, 0L, )
+ data = (576460760910204928L, 0L, )
return data
public static final tokenSet_46_ = BitSet(mk_tokenSet_46_())
private static def mk_tokenSet_47_() as (long):
- data = (-6358801241832295006L, 1034013912832L, 0L, 0L, )
+ data = (-5188087946187075584L, 68719493881872L, 0L, 0L, )
return data
public static final tokenSet_47_ = BitSet(mk_tokenSet_47_())
private static def mk_tokenSet_48_() as (long):
- data = (-8663799826115856414L, 1034013912320L, 0L, 0L, )
+ data = (-508883108778897328L, 70128226009074L, 0L, 0L, )
return data
public static final tokenSet_48_ = BitSet(mk_tokenSet_48_())
private static def mk_tokenSet_49_() as (long):
- data = (-8664661937457082080L, 1030792686848L, 0L, 0L, )
+ data = (-571957169868521486L, 69869454211954L, 0L, 0L, )
return data
public static final tokenSet_49_ = BitSet(mk_tokenSet_49_())
private static def mk_tokenSet_50_() as (long):
- data = (-7493989825043367950L, 1095216660479L, 0L, 0L, )
+ data = (-571957170204065886L, 68753853636624L, 0L, 0L, )
return data
public static final tokenSet_50_ = BitSet(mk_tokenSet_50_())
private static def mk_tokenSet_51_() as (long):
- data = (-8663799828261242910L, 1034013912832L, 0L, 0L, )
+ data = (-571957170220843102L, 68753853620241L, 0L, 0L, )
return data
public static final tokenSet_51_ = BitSet(mk_tokenSet_51_())
private static def mk_tokenSet_52_() as (long):
- data = (-8087339075959916574L, 1034013912320L, 0L, 0L, )
+ data = (2305843009213693952L, 33L, 0L, 0L, )
return data
public static final tokenSet_52_ = BitSet(mk_tokenSet_52_())
private static def mk_tokenSet_53_() as (long):
- data = (-8591509518L, 1095216660479L, 0L, 0L, )
+ data = (0L, 40L, 0L, 0L, )
return data
public static final tokenSet_53_ = BitSet(mk_tokenSet_53_())
private static def mk_tokenSet_54_() as (long):
- data = (0L, 17179881474L, 0L, 0L, )
+ data = (-5188123130559164416L, 68719493873684L, 0L, 0L, )
return data
public static final tokenSet_54_ = BitSet(mk_tokenSet_54_())
private static def mk_tokenSet_55_() as (long):
- data = (576460752303423488L, 1L, 0L, 0L, )
+ data = (576460889743429632L, 134217728L, 0L, 0L, )
return data
public static final tokenSet_55_ = BitSet(mk_tokenSet_55_())
private static def mk_tokenSet_56_() as (long):
- data = (4611686018427387904L, 1L, 0L, 0L, )
+ data = (352321536L, 6845104128L, 0L, 0L, )
return data
public static final tokenSet_56_ = BitSet(mk_tokenSet_56_())
private static def mk_tokenSet_57_() as (long):
- data = (44040192L, 217251840L, 0L, 0L, )
+ data = (-5188123130542387200L, 68719493873680L, 0L, 0L, )
return data
public static final tokenSet_57_ = BitSet(mk_tokenSet_57_())
private static def mk_tokenSet_58_() as (long):
- data = (-8809034961142083584L, 1030792686592L, 0L, 0L, )
+ data = (0L, 106954752L, 0L, 0L, )
return data
public static final tokenSet_58_ = BitSet(mk_tokenSet_58_())
private static def mk_tokenSet_59_() as (long):
- data = (-6503191951930486784L, 1030792686592L, 0L, 0L, )
+ data = (-576437111779192752L, 69835094465394L, 0L, 0L, )
return data
public static final tokenSet_59_ = BitSet(mk_tokenSet_59_())
private static def mk_tokenSet_60_() as (long):
- data = (-8232574208840757248L, 1030792686592L, 0L, 0L, )
+ data = (-5188123130559164416L, 68719493873712L, 0L, 0L, )
return data
public static final tokenSet_60_ = BitSet(mk_tokenSet_60_())
diff --git a/src/UnityScript/Parser/UnityScriptParserExtensions.boo b/src/UnityScript/Parser/UnityScriptParserExtensions.boo
new file mode 100755
index 0000000..c884552
--- /dev/null
+++ b/src/UnityScript/Parser/UnityScriptParserExtensions.boo
@@ -0,0 +1,61 @@
+namespace UnityScript.Parser
+
+import System.IO
+import Boo.Lang.Compiler
+import Boo.Lang.Compiler.Ast
+import PatternMatching
+
+partial class UnityScriptParser:
+
+ static def ParseReader(reader as TextReader, fileName as string, context as CompilerContext, targetCompileUnit as CompileUnit):
+ lexer = UnityScriptLexerFor(reader, fileName, TabSizeFromContext(context))
+ if lexer is null:
+ targetCompileUnit.Modules.Add(CodeFactory.NewModule(fileName))
+ return
+
+ parser = UnityScriptParser(lexer, CompilerContext: context)
+ parser.setFilename(fileName)
+
+ try:
+ parser.start(targetCompileUnit)
+ except x as antlr.TokenStreamRecognitionException:
+ parser.reportError(x.recog)
+
+ static def ParseExpression(expression as string, fileName as string, context as CompilerContext):
+ return ParseExpression(StringReader(expression), fileName, context)
+
+ static def ParseExpression(expression as TextReader, fileName as string, context as CompilerContext):
+ """
+ if the expression reader is empty returns null.
+
+ Otherwise tries to parse an expression reporting errors in the compiler context passed as argument.
+ """
+ lexer = UnityScriptLexerFor(expression, fileName, TabSizeFromContext(context))
+ if lexer is null:
+ return null
+
+ parser = UnityScriptParser(lexer, CompilerContext: context)
+ parser.setFilename(fileName)
+
+ try:
+ return parser.expression()
+ except x as antlr.TokenStreamRecognitionException:
+ parser.reportError(x.recog)
+
+ static def UnityScriptLexerFor(reader as TextReader, fileName as string, tabSize as int):
+ if reader.Peek() == -1:
+ return null
+
+ lexer = UnityScriptLexer(reader)
+ lexer.setFilename(fileName)
+ lexer.setTokenCreator(Boo.Lang.Parser.BooToken.BooTokenCreator())
+ lexer.setTabSize(tabSize)
+ return lexer
+
+ static def TabSizeFromContext(context as CompilerContext):
+ match context:
+ case CompilerContext(Parameters: UnityScriptCompilerParameters(TabSize: t)):
+ return t
+ otherwise:
+ return UnityScriptCompilerParameters.DefaultTabSize
+
\ No newline at end of file
diff --git a/src/UnityScript/Parser/UnityScriptTokenTypes.boo b/src/UnityScript/Parser/UnityScriptTokenTypes.boo
index d45c730..9b0bcc3 100644
--- a/src/UnityScript/Parser/UnityScriptTokenTypes.boo
+++ b/src/UnityScript/Parser/UnityScriptTokenTypes.boo
@@ -6,115 +6,122 @@ class UnityScriptTokenTypes:
public static final NULL_TREE_LOOKAHEAD = 3
public static final AS = 4
public static final BREAK = 5
- public static final CATCH = 6
- public static final CLASS = 7
- public static final CONTINUE = 8
- public static final ELSE = 9
- public static final ENUM = 10
- public static final EXTENDS = 11
- public static final FALSE = 12
- public static final FINAL = 13
- public static final FINALLY = 14
- public static final FOR = 15
- public static final FUNCTION = 16
- public static final GET = 17
- public static final IF = 18
- public static final IMPORT = 19
- public static final IMPLEMENTS = 20
- public static final IN = 21
- public static final INTERFACE = 22
- public static final INSTANCEOF = 23
- public static final NEW = 24
- public static final NOT = 25
- public static final NULL = 26
- public static final RETURN = 27
- public static final PUBLIC = 28
- public static final PROTECTED = 29
- public static final INTERNAL = 30
- public static final OVERRIDE = 31
- public static final PARTIAL = 32
- public static final PRAGMA = 33
- public static final PRIVATE = 34
- public static final SET = 35
- public static final STATIC = 36
- public static final SUPER = 37
- public static final THIS = 38
- public static final THROW = 39
- public static final TRUE = 40
- public static final TRY = 41
- public static final TYPEOF = 42
- public static final VAR = 43
- public static final VIRTUAL = 44
- public static final WHILE = 45
- public static final YIELD = 46
- public static final SWITCH = 47
- public static final CASE = 48
- public static final DEFAULT = 49
- public static final INPLACE_DIVISION = 50
- public static final INPLACE_ADD = 51
- public static final INPLACE_SUBTRACT = 52
- public static final INPLACE_MULTIPLY = 53
- public static final ID = 54
- public static final DOUBLE_QUOTED_STRING = 55
- public static final LBRACE = 56
- public static final RBRACE = 57
- public static final LPAREN = 58
- public static final RPAREN = 59
- public static final DOT = 60
- public static final COLON = 61
- public static final COMMA = 62
- public static final LBRACK = 63
- public static final RBRACK = 64
- public static final BITWISE_OR = 65
- public static final INPLACE_BITWISE_OR = 66
- public static final BITWISE_AND = 67
- public static final BITWISE_XOR = 68
- public static final INPLACE_BITWISE_AND = 69
- public static final LOGICAL_OR = 70
- public static final LOGICAL_AND = 71
- public static final EOS = 72
- public static final ASSIGN = 73
- public static final INCREMENT = 74
- public static final DECREMENT = 75
- public static final ADD = 76
- public static final SUBTRACT = 77
- public static final MODULUS = 78
- public static final MULTIPLY = 79
- public static final EQUALITY = 80
- public static final INEQUALITY = 81
- public static final QUESTION_MARK = 82
- public static final ONES_COMPLEMENT = 83
- public static final REFERENCE_EQUALITY = 84
- public static final REFERENCE_INEQUALITY = 85
- public static final LESS_THAN = 86
- public static final LESS_THAN_OR_EQUAL = 87
- public static final SHIFT_LEFT = 88
- public static final INPLACE_SHIFT_LEFT = 89
- public static final GREATER_THAN = 90
- public static final GREATER_THAN_OR_EQUAL = 91
- public static final SHIFT_RIGHT = 92
- public static final INPLACE_SHIFT_RIGHT = 93
- public static final AT = 94
- public static final SCRIPT_ATTRIBUTE_MARKER = 95
- public static final HASH = 96
- public static final INPLACE_BITWISE_XOR = 97
- public static final EXCLUSIVE_OR = 98
- public static final DIVISION = 99
- public static final RE_LITERAL = 100
- public static final DOUBLE = 101
- public static final INT = 102
- public static final LONG = 103
- public static final DOUBLE_SUFFIX = 104
- public static final EXPONENT = 105
- public static final WHITE_SPACE = 106
- public static final DQS_ESC = 107
- public static final SQS_ESC = 108
- public static final SESC = 109
- public static final ML_COMMENT = 110
- public static final RE_CHAR = 111
- public static final RE_ESC = 112
- public static final NEWLINE = 113
- public static final ID_LETTER = 114
- public static final DIGIT = 115
- public static final HEXDIGIT = 116
+ public static final CAST = 6
+ public static final CATCH = 7
+ public static final CLASS = 8
+ public static final CONTINUE = 9
+ public static final DO = 10
+ public static final ELSE = 11
+ public static final EACH = 12
+ public static final ENUM = 13
+ public static final EXTENDS = 14
+ public static final FALSE = 15
+ public static final FINAL = 16
+ public static final FINALLY = 17
+ public static final FOR = 18
+ public static final FUNCTION = 19
+ public static final GET = 20
+ public static final IF = 21
+ public static final IMPORT = 22
+ public static final IMPLEMENTS = 23
+ public static final IN = 24
+ public static final INTERFACE = 25
+ public static final INSTANCEOF = 26
+ public static final NEW = 27
+ public static final NOT = 28
+ public static final NULL = 29
+ public static final RETURN = 30
+ public static final PUBLIC = 31
+ public static final PROTECTED = 32
+ public static final INTERNAL = 33
+ public static final OVERRIDE = 34
+ public static final PARTIAL = 35
+ public static final PRIVATE = 36
+ public static final SET = 37
+ public static final STATIC = 38
+ public static final SUPER = 39
+ public static final THIS = 40
+ public static final THROW = 41
+ public static final TRUE = 42
+ public static final TRY = 43
+ public static final TYPEOF = 44
+ public static final VAR = 45
+ public static final VIRTUAL = 46
+ public static final WHILE = 47
+ public static final YIELD = 48
+ public static final SWITCH = 49
+ public static final CASE = 50
+ public static final DEFAULT = 51
+ public static final INPLACE_DIVISION = 52
+ public static final INPLACE_ADD = 53
+ public static final INPLACE_SUBTRACT = 54
+ public static final INPLACE_MULTIPLY = 55
+ public static final SL_COMMENT = 56
+ public static final PRAGMA_ON = 57
+ public static final PRAGMA_OFF = 58
+ public static final ID = 59
+ public static final DOUBLE_QUOTED_STRING = 60
+ public static final LBRACE = 61
+ public static final RBRACE = 62
+ public static final LPAREN = 63
+ public static final RPAREN = 64
+ public static final DOT = 65
+ public static final COLON = 66
+ public static final COMMA = 67
+ public static final LBRACK = 68
+ public static final RBRACK = 69
+ public static final BITWISE_OR = 70
+ public static final INPLACE_BITWISE_OR = 71
+ public static final BITWISE_AND = 72
+ public static final BITWISE_XOR = 73
+ public static final INPLACE_BITWISE_AND = 74
+ public static final LOGICAL_OR = 75
+ public static final LOGICAL_AND = 76
+ public static final EOS = 77
+ public static final ASSIGN = 78
+ public static final INCREMENT = 79
+ public static final DECREMENT = 80
+ public static final ADD = 81
+ public static final SUBTRACT = 82
+ public static final MODULUS = 83
+ public static final MULTIPLY = 84
+ public static final EQUALITY = 85
+ public static final INEQUALITY = 86
+ public static final QUESTION_MARK = 87
+ public static final BITWISE_NOT = 88
+ public static final REFERENCE_EQUALITY = 89
+ public static final REFERENCE_INEQUALITY = 90
+ public static final LESS_THAN = 91
+ public static final LESS_THAN_OR_EQUAL = 92
+ public static final SHIFT_LEFT = 93
+ public static final INPLACE_SHIFT_LEFT = 94
+ public static final GREATER_THAN = 95
+ public static final GREATER_THAN_OR_EQUAL = 96
+ public static final SHIFT_RIGHT = 97
+ public static final INPLACE_SHIFT_RIGHT = 98
+ public static final AT = 99
+ public static final SCRIPT_ATTRIBUTE_MARKER = 100
+ public static final ASSEMBLY_ATTRIBUTE_MARKER = 101
+ public static final INPLACE_BITWISE_XOR = 102
+ public static final LOGICAL_NOT = 103
+ public static final DIVISION = 104
+ public static final RE_LITERAL = 105
+ public static final DOUBLE = 106
+ public static final INT = 107
+ public static final LONG = 108
+ public static final SINGLE_QUOTED_STRING = 109
+ public static final DOUBLE_SUFFIX = 110
+ public static final EXPONENT = 111
+ public static final PRAGMA_WHITE_SPACE = 112
+ public static final WHITE_SPACE = 113
+ public static final DQS_ESC = 114
+ public static final SQS_ESC = 115
+ public static final SESC = 116
+ public static final ML_COMMENT = 117
+ public static final RE_CHAR = 118
+ public static final RE_ESC = 119
+ public static final NEWLINE = 120
+ public static final ID_LETTER = 121
+ public static final DIGIT = 122
+ public static final HEXDIGIT = 123
diff --git a/src/UnityScript/Parser/UnityScriptTokenTypes.txt b/src/UnityScript/Parser/UnityScriptTokenTypes.txt
index cc6f6ed..0fb8c44 100644
--- a/src/UnityScript/Parser/UnityScriptTokenTypes.txt
+++ b/src/UnityScript/Parser/UnityScriptTokenTypes.txt
@@ -2,114 +2,121 @@
UnityScript // output token vocab name
AS="as"=4
BREAK="break"=5
-CATCH="catch"=6
-CLASS="class"=7
-CONTINUE="continue"=8
-ELSE="else"=9
-ENUM="enum"=10
-EXTENDS="extends"=11
-FALSE="false"=12
-FINAL="final"=13
-FINALLY="finally"=14
-FOR="for"=15
-FUNCTION="function"=16
-GET="get"=17
-IF="if"=18
-IMPORT="import"=19
-IMPLEMENTS="implements"=20
-IN="in"=21
-INTERFACE="interface"=22
-INSTANCEOF="instanceof"=23
-NEW="new"=24
-NOT="not"=25
-NULL="null"=26
-RETURN="return"=27
-PUBLIC="public"=28
-PROTECTED="protected"=29
-INTERNAL="internal"=30
-OVERRIDE="override"=31
-PARTIAL="partial"=32
-PRAGMA="pragma"=33
-PRIVATE="private"=34
-SET="set"=35
-STATIC="static"=36
-SUPER="super"=37
-THIS="this"=38
-THROW="throw"=39
-TRUE="true"=40
-TRY="try"=41
-TYPEOF="typeof"=42
-VAR="var"=43
-VIRTUAL="virtual"=44
-WHILE="while"=45
-YIELD="yield"=46
-SWITCH="switch"=47
-CASE="case"=48
-DEFAULT="default"=49
-INPLACE_DIVISION="/="=50
-INPLACE_ADD="+="=51
-INPLACE_SUBTRACT="-="=52
-INPLACE_MULTIPLY="*="=53
-ID="an identifier"=54
-DOUBLE_QUOTED_STRING="a string"=55
-LBRACE="{"=56
-RBRACE="}"=57
-LPAREN="("=58
-RPAREN=")"=59
-DOT="."=60
-COLON=":"=61
-COMMA=","=62
-LBRACK="["=63
-RBRACK="]"=64
-BITWISE_OR="|"=65
-INPLACE_BITWISE_OR="|="=66
-BITWISE_AND="&"=67
-BITWISE_XOR="^"=68
-INPLACE_BITWISE_AND="&="=69
-LOGICAL_OR="||"=70
-LOGICAL_AND="&&"=71
-EOS=";"=72
-ASSIGN="="=73
-INCREMENT="++"=74
-DECREMENT="--"=75
-ADD="+"=76
-SUBTRACT="-"=77
-MODULUS="%"=78
-MULTIPLY="*"=79
-EQUALITY="=="=80
-INEQUALITY="!="=81
-QUESTION_MARK="?"=82
-ONES_COMPLEMENT="~"=83
-REFERENCE_EQUALITY="==="=84
-REFERENCE_INEQUALITY="!=="=85
-LESS_THAN="<"=86
-LESS_THAN_OR_EQUAL="<="=87
-SHIFT_LEFT="<<"=88
-INPLACE_SHIFT_LEFT="<<="=89
-GREATER_THAN=">"=90
-GREATER_THAN_OR_EQUAL=">="=91
-SHIFT_RIGHT=">>"=92
-INPLACE_SHIFT_RIGHT=">>="=93
-AT="@"=94
-SCRIPT_ATTRIBUTE_MARKER="@script"=95
-HASH=96
-INPLACE_BITWISE_XOR=97
-EXCLUSIVE_OR=98
-DIVISION=99
-RE_LITERAL=100
-DOUBLE=101
-INT=102
-LONG=103
-DOUBLE_SUFFIX=104
-EXPONENT=105
-WHITE_SPACE=106
-DQS_ESC=107
-SQS_ESC=108
-SESC=109
-ML_COMMENT=110
-RE_CHAR=111
-RE_ESC=112
-NEWLINE=113
-ID_LETTER=114
-DIGIT=115
-HEXDIGIT=116
+CAST="cast"=6
+CATCH="catch"=7
+CLASS="class"=8
+CONTINUE="continue"=9
+DO="do"=10
+ELSE="else"=11
+EACH="each"=12
+ENUM="enum"=13
+EXTENDS="extends"=14
+FALSE="false"=15
+FINAL="final"=16
+FINALLY="finally"=17
+FOR="for"=18
+FUNCTION="function"=19
+GET="get"=20
+IF="if"=21
+IMPORT="import"=22
+IMPLEMENTS="implements"=23
+IN="in"=24
+INTERFACE="interface"=25
+INSTANCEOF="instanceof"=26
+NEW="new"=27
+NOT="not"=28
+NULL="null"=29
+RETURN="return"=30
+PUBLIC="public"=31
+PROTECTED="protected"=32
+INTERNAL="internal"=33
+OVERRIDE="override"=34
+PARTIAL="partial"=35
+PRIVATE="private"=36
+SET="set"=37
+STATIC="static"=38
+SUPER="super"=39
+THIS="this"=40
+THROW="throw"=41
+TRUE="true"=42
+TRY="try"=43
+TYPEOF="typeof"=44
+VAR="var"=45
+VIRTUAL="virtual"=46
+WHILE="while"=47
+YIELD="yield"=48
+SWITCH="switch"=49
+CASE="case"=50
+DEFAULT="default"=51
+INPLACE_DIVISION="/="=52
+INPLACE_ADD="+="=53
+INPLACE_SUBTRACT="-="=54
+INPLACE_MULTIPLY="*="=55
+SL_COMMENT="//"=56
+PRAGMA_ON="pragma on"=57
+PRAGMA_OFF="pragma off"=58
+ID="an identifier"=59
+DOUBLE_QUOTED_STRING="a string"=60
+LBRACE="{"=61
+RBRACE="}"=62
+LPAREN="("=63
+RPAREN=")"=64
+DOT="."=65
+COLON=":"=66
+COMMA=","=67
+LBRACK="["=68
+RBRACK="]"=69
+BITWISE_OR="|"=70
+INPLACE_BITWISE_OR="|="=71
+BITWISE_AND="&"=72
+BITWISE_XOR="^"=73
+INPLACE_BITWISE_AND="&="=74
+LOGICAL_OR="||"=75
+LOGICAL_AND="&&"=76
+EOS=";"=77
+ASSIGN="="=78
+INCREMENT="++"=79
+DECREMENT="--"=80
+ADD="+"=81
+SUBTRACT="-"=82
+MODULUS="%"=83
+MULTIPLY="*"=84
+EQUALITY="=="=85
+INEQUALITY="!="=86
+QUESTION_MARK="?"=87
+BITWISE_NOT="~"=88
+REFERENCE_EQUALITY="==="=89
+REFERENCE_INEQUALITY="!=="=90
+LESS_THAN="<"=91
+LESS_THAN_OR_EQUAL="<="=92
+SHIFT_LEFT="<<"=93
+INPLACE_SHIFT_LEFT="<<="=94
+GREATER_THAN=">"=95
+GREATER_THAN_OR_EQUAL=">="=96
+SHIFT_RIGHT=">>"=97
+INPLACE_SHIFT_RIGHT=">>="=98
+AT="@"=99
+SCRIPT_ATTRIBUTE_MARKER="@script"=100
+ASSEMBLY_ATTRIBUTE_MARKER="@assembly"=101
+INPLACE_BITWISE_XOR=102
+LOGICAL_NOT=103
+DIVISION=104
+RE_LITERAL=105
+DOUBLE=106
+INT=107
+LONG=108
+SINGLE_QUOTED_STRING=109
+DOUBLE_SUFFIX=110
+EXPONENT=111
+PRAGMA_WHITE_SPACE=112
+WHITE_SPACE=113
+DQS_ESC=114
+SQS_ESC=115
+SESC=116
+ML_COMMENT=117
+RE_CHAR=118
+RE_ESC=119
+NEWLINE=120
+ID_LETTER=121
+DIGIT=122
+HEXDIGIT=123
diff --git a/src/UnityScript/Scripting/EvaluationContext.boo b/src/UnityScript/Scripting/EvaluationContext.boo
index 5c2ea85..3126c2a 100755
--- a/src/UnityScript/Scripting/EvaluationContext.boo
+++ b/src/UnityScript/Scripting/EvaluationContext.boo
@@ -16,8 +16,11 @@ class EvaluationContext:
def constructor(container as IEvaluationDomainProvider):
_container = container or SimpleEvaluationDomainProvider()
+ def constructor():
+ _container = SimpleEvaluationDomainProvider()
+
IsStaticContext:
- get: return SimpleEvaluationDomainProvider is _container.GetType()
+ get: return _container isa SimpleEvaluationDomainProvider
[lock]
def AddScript(script):
@@ -34,4 +37,6 @@ class EvaluationContext:
[lock]
def GetActiveScripts():
return _activeScripts.ToArray()
+
+
diff --git a/src/UnityScript/Scripting/Evaluator.boo b/src/UnityScript/Scripting/Evaluator.boo
index 141a230..e0a9295 100755
--- a/src/UnityScript/Scripting/Evaluator.boo
+++ b/src/UnityScript/Scripting/Evaluator.boo
@@ -13,58 +13,6 @@ class CompilationErrorsException(Exception):
def constructor(errors as CompilerErrorCollection):
super(errors.ToString(true))
_errors = errors
-
-interface IEvaluationDomainProvider:
-"""
-Every script in UnityScript defines a new EvaluationDomain.
-"""
- def GetImports() as (string)
- def GetEvaluationDomain() as EvaluationDomain
-
-class SimpleEvaluationDomainProvider(IEvaluationDomainProvider):
-"""
-SimpleEvaluationDomainProvider is used whenever there's an eval invocation
-inside a static method.
-"""
- private _domain = EvaluationDomain()
- private _imports as (string)
-
- def GetImports():
- return _imports
-
- def GetEvaluationDomain() as EvaluationDomain:
- return _domain
-
-class EvaluationDomain:
-"""
-Groups together a set of related EvaluationScripts instances.
-"""
- _cache = {}
-
- [lock]
- def GetCachedScript(key as EvaluationScriptCacheKey) as System.Type:
- return _cache[key]
-
- [lock]
- def CacheScript(key as EvaluationScriptCacheKey, type as System.Type):
- _cache[key] = type
-
-class EvaluationScriptCacheKey:
-
- _contextType as System.Type
- _code as string
-
- def constructor(contextType as Type, code as string):
- _contextType = contextType
- _code = code
-
- override def Equals(o):
- other = o as EvaluationScriptCacheKey
- if other is null: return false
- return other._contextType is _contextType and other._code == _code
-
- override def GetHashCode():
- return _contextType.GetHashCode() ^ _code.GetHashCode()
class EvaluationScript:
@@ -136,18 +84,17 @@ class Evaluator:
compiler.Parameters.Debug = false
compiler.Parameters.GenerateInMemory = true
- contextAssembly = _context.GetType().Assembly
- compiler.Parameters.References.Add(contextAssembly)
- for name in contextAssembly.GetReferencedAssemblies():
- compiler.Parameters.References.Add(System.Reflection.Assembly.Load(name))
+ AddEvaluationContextReferencesTo(compiler)
_compilationResult = compiler.Run()
if len(_compilationResult.Errors):
raise CompilationErrorsException(_compilationResult.Errors)
-
- #print _compilationResult.CompileUnit.ToCodeString()
return _compilationResult.GeneratedAssembly.GetType("script")
+ private def AddEvaluationContextReferencesTo(compiler as UnityScriptCompiler):
+ for assembly in _context.ScriptContainer.GetAssemblyReferences():
+ compiler.Parameters.References.Add(assembly)
+
static def AdjustPipeline(context as EvaluationContext, pipeline as CompilerPipeline):
pipeline.InsertAfter(
UnityScript.Steps.IntroduceUnityGlobalNamespaces,
diff --git a/src/UnityScript/Scripting/IEvaluationDomainProvider.boo b/src/UnityScript/Scripting/IEvaluationDomainProvider.boo
new file mode 100644
index 0000000..272916b
--- /dev/null
+++ b/src/UnityScript/Scripting/IEvaluationDomainProvider.boo
@@ -0,0 +1,40 @@
+namespace UnityScript.Scripting
+
+interface IEvaluationDomainProvider: // IEvalHost?
+"""
+Every script in UnityScript defines a new EvaluationDomain.
+"""
+ def GetImports() as (string)
+ def GetAssemblyReferences() as (System.Reflection.Assembly)
+ def GetEvaluationDomain() as EvaluationDomain
+
+class EvaluationDomain:
+"""
+A EvaluationScript cache.
+"""
+ _cache = {}
+
+ [lock]
+ def GetCachedScript(key as EvaluationScriptCacheKey) as System.Type:
+ return _cache[key]
+
+ [lock]
+ def CacheScript(key as EvaluationScriptCacheKey, type as System.Type):
+ _cache[key] = type
+
+class EvaluationScriptCacheKey:
+
+ _contextType as System.Type
+ _code as string
+
+ def constructor(contextType as System.Type, code as string):
+ _contextType = contextType
+ _code = code
+
+ override def Equals(o):
+ other = o as EvaluationScriptCacheKey
+ if other is null: return false
+ return other._contextType is _contextType and other._code == _code
+
+ override def GetHashCode():
+ return _contextType.GetHashCode() ^ _code.GetHashCode()
\ No newline at end of file
diff --git a/src/UnityScript/Scripting/Pipeline/IntroduceImports.boo b/src/UnityScript/Scripting/Pipeline/IntroduceImports.boo
old mode 100755
new mode 100644
index fac9196..a43100e
--- a/src/UnityScript/Scripting/Pipeline/IntroduceImports.boo
+++ b/src/UnityScript/Scripting/Pipeline/IntroduceImports.boo
@@ -18,6 +18,6 @@ class IntroduceImports(AbstractCompilerStep):
def AddImports(imports as (string)):
for m in CompileUnit.Modules:
for i in imports:
- m.Imports.Add(Import(Namespace: i))
+ m.Imports.Add(Import(i))
\ No newline at end of file
diff --git a/src/UnityScript/Scripting/Pipeline/IntroduceReturnValue.boo b/src/UnityScript/Scripting/Pipeline/IntroduceReturnValue.boo
index b5cf009..1401429 100755
--- a/src/UnityScript/Scripting/Pipeline/IntroduceReturnValue.boo
+++ b/src/UnityScript/Scripting/Pipeline/IntroduceReturnValue.boo
@@ -5,8 +5,7 @@ import Boo.Lang.Compiler.Ast
import UnityScript.Steps
class IntroduceReturnValue(AbstractCompilerStep):
-"""
-"""
+
override def Run():
klass = GetScriptClass(Context)
if klass is null: return
diff --git a/src/UnityScript/Scripting/Pipeline/IntroduceScriptingNamespace.boo b/src/UnityScript/Scripting/Pipeline/IntroduceScriptingNamespace.boo
index b7ce0b8..dbf6fd9 100755
--- a/src/UnityScript/Scripting/Pipeline/IntroduceScriptingNamespace.boo
+++ b/src/UnityScript/Scripting/Pipeline/IntroduceScriptingNamespace.boo
@@ -66,8 +66,10 @@ class EvaluationContextNamespace(INamespace):
_tss = tss
_parent = parent
_context = context
- _contextNamespace = tss.Map(_context.GetType())
- _scriptContainerNamespace = tss.Map(_context.GetType().DeclaringType)
+
+ contextType = tss.Map(_context.GetType())
+ _contextNamespace = contextType
+ _scriptContainerNamespace = contextType.DeclaringEntity or NullNamespace.Default
_activeScripts = _context.GetActiveScripts()
Name:
diff --git a/src/UnityScript/Scripting/Pipeline/ProcessScriptingMethods.boo b/src/UnityScript/Scripting/Pipeline/ProcessScriptingMethods.boo
old mode 100755
new mode 100644
index 94ad360..ee414b0
--- a/src/UnityScript/Scripting/Pipeline/ProcessScriptingMethods.boo
+++ b/src/UnityScript/Scripting/Pipeline/ProcessScriptingMethods.boo
@@ -25,12 +25,12 @@ they point to EvaluationContext provided members.
override def OnReferenceExpression(node as ReferenceExpression):
super(node)
- entity = GetOptionalEntity(node) as EvaluationContextEntity
+ entity = node.Entity as EvaluationContextEntity
if entity is null: return
if not ValidateContext(entity):
member = entity.Delegate
- Errors.Add(CompilerErrorFactory.InstanceRequired(node, member.DeclaringType.ToString(), member.Name))
+ Errors.Add(CompilerErrorFactory.InstanceRequired(node, member))
node.ParentNode.Replace(
node,
@@ -86,7 +86,3 @@ they point to EvaluationContext provided members.
def GetScriptClassType():
return GetEntity(GetScriptClass(Context))
-
- def GetOptionalEntity(node as Node):
- return self.TypeSystemServices.GetOptionalEntity(node)
-
diff --git a/src/UnityScript/Scripting/SimpleEvaluationDomainProvider.boo b/src/UnityScript/Scripting/SimpleEvaluationDomainProvider.boo
new file mode 100644
index 0000000..d44304f
--- /dev/null
+++ b/src/UnityScript/Scripting/SimpleEvaluationDomainProvider.boo
@@ -0,0 +1,26 @@
+namespace UnityScript.Scripting
+
+class SimpleEvaluationDomainProvider(IEvaluationDomainProvider):
+"""
+SimpleEvaluationDomainProvider is used whenever there's an eval invocation
+inside a static method.
+"""
+ private _domain = EvaluationDomain()
+ private _imports as (string)
+
+ def constructor():
+ pass
+
+ def constructor(*imports as (string)):
+ _imports = imports
+
+ def GetImports():
+ return _imports
+
+ def GetEvaluationDomain():
+ return _domain
+
+ virtual def GetAssemblyReferences():
+ return array[of System.Reflection.Assembly](0)
+
+
diff --git a/src/UnityScript/Steps/ApplyDefaultVisibility.boo b/src/UnityScript/Steps/ApplyDefaultVisibility.boo
new file mode 100644
index 0000000..d048750
--- /dev/null
+++ b/src/UnityScript/Steps/ApplyDefaultVisibility.boo
@@ -0,0 +1,35 @@
+namespace UnityScript.Steps
+
+import Boo.Lang.Compiler.Ast
+import Boo.Lang.Compiler.Steps
+
+class ApplyDefaultVisibility(AbstractVisitorCompilerStep):
+
+ override def Run():
+ Visit(CompileUnit)
+
+ override def LeaveEnumDefinition(node as EnumDefinition):
+ SetPublicByDefault(node)
+
+ override def LeaveInterfaceDefinition(node as InterfaceDefinition):
+ SetPublicByDefault(node)
+
+ override def LeaveClassDefinition(node as ClassDefinition):
+ SetPublicByDefault(node)
+
+ override def OnField(node as Field):
+ SetPublicByDefault(node)
+
+ override def OnConstructor(node as Constructor):
+ SetPublicByDefault(node)
+
+ override def OnMethod(node as Method):
+ if node.IsPrivate: return
+
+ SetPublicByDefault(node)
+ if node.IsFinal: return
+ if node.IsStatic: return
+ node.Modifiers |= TypeMemberModifiers.Virtual
+
+ def SetPublicByDefault(node as TypeMember):
+ node.Modifiers |= TypeMemberModifiers.Public unless node.IsVisibilitySet
\ No newline at end of file
diff --git a/src/UnityScript/Steps/ApplySemantics.boo b/src/UnityScript/Steps/ApplySemantics.boo
index a231b5f..01369ff 100755
--- a/src/UnityScript/Steps/ApplySemantics.boo
+++ b/src/UnityScript/Steps/ApplySemantics.boo
@@ -4,6 +4,7 @@ import UnityScript.Core
import Boo.Lang.Compiler.Ast
import Boo.Lang.Compiler.Steps
+import System.Linq
class ApplySemantics(AbstractVisitorCompilerStep):
@@ -39,27 +40,35 @@ class ApplySemantics(AbstractVisitorCompilerStep):
override def OnModule(module as Module):
SetUpDefaultImports(module)
+ if ModuleContainsOnlyTypeDefinitions(module):
+ return
script = FindOrCreateScriptClass(module)
- SetUpScriptClass(script)
+ MakeItPartial(script)
MoveMembers(module, script)
SetUpMainMethod(module, script)
MoveAttributes(module, script)
module.Members.Add(script)
SetScriptClass(Context, script)
- def SetUpMainMethod(module as Module, script as TypeDefinition):
+ def ModuleContainsOnlyTypeDefinitions(module as Module):
+ return not module.Members.IsEmpty and module.Members.All({ m | m isa TypeDefinition }) and module.Globals.IsEmpty and module.Attributes.IsEmpty
+ def SetUpMainMethod(module as Module, script as TypeDefinition):
TransformGlobalVariablesIntoFields(module, script)
+ MoveGlobalStatementsToMainMethodOf(script, module)
+
+ def MoveGlobalStatementsToMainMethodOf(script as TypeDefinition, module as Module):
+
+ main = ExistingMainMethodOn(script)
- main = FindExistingMainMethodOn(script)
if main is null:
- main = CreateMainMethod(module)
+ main = NewMainMethodFor(module)
script.Members.Add(main)
else:
Warnings.Add(UnityScriptWarnings.ScriptMainMethodIsImplicitlyDefined(main.LexicalInfo, main.Name))
- main.Body.Statements.Extend(module.Globals.Statements)
+ main.Body.Statements.AddRange(module.Globals.Statements)
module.Globals.Statements.Clear()
def TransformGlobalVariablesIntoFields(module as Module, script as TypeDefinition):
@@ -67,25 +76,24 @@ class ApplySemantics(AbstractVisitorCompilerStep):
return
module.Globals.Accept(DeclareGlobalVariables(script))
- def FindExistingMainMethodOn(typeDef as TypeDefinition):
- for member in typeDef.Members:
- method = member as Method
- found = method is not null \
- and method.Name == ScriptMainMethod \
- and len(method.Parameters) == 0
- return method if found
+ def ExistingMainMethodOn(typeDef as TypeDefinition):
+ return typeDef.Members.OfType[of Method]().FirstOrDefault(IsMainMethod)
- def SetUpScriptClass(global as ClassDefinition):
- global.Modifiers |= TypeMemberModifiers.Partial
- SetMembersPublicByDefault(global)
+ def IsMainMethod(m as Method):
+ return (
+ m is not null
+ and m.Name == ScriptMainMethod
+ and len(m.Parameters) == 0)
+
+ def MakeItPartial(global as ClassDefinition):
+ global.Modifiers |= TypeMemberModifiers.Partial
def SetUpDefaultImports(module as Module):
for ns as string in self.UnityScriptParameters.Imports:
- module.Imports.Add(
- Import(LexicalInfo: module.LexicalInfo, Namespace: ns))
+ module.Imports.Add(Import(ns))
def MoveAttributes(fromType as TypeDefinition, toType as TypeDefinition):
- toType.Attributes.Extend(fromType.Attributes)
+ toType.Attributes.AddRange(fromType.Attributes)
fromType.Attributes.Clear()
def MoveMembers(fromType as TypeDefinition, toType as TypeDefinition):
@@ -120,53 +128,30 @@ class ApplySemantics(AbstractVisitorCompilerStep):
LexicalInfo: method.LexicalInfo,
EndSourceLocation: method.EndSourceLocation)
- override def OnField(node as Field):
- SetPublicByDefault(node)
-
- override def OnConstructor(node as Constructor):
- SetPublicByDefault(node)
-
- override def OnMethod(node as Method):
- if node.IsPrivate: return
-
- SetPublicByDefault(node)
- if node.IsFinal: return
- if node.IsStatic: return
- node.Modifiers |= TypeMemberModifiers.Virtual
-
def FindOrCreateScriptClass(module as Module):
- for existing as ClassDefinition in module.Members.Select(NodeType.ClassDefinition):
+ for existing in module.Members.OfType of ClassDefinition():
if existing.Name == module.Name:
module.Members.Remove(existing)
if existing.IsPartial: AddScriptBaseType(existing)
existing.Annotate("UserDefined")
return existing
- klass = ClassDefinition(module.LexicalInfo, Name: module.Name, EndSourceLocation: module.EndSourceLocation)
+ klass = ClassDefinition(module.LexicalInfo, Name: module.Name, EndSourceLocation: module.EndSourceLocation, IsSynthetic: true)
AddScriptBaseType(klass)
return klass
def AddScriptBaseType(klass as ClassDefinition):
klass.BaseTypes.Add(CodeBuilder.CreateTypeReference(UnityScriptParameters.ScriptBaseType))
- def SetMembersPublicByDefault(node as ClassDefinition):
- for member in node.Members: Visit(member)
-
- def SetPublicByDefault(node as TypeMember):
- node.Modifiers |= TypeMemberModifiers.Public unless node.IsVisibilitySet
-
ScriptMainMethod:
get: return self.UnityScriptParameters.ScriptMainMethod
- def CreateMainMethod(module as Module):
- method = Method(module.LexicalInfo, Name: ScriptMainMethod)
- method.Modifiers = TypeMemberModifiers.Public | TypeMemberModifiers.Virtual
-
- stmts = module.Globals.Statements
- if len(stmts) > 0: method.LexicalInfo = Copy(stmts[0].LexicalInfo)
- method.EndSourceLocation = module.EndSourceLocation
-
- return method
+ def NewMainMethodFor(module as Module):
+ return Method(
+ LexicalInfo: (Copy(module.Globals.Statements[0].LexicalInfo) if not module.Globals.IsEmpty else module.LexicalInfo),
+ Name: ScriptMainMethod,
+ Modifiers: TypeMemberModifiers.Public | TypeMemberModifiers.Virtual,
+ EndSourceLocation: module.EndSourceLocation)
def Copy(li as LexicalInfo):
return LexicalInfo(li.FileName, li.Line, li.Column)
diff --git a/src/UnityScript/Steps/AutoExplodeVarArgsInvocation.boo b/src/UnityScript/Steps/AutoExplodeVarArgsInvocation.boo
new file mode 100644
index 0000000..f566728
--- /dev/null
+++ b/src/UnityScript/Steps/AutoExplodeVarArgsInvocation.boo
@@ -0,0 +1,27 @@
+namespace UnityScript.Steps
+
+import Boo.Lang.Compiler.Ast
+import Boo.Lang.Compiler.Steps
+import Boo.Lang.Compiler.TypeSystem
+import UnityScript.TypeSystem
+
+class AutoExplodeVarArgsInvocations(AbstractVisitorCompilerStep):
+
+ override def Run():
+ Visit(CompileUnit)
+
+ override def LeaveMethodInvocationExpression(node as MethodInvocationExpression):
+ entity = node.Target.Entity as IEntityWithParameters
+ if entity is null:
+ return
+
+ args = node.Arguments
+ if not entity.AcceptVarArgs or not IsArrayArgumentExplicitlyProvided(entity.GetParameters(), args):
+ return
+
+ lastArg = args[-1]
+ args.ReplaceAt(-1,
+ UnaryExpression(
+ Operator: UnaryOperatorType.Explode,
+ Operand: lastArg,
+ ExpressionType: GetExpressionType(lastArg)))
diff --git a/src/UnityScript/Steps/CheckBaseTypes.boo b/src/UnityScript/Steps/CheckBaseTypes.boo
index f20254f..08f9fba 100755
--- a/src/UnityScript/Steps/CheckBaseTypes.boo
+++ b/src/UnityScript/Steps/CheckBaseTypes.boo
@@ -25,13 +25,13 @@ class CheckBaseTypes(AbstractVisitorCompilerStep):
type = TypeEntityFor(baseType)
if type.IsClass:
return
- Errors.Add(UnityScriptCompilerErrors.ClassExpected(baseType.LexicalInfo, type.FullName))
+ Errors.Add(UnityScriptCompilerErrors.ClassExpected(baseType.LexicalInfo, type.DisplayName()))
def CheckIsInterface(baseType as TypeReference):
type = TypeEntityFor(baseType)
if type.IsInterface:
return
- Errors.Add(UnityScriptCompilerErrors.InterfaceExpected(baseType.LexicalInfo, type.FullName))
+ Errors.Add(UnityScriptCompilerErrors.InterfaceExpected(baseType.LexicalInfo, type.DisplayName()))
def TypeEntityFor(baseType as TypeReference) as IType:
return GetEntity(baseType)
diff --git a/src/UnityScript/Steps/EvalAnnotation.boo b/src/UnityScript/Steps/EvalAnnotation.boo
new file mode 100644
index 0000000..126c89d
--- /dev/null
+++ b/src/UnityScript/Steps/EvalAnnotation.boo
@@ -0,0 +1,18 @@
+namespace UnityScript.Steps
+
+import Boo.Lang.Compiler.Ast
+
+static class EvalAnnotation:
+
+ def Mark(node as Method):
+ AnnotateEval(node.DeclaringType)
+ AnnotateEval(node)
+
+ def IsMarked(node as Node):
+ return node.ContainsAnnotation(Annotation)
+
+ private def AnnotateEval(node as Node):
+ if IsMarked(node): return
+ node.Annotate(Annotation)
+
+ final Annotation = object()
\ No newline at end of file
diff --git a/src/UnityScript/Steps/EvaluationDomainProviderImplementor.boo b/src/UnityScript/Steps/EvaluationDomainProviderImplementor.boo
new file mode 100755
index 0000000..dbdc0ae
--- /dev/null
+++ b/src/UnityScript/Steps/EvaluationDomainProviderImplementor.boo
@@ -0,0 +1,103 @@
+namespace UnityScript.Steps
+
+import System
+import Boo.Lang.Environments
+import Boo.Lang.Compiler
+import Boo.Lang.Compiler.Ast
+import Boo.Lang.Compiler.TypeSystem
+import Boo.Lang.Compiler.TypeSystem.Services
+import UnityScript.Macros
+import UnityScript.Scripting
+
+class EvaluationDomainProviderImplementor(AbstractCompilerComponent):
+
+ def ImplementIEvaluationDomainProviderOn(node as ClassDefinition):
+ domainField = ReferenceExpression(Context.GetUniqueName("domain"))
+ evaluationDomainProviderImpl = [|
+ class _($IEvaluationDomainProvider):
+
+ private $domainField as $EvaluationDomain
+
+ def GetEvaluationDomain():
+ return $domainField or ($domainField = $EvaluationDomain())
+
+ def GetImports():
+ return $(ImportsArrayFor(node))
+
+ def GetAssemblyReferences():
+ return $(AssemblyReferencesArray())
+ |]
+
+ my(CodeReifier).MergeInto(node, evaluationDomainProviderImpl)
+
+ def StaticEvaluationDomainProviderFor(node as ClassDefinition) as IField:
+ perNode node:
+ return CreateStaticEvaluationDomainProviderReferenceOn(node)
+
+ private def AssemblyReferencesArray() as Expression:
+ perNode CompileUnit:
+ return CodeBuilder.CreateReference(CreateAssemblyReferencesArray())
+
+ private def ImportsArrayFor(node as ClassDefinition):
+ result = [| (of $string:,) |]
+ result.Items.AddRange([| $(i.Namespace) |] for i in node.EnclosingModule.Imports)
+ return result
+
+ private def CreateStaticEvaluationDomainProviderReferenceOn(node as ClassDefinition):
+ evaluationDomainProviderImpl = [|
+ public class StaticEvaluationDomainProvider($SimpleEvaluationDomainProvider):
+
+ public static final Instance = StaticEvaluationDomainProvider()
+
+ def constructor():
+ super($(ImportsArrayFor(node)))
+
+ override def GetAssemblyReferences():
+ return $(AssemblyReferencesArray())
+ |]
+ my(CodeReifier).ReifyInto(node, evaluationDomainProviderImpl)
+ return evaluationDomainProviderImpl.Members["Instance"].Entity
+
+ private def CreateAssemblyReferencesArray() as IField:
+ references = [| (System.Reflection.Assembly.GetExecutingAssembly(),) |]
+
+ for assembly in ReferencedAssemblies():
+ publicType = AnyPublicTypeOf(assembly)
+ continue if publicType is null
+ references.Items.Add([| typeof($publicType).Assembly |])
+
+ arrayHolder = [|
+ internal class EvalAssemblyReferences:
+ public static final Value = $references
+ |]
+ my(CodeReifier).ReifyInto(CompileUnit.Modules[0], arrayHolder)
+ return arrayHolder.Members["Value"].Entity
+
+ private def AnyPublicTypeOf(assembly as System.Reflection.Assembly):
+ for t in assembly.GetTypes():
+ return t if t.IsPublic and not t.IsGenericType
+
+ private def ReferencedAssemblies():
+ collector = ReferencedAssemblyCollector()
+ CompileUnit.Accept(collector)
+ return collector.ReferencedAssemblies
+
+class ReferencedAssemblyCollector(DepthFirstVisitor):
+
+ [getter(ReferencedAssemblies)]
+ _assemblies = Boo.Lang.Compiler.Util.Set of Assembly()
+
+ override def OnReferenceExpression(node as ReferenceExpression):
+ CheckTypeReference(node)
+
+ override def LeaveMemberReferenceExpression(node as MemberReferenceExpression):
+ CheckTypeReference(node)
+
+ override def OnSimpleTypeReference(node as SimpleTypeReference):
+ CheckTypeReference(node)
+
+ def CheckTypeReference(node as Node):
+ type = node.Entity as Boo.Lang.Compiler.TypeSystem.Reflection.ExternalType
+ if type is null: return
+ _assemblies.Add(type.ActualType.Assembly)
+
diff --git a/src/UnityScript/Steps/ExpandUnityDuckTypedExpressions.boo b/src/UnityScript/Steps/ExpandUnityDuckTypedExpressions.boo
index 97c00b7..1f36cf2 100755
--- a/src/UnityScript/Steps/ExpandUnityDuckTypedExpressions.boo
+++ b/src/UnityScript/Steps/ExpandUnityDuckTypedExpressions.boo
@@ -1,5 +1,7 @@
namespace UnityScript.Steps
+import UnityScript.Core
+
import Boo.Lang.Compiler
import Boo.Lang.Compiler.Ast
import Boo.Lang.Compiler.TypeSystem
@@ -8,40 +10,39 @@ import Boo.Lang.Compiler.Steps
class ExpandUnityDuckTypedExpressions(ExpandDuckTypedExpressions):
private UnityRuntimeServices_Invoke as IMethod
+ private UnityRuntimeServices_GetProperty as IMethod
private _expando as bool
override def Initialize(context as CompilerContext):
super(context)
UnityRuntimeServices_Invoke = ResolveUnityRuntimeMethod("Invoke")
+ UnityRuntimeServices_GetProperty = ResolveUnityRuntimeMethod("GetProperty")
- override def EnterModule(module as Module):
- _expando = UnityScriptParameters.Expando or module.ContainsAnnotation("expando")
- return super(module)
+ override def OnModule(module as Module):
+ _expando = UnityScriptParameters.Expando or Pragmas.IsEnabledOn(module, Pragmas.Expando)
+ preserving Parameters.Strict:
+ Parameters.Strict = Pragmas.IsEnabledOn(module, Pragmas.Strict)
+ super(module)
override def GetSetPropertyMethod():
if not _expando: return super()
return ResolveUnityRuntimeMethod("SetProperty")
override def GetGetPropertyMethod():
- if not _expando: return super()
- return ResolveUnityRuntimeMethod("GetProperty")
+ return UnityRuntimeServices_GetProperty
override def ExpandQuackInvocation(node as MethodInvocationExpression):
- if not IsPossibleStartCoroutineInvocation(node):
- super(node)
- return
-
self.ExpandQuackInvocation(node, UnityRuntimeServices_Invoke)
node.Arguments.Add(CodeBuilder.CreateTypeofExpression(UnityScriptTypeSystem.ScriptBaseType))
def ResolveUnityRuntimeMethod(methodName as string):
return NameResolutionService.ResolveMethod(UnityRuntimeServicesType, methodName)
- UnityScriptTypeSystem as UnityScript.Steps.UnityScriptTypeSystem:
+ UnityScriptTypeSystem as UnityScript.TypeSystem.UnityScriptTypeSystem:
get: return self.TypeSystemServices
UnityScriptParameters as UnityScript.UnityScriptCompilerParameters:
- get: return _context.Parameters
+ get: return self.Parameters
UnityRuntimeServicesType:
get: return self.TypeSystemServices.Map(typeof(UnityScript.Lang.UnityRuntimeServices))
diff --git a/src/UnityScript/Steps/InitializeUnityScriptTypeSystem.boo b/src/UnityScript/Steps/InitializeUnityScriptTypeSystem.boo
deleted file mode 100755
index e2bdf7a..0000000
--- a/src/UnityScript/Steps/InitializeUnityScriptTypeSystem.boo
+++ /dev/null
@@ -1,14 +0,0 @@
-namespace UnityScript.Steps
-
-import Boo.Lang.Compiler.Steps
-
-class InitializeUnityScriptTypeSystem(InitializeTypeSystemServices):
-
- override def CreateTypeSystemServices():
- return UnityScriptTypeSystem(Context)
-
- override def CreateCallableResolutionService():
- return UnityCallableResolutionService(Context)
-
- override def CreateDowncastPermissions():
- return UnityDowncastPermissions()
diff --git a/src/UnityScript/Steps/IntroducePragmas.boo b/src/UnityScript/Steps/IntroducePragmas.boo
index a135294..36c2bbc 100755
--- a/src/UnityScript/Steps/IntroducePragmas.boo
+++ b/src/UnityScript/Steps/IntroducePragmas.boo
@@ -1,16 +1,18 @@
namespace UnityScript.Steps
+import UnityScript.Core
+
import Boo.Lang.Compiler.Steps
class IntroducePragmas(AbstractCompilerStep):
- _pragmas as List of string
+ _pragmas as string*
- def constructor(pragmas as List of string):
+ def constructor(pragmas as string*):
_pragmas = pragmas
override def Run():
for module in CompileUnit.Modules:
for pragma in _pragmas:
- module.Annotate(pragma) unless module.ContainsAnnotation(pragma)
-
+ Pragmas.TryToEnableOn(module, pragma)
+
diff --git a/src/UnityScript/Steps/IntroduceUnityGlobalNamespaces.boo b/src/UnityScript/Steps/IntroduceUnityGlobalNamespaces.boo
index 721edb1..33dbc31 100755
--- a/src/UnityScript/Steps/IntroduceUnityGlobalNamespaces.boo
+++ b/src/UnityScript/Steps/IntroduceUnityGlobalNamespaces.boo
@@ -9,12 +9,11 @@ class IntroduceUnityGlobalNamespaces(AbstractCompilerStep):
NameResolutionService.Reset()
NameResolutionService.GlobalNamespace = NamespaceDelegator(
NameResolutionService.GlobalNamespace,
- SafeGetNamespace("Boo.Lang"),
TypeSystemServices.BuiltinsType,
SafeGetNamespace("UnityScript.Lang"),
TypeSystemServices.Map(UnityScript.Lang.UnityBuiltins),
TypeSystemServices.Map(UnityScript.Lang.Extensions))
def SafeGetNamespace(name as string):
- ns = NameResolutionService.ResolveQualifiedName("Boo.Lang")
+ ns = NameResolutionService.ResolveQualifiedName(name)
return ns or NullNamespace.Default
diff --git a/src/UnityScript/Steps/Lint.boo b/src/UnityScript/Steps/Lint.boo
new file mode 100644
index 0000000..dda4798
--- /dev/null
+++ b/src/UnityScript/Steps/Lint.boo
@@ -0,0 +1,22 @@
+namespace UnityScript.Steps
+
+import Boo.Lang.Compiler.Ast
+import Boo.Lang.Compiler.Steps
+
+import PatternMatching
+import UnityScript.Core.UnityScriptWarnings
+
+class Lint(AbstractFastVisitorCompilerStep):
+
+ override def OnBinaryExpression(node as BinaryExpression):
+ super(node)
+ match node.Operator:
+ case BinaryOperatorType.BitwiseAnd | BinaryOperatorType.BitwiseOr:
+ if IsBoolean(node.Left) and IsBoolean(node.Right):
+ expected, actual = (("&&", "&") if node.Operator == BinaryOperatorType.BitwiseAnd else ("||", "|"))
+ Warnings.Add(BitwiseOperatorWithBooleanOperands(node.LexicalInfo, expected, actual))
+ otherwise:
+ pass
+
+ def IsBoolean(e as Expression):
+ return e.ExpressionType is TypeSystemServices.BoolType
\ No newline at end of file
diff --git a/src/UnityScript/Steps/Parse.boo b/src/UnityScript/Steps/Parse.boo
index bcc7465..0482aca 100644
--- a/src/UnityScript/Steps/Parse.boo
+++ b/src/UnityScript/Steps/Parse.boo
@@ -1,35 +1,60 @@
namespace UnityScript.Steps
import System
-import System.IO
import Boo.Lang.Compiler
+import Boo.Lang.Compiler.Ast
import Boo.Lang.Compiler.Steps
+import UnityScript.Core
import UnityScript.Parser
class Parse(AbstractCompilerStep):
override def Run():
+ ParseInputs()
+ NormalizePropertyAccessors()
+
+ private def ParseInputs():
for input in self.Parameters.Input:
try:
ParseInput(input)
except x:
Errors.Add(CompilerErrorFactory.InputError(input.Name, x))
+
+ private def NormalizePropertyAccessors():
+ CompileUnit.Accept(PropertyAccessorNormalizer(Errors: Errors))
private def ParseInput(input as ICompilerInput):
using reader = input.Open():
- if reader.Peek() == -1:
- return
- ParseReader(input.Name, reader)
-
- protected virtual def ParseReader(name as string, reader as TextReader):
- lexer = UnityScriptLexer(reader)
- lexer.setFilename(name)
- lexer.setTokenCreator(Boo.Lang.Parser.BooToken.BooTokenCreator())
-
- parser = UnityScriptParser(lexer, CompilerContext: Context)
- parser.setFilename(name)
+ UnityScriptParser.ParseReader(reader, input.Name, self.Context, self.CompileUnit)
+
+ class PropertyAccessorNormalizer(FastDepthFirstVisitor):
+ property Errors as CompilerErrorCollection
- try:
- parser.start(self.CompileUnit)
- except x as antlr.TokenStreamRecognitionException:
- parser.reportError(x.recog)
+ override def OnProperty(node as Property):
+ NormalizeSetter node.Setter
+ NormalizeGetter node.Getter
+
+ def NormalizeSetter(setter as Method):
+ if setter is null:
+ return
+ NormalizeSetterParameters setter
+ CheckSetterReturnType setter
+
+ def NormalizeSetterParameters(setter as Method):
+ if setter.Parameters.Count != 1 or setter.Parameters[0].Name != "value":
+ ReportError(UnityScriptCompilerErrors.InvalidPropertySetter(setter.LexicalInfo))
+ return
+ setter.Parameters.Clear()
+
+ def CheckSetterReturnType(setter as Method):
+ if setter.ReturnType is null:
+ return
+ ReportError(UnityScriptCompilerErrors.SetterCanNotDeclareReturnType(setter.ReturnType.LexicalInfo))
+
+ def NormalizeGetter(getter as Method):
+ if getter is null or getter.Parameters.Count == 0:
+ return
+ ReportError(UnityScriptCompilerErrors.InvalidPropertyGetter(getter.LexicalInfo))
+
+ def ReportError(error as CompilerError):
+ Errors.Add(error)
diff --git a/src/UnityScript/Steps/PreProcess.boo b/src/UnityScript/Steps/PreProcess.boo
index 59d8287..da301f5 100644
--- a/src/UnityScript/Steps/PreProcess.boo
+++ b/src/UnityScript/Steps/PreProcess.boo
@@ -10,7 +10,6 @@ class PreProcess(AbstractCompilerStep):
override def Run():
processed = List[of ICompilerInput]()
-
for input in Parameters.Input:
processed.Add(RunPreProcessorOn(input))
diff --git a/src/UnityScript/Steps/ProcessEvalInvocations.boo b/src/UnityScript/Steps/ProcessEvalInvocations.boo
index 5a8ab70..d6a1a91 100755
--- a/src/UnityScript/Steps/ProcessEvalInvocations.boo
+++ b/src/UnityScript/Steps/ProcessEvalInvocations.boo
@@ -1,35 +1,25 @@
namespace UnityScript.Steps
import System
+import Boo.Lang.Environments
import Boo.Lang.Compiler.Ast
import Boo.Lang.Compiler.Steps
import Boo.Lang.Compiler.TypeSystem
import Boo.Lang.Compiler.TypeSystem.Internal
import Boo.Lang.Compiler.TypeSystem.Builders
+import UnityScript.Core
import UnityScript.Scripting
+import UnityScript.TypeSystem
class ProcessEvalInvocations(AbstractVisitorCompilerStep):
- static final ContainsEvalAnnotation = object()
-
- static def Mark(node as Method):
- AnnotateEval(node.DeclaringType)
- AnnotateEval(node)
-
- static def IsMarked(node as Node):
- return node.ContainsAnnotation(ContainsEvalAnnotation)
-
- static private def AnnotateEval(node as Node):
- if IsMarked(node): return
- node.Annotate(ContainsEvalAnnotation)
-
static final Evaluator_Eval = typeof(Evaluator).GetMethod("Eval")
_currentMethod as InternalMethod
_evaluationContextLocal as InternalLocal
override def Run():
- if Errors.Count > 0: return
+ return if Errors.Count > 0
Visit(CompileUnit)
override def OnConstructor(node as Constructor):
@@ -37,7 +27,7 @@ class ProcessEvalInvocations(AbstractVisitorCompilerStep):
override def OnMethod(node as Method):
- if not IsMarked(node): return
+ if not EvalAnnotation.IsMarked(node): return
_currentMethod = GetEntity(node)
@@ -48,7 +38,7 @@ class ProcessEvalInvocations(AbstractVisitorCompilerStep):
override def OnReferenceExpression(node as ReferenceExpression):
- entity = TypeSystemServices.GetOptionalEntity(node) as IInternalEntity
+ entity = node.Entity as IInternalEntity
if entity is null: return
field = GetEvaluationContextField(entity.Node)
@@ -57,6 +47,11 @@ class ProcessEvalInvocations(AbstractVisitorCompilerStep):
node.ParentNode.Replace(
node,
CreateEvaluationContextFieldReference(field))
+
+ override def LeaveClassDefinition(node as ClassDefinition):
+ if not EvalAnnotation.IsMarked(node): return
+
+ my(EvaluationDomainProviderImplementor).ImplementIEvaluationDomainProviderOn(node)
def DefineEvaluationContext():
@@ -80,8 +75,8 @@ class ProcessEvalInvocations(AbstractVisitorCompilerStep):
CodeBuilder.CreateAssignment(
CreateEvaluationContextReference(),
CodeBuilder.CreateConstructorInvocation(
- DefaultConstructorFor(evaluationContextType),
- GetSelfReferenceIfInInstanceMethod())))
+ ConstructorTakingNArgumentsFor(evaluationContextType, 1),
+ EvaluationDomainProviderReference())))
for parameter in CurrentMethodNode.Parameters:
// $context.param = param
@@ -92,14 +87,14 @@ class ProcessEvalInvocations(AbstractVisitorCompilerStep):
return initializationBlock
- def GetSelfReferenceIfInInstanceMethod():
- if _currentMethod.IsStatic: return CodeBuilder.CreateNullLiteral()
+ def EvaluationDomainProviderReference():
+ if _currentMethod.IsStatic:
+ staticEvaluationDomainProviderField = my(EvaluationDomainProviderImplementor).StaticEvaluationDomainProviderFor(CurrentTypeNode)
+ return CodeBuilder.CreateReference(staticEvaluationDomainProviderField)
return CodeBuilder.CreateSelfReference(CurrentType)
def CreateEvaluationContextFieldReference(field as InternalField):
- return CodeBuilder.CreateMemberReference(
- CreateEvaluationContextReference(),
- field)
+ return CodeBuilder.CreateMemberReference(CreateEvaluationContextReference(), field)
def CreateEvaluationContextReference():
return CodeBuilder.CreateReference(_evaluationContextLocal)
@@ -137,73 +132,20 @@ class ProcessEvalInvocations(AbstractVisitorCompilerStep):
ctor.Body.Add(superInvocationStmt)
- override def LeaveClassDefinition(node as ClassDefinition):
- if not IsMarked(node): return
-
- ImplementIEvaluationDomainProvider(node)
-
override def LeaveMethodInvocationExpression(node as MethodInvocationExpression):
if not IsEvalInvocation(node): return
+ if not string.IsNullOrEmpty(UnityScriptParameters.DisableEval):
+ Error(node, UnityScriptCompilerErrors.EvalHasBeenDisabled(node.Target.LexicalInfo, UnityScriptParameters.DisableEval))
+ return
+
ReplaceEvalByEvaluatorEval(node)
+ UnityScriptParameters as UnityScript.UnityScriptCompilerParameters:
+ get: return _context.Parameters
+
def IsEvalInvocation(node as MethodInvocationExpression):
- return TypeSystemServices.GetOptionalEntity(node.Target) is UnityScriptTypeSystem.UnityScriptEval
-
- def ImplementIEvaluationDomainProvider(node as ClassDefinition):
- node.BaseTypes.Add(CodeBuilder.CreateTypeReference(IEvaluationDomainProvider))
- ImplementGetEvaluationDomain(node)
- ImplementGetImports(node)
-
- def StringArray():
- return Map(typeof((string)))
-
- def ImplementGetImports(node as ClassDefinition):
- builder = AddVirtualMethod(node, "GetImports", StringArray())
- builder.Body.Add(ReturnStatement(CreateImportsArray(node)))
-
- def CreateImportsArray(node as ClassDefinition):
- items = ExpressionCollection()
- for i in node.EnclosingModule.Imports:
- items.Add(CodeBuilder.CreateStringLiteral(i.Namespace))
- return CodeBuilder.CreateArray(StringArray(), items)
-
- def ImplementGetEvaluationDomain(node as ClassDefinition):
- evaluationDomainType = Map(EvaluationDomain)
- domainField = CodeBuilder.CreateField(Context.GetUniqueName("domain"), evaluationDomainType)
- node.Members.Add(domainField)
-
- builder = AddVirtualMethod(node, "GetEvaluationDomain", evaluationDomainType)
-
- // if _domain is null: _domain = EvaluationDomain()
- ifDomainField = IfStatement(TrueBlock: Block())
- ifDomainField.Condition = CodeBuilder.CreateBoundBinaryExpression(
- TypeSystemServices.BoolType,
- BinaryOperatorType.ReferenceEquality,
- CodeBuilder.CreateReference(domainField),
- CodeBuilder.CreateNullLiteral())
- ifDomainField.TrueBlock.Add(
- CodeBuilder.CreateFieldAssignment(
- domainField,
- CodeBuilder.CreateConstructorInvocation(DefaultConstructorFor(evaluationDomainType))))
-
- builder.Body.Add(ifDomainField)
-
- // return _domain
- builder.Body.Add(ReturnStatement(CodeBuilder.CreateReference(domainField)))
-
- def DefaultConstructorFor(type as IType):
- first, = type.GetConstructors()
- return first
-
- def AddVirtualMethod(node as ClassDefinition, name as string, returnType as IType):
- builder = BooMethodBuilder(
- CodeBuilder,
- name,
- returnType,
- TypeMemberModifiers.Public|TypeMemberModifiers.Virtual)
- node.Members.Add(builder.Method)
- return builder
+ return node.Target.Entity is UnityScriptTypeSystem.UnityScriptEval
def Map(type as System.Type):
return TypeSystemServices.Map(type)
diff --git a/src/UnityScript/Steps/ProcessUnityScriptMethods.boo b/src/UnityScript/Steps/ProcessUnityScriptMethods.boo
index fca306d..68ec27a 100755
--- a/src/UnityScript/Steps/ProcessUnityScriptMethods.boo
+++ b/src/UnityScript/Steps/ProcessUnityScriptMethods.boo
@@ -8,15 +8,17 @@ import Boo.Lang.Compiler.Steps
import Boo.Lang.Environments
+import UnityScript.Core
import UnityScript.Macros
+import UnityScript.TypeSystem
class ProcessUnityScriptMethods(ProcessMethodBodiesWithDuckTyping):
- deferred IEnumerable_GetEnumerator = Types.IEnumerable.GetMethod("GetEnumerator");
+ deferred IEnumerable_GetEnumerator = typeof(System.Collections.IEnumerable).GetMethod("GetEnumerator");
- deferred IEnumerator_MoveNext = Types.IEnumerator.GetMethod("MoveNext");
+ deferred IEnumerator_MoveNext = typeof(System.Collections.IEnumerator).GetMethod("MoveNext");
- deferred IEnumerator_get_Current = Types.IEnumerator.GetProperty("Current").GetGetMethod();
+ deferred IEnumerator_get_Current = typeof(System.Collections.IEnumerator).GetProperty("Current").GetGetMethod();
deferred _StartCoroutine = NameResolutionService.ResolveMethod(UnityScriptTypeSystem.ScriptBaseType, "StartCoroutine_Auto")
@@ -26,19 +28,17 @@ class ProcessUnityScriptMethods(ProcessMethodBodiesWithDuckTyping):
deferred _UnityRuntimeServices_GetTypeOf = ResolveUnityRuntimeMethod("GetTypeOf")
- _strict = false
-
_implicit = false
override def Initialize(context as CompilerContext):
super(context)
-
+
// don't transform
- // foo == null
+ // foo == null
// into:
- // foo is null
+ // foo is null
// but into:
- // foo.Equals(null)
+ // foo.Equals(null)
self.OptimizeNullComparisons = false
def ResolveUnityRuntimeMethod(name as string):
@@ -49,7 +49,7 @@ class ProcessUnityScriptMethods(ProcessMethodBodiesWithDuckTyping):
deferred UnityRuntimeServicesType = TypeSystemServices.Map(UnityScript.Lang.UnityRuntimeServices)
- UnityScriptTypeSystem as UnityScript.Steps.UnityScriptTypeSystem:
+ UnityScriptTypeSystem as UnityScript.TypeSystem.UnityScriptTypeSystem:
get: return self.TypeSystemServices
UnityScriptParameters as UnityScript.UnityScriptCompilerParameters:
@@ -57,26 +57,59 @@ class ProcessUnityScriptMethods(ProcessMethodBodiesWithDuckTyping):
override def GetGeneratorReturnType(generator as InternalMethod):
return TypeSystemServices.IEnumeratorType
-
- override def IsDuckTyped(e as Expression):
- if _strict: return false
- return super(e)
-
- override def IsDuckTyped(member as IMember):
- if _strict: return false
- return super(member)
override protected def MemberNotFound(node as MemberReferenceExpression, ns as INamespace):
- if (not _strict) and (UnityScriptParameters.Expando or super.IsDuckTyped(node.Target)):
- BindQuack(node);
+ if Strict:
+ super(node, ns)
+ else:
+ BindQuack(node)
+
+ override protected def LocalToReuseFor(d as Declaration):
+ if DeclarationAnnotations.ShouldForceNewVariableFor(d):
+ AssertUniqueLocal(d)
+ return null
+ return super(d)
+
+ override def OnModule(module as Module):
+ ActiveModule = module
+ super(module)
+
+ override def VisitMemberPreservingContext(node as TypeMember):
+
+ module = node.EnclosingModule
+ if module is ActiveModule:
+ super(node)
return
- super(node, ns)
- override def OnModule(module as Module):
- Parameters.Strict = _strict = module.ContainsAnnotation("strict")
- _implicit = module.ContainsAnnotation("implicit")
- my(UnityDowncastPermissions).Enabled = module.ContainsAnnotation("downcast")
- super(module)
+ preserving ActiveModule:
+ ActiveModule = module
+ super(node)
+
+ ActiveModule:
+ get: return _activeModule
+ set:
+ _activeModule = value
+ UpdateSettingsForActiveModule()
+
+ _activeModule as Module
+
+ def UpdateSettingsForActiveModule():
+ Parameters.Strict = Pragmas.IsEnabledOn(ActiveModule, Pragmas.Strict)
+ _implicit = Pragmas.IsEnabledOn(ActiveModule, Pragmas.Implicit)
+ my(UnityDowncastPermissions).Enabled = Pragmas.IsEnabledOn(ActiveModule, Pragmas.Downcast)
+ if ShouldDisableImplicitDowncastWarning():
+ Parameters.DisableWarning(ImplicitDowncast)
+ else:
+ Parameters.EnableWarning(ImplicitDowncast)
+
+ def ShouldDisableImplicitDowncastWarning():
+ return not Parameters.Strict or ActiveModule.ContainsAnnotation(Pragmas.Downcast)
+
+ ImplicitDowncast:
+ get: return Boo.Lang.Compiler.CompilerWarningFactory.Codes.ImplicitDowncast
+
+ Strict:
+ get: return Parameters.Strict
override def OnMethod(node as Method):
super(node)
@@ -104,7 +137,7 @@ class ProcessUnityScriptMethods(ProcessMethodBodiesWithDuckTyping):
ContextAnnotations.SetEntryPoint(_context, node)
override def ProcessAutoLocalDeclaration(node as BinaryExpression, reference as ReferenceExpression):
- if (_strict and not _implicit) and not IsCompilerGenerated(reference):
+ if (Strict and not _implicit) and not IsCompilerGenerated(reference):
EmitUnknownIdentifierError(reference, reference.Name)
else:
super(node, reference)
@@ -112,79 +145,78 @@ class ProcessUnityScriptMethods(ProcessMethodBodiesWithDuckTyping):
def IsCompilerGenerated(reference as ReferenceExpression):
return reference.Name.Contains('$')
- override protected def ProcessBuiltinInvocation(function as BuiltinFunction, node as MethodInvocationExpression):
+ override protected def ProcessBuiltinInvocation(node as MethodInvocationExpression, function as BuiltinFunction):
if function is UnityScriptTypeSystem.UnityScriptEval:
- ProcessEvalInvocations.Mark(_currentMethod.Method)
+ EvalAnnotation.Mark(CurrentMethod)
BindExpressionType(node, TypeSystemServices.ObjectType)
return
if function is UnityScriptTypeSystem.UnityScriptTypeof:
ProcessTypeofBuiltin(node);
return
- super(function, node)
+ super(node, function)
private def ProcessTypeofBuiltin(node as MethodInvocationExpression):
if node.Arguments.Count != 1:
Error(node, CompilerError("UCE0001", node.Target.LexicalInfo, "'typeof' takes a single argument.", null))
return
- type = TypeSystemServices.GetOptionalEntity(node.Arguments[0]) as IType
+ type = node.Arguments[0].Entity as IType
if type is not null:
node.ParentNode.Replace(node, CodeBuilder.CreateTypeofExpression(type))
return
node.Target = CodeBuilder.CreateReference(_UnityRuntimeServices_GetTypeOf)
- BindExpressionType(node, TypeSystemServices.TypeType)
-
+ BindExpressionType(node, TypeSystemServices.TypeType)
- override protected def ProcessMethodInvocation(node as MethodInvocationExpression, targetEntity as IEntity):
+ override protected def ProcessMethodInvocation(node as MethodInvocationExpression, method as IMethod):
"""
Automatically detects coroutine invocations in assignments and as standalone
expressions and generates StartCoroutine invocations.
"""
- super(node, targetEntity)
+ super(node, method)
- if not IsPossibleStartCoroutineInvocation(node):
+ if not IsPossibleStartCoroutineInvocationForm(node):
return
- method as IMethod = targetEntity
- if method is null or method.IsStatic: return
-
tss = self.UnityScriptTypeSystem
if not tss.IsScriptType(method.DeclaringType): return
if not tss.IsGenerator(method): return
+ if CurrentMethod.IsStatic:
+ Warnings.Add(UnityScriptWarnings.CannotStartCoroutineFromStaticFunction(node.LexicalInfo, method.Name))
+ return
+
parentNode = node.ParentNode
parentNode.Replace(
node,
CodeBuilder.CreateMethodInvocation(
- TargetForStartCoroutineInvocation(node, method),
+ CodeBuilder.CreateSelfReference(node.LexicalInfo, CurrentType),
_StartCoroutine,
node))
- def TargetForStartCoroutineInvocation(node as MethodInvocationExpression, method as IMethod):
- target = cast(MemberReferenceExpression, node.Target).Target
- if target isa SuperLiteralExpression: // super becomes self for coroutine invocation
- return CodeBuilder.CreateSelfReference(target.LexicalInfo, method.DeclaringType)
- return target.CloneNode()
-
override def ProcessStaticallyTypedAssignment(node as BinaryExpression):
TryToResolveAmbiguousAssignment(node)
ApplyImplicitArrayConversion(node)
- ValidateAssignment(node)
- BindExpressionType(node, GetExpressionType(node.Right))
+ if ValidateAssignment(node):
+ BindExpressionType(node, GetExpressionType(node.Right))
+ else:
+ Error(node)
def ApplyImplicitArrayConversion(node as BinaryExpression):
- left = GetExpressionType(node.Left)
- if not left.IsArray: return
+ leftType = GetExpressionType(node.Left)
+ return unless leftType.IsArray
- right = GetExpressionType(node.Right)
- if right is not TypeSystemServices.Map(UnityScript.Lang.Array): return
+ rightType = GetExpressionType(node.Right)
+ return unless rightType is UnityScriptLangArray()
- node.Right = CodeBuilder.CreateCast(left,
+ node.Right = CodeBuilder.CreateCast(leftType,
CodeBuilder.CreateMethodInvocation(
node.Right,
- ResolveMethod(right, "ToBuiltin"),
- CodeBuilder.CreateTypeofExpression(left.GetElementType())))
+ ResolveMethod(rightType, "ToBuiltin"),
+ CodeBuilder.CreateTypeofExpression(leftType.ElementType)))
+
+ def UnityScriptLangArray():
+ return TypeSystemServices.Map(UnityScript.Lang.Array)
override def OnForStatement(node as ForStatement):
assert 1 == len(node.Declarations)
@@ -199,16 +231,17 @@ class ProcessUnityScriptMethods(ProcessMethodBodiesWithDuckTyping):
VisitForStatementBlock(node)
def ProcessUpdateableIteration(node as ForStatement):
+ originalIterator = node.Iterator
newIterator = CodeBuilder.CreateMethodInvocation(_UnityRuntimeServices_GetEnumerator, node.Iterator)
newIterator.LexicalInfo = LexicalInfo(node.Iterator.LexicalInfo)
node.Iterator = newIterator
- ProcessDeclarationForIterator(node.Declarations[0], TypeSystemServices.ObjectType)
+ ProcessDeclarationForIterator(node.Declarations[0], GetEnumeratorItemType(GetExpressionType(originalIterator)))
VisitForStatementBlock(node)
TransformIteration(node)
def TransformIteration(node as ForStatement):
iterator = CodeBuilder.DeclareLocal(
- _currentMethod.Method,
+ CurrentMethod,
_context.GetUniqueName("iterator"),
TypeSystemServices.IEnumeratorType)
iterator.IsUsed = true
@@ -283,5 +316,5 @@ class ProcessUnityScriptMethods(ProcessMethodBodiesWithDuckTyping):
override def OnReferenceExpression(node as ReferenceExpression):
if _found: return
- referent = _context.TypeSystemServices.GetOptionalEntity(node)
+ referent = node.Entity
_found = referent is _loopVariable
diff --git a/src/UnityScript/Steps/SuppressWarnings.boo b/src/UnityScript/Steps/SuppressWarnings.boo
index 46143c3..5686120 100755
--- a/src/UnityScript/Steps/SuppressWarnings.boo
+++ b/src/UnityScript/Steps/SuppressWarnings.boo
@@ -5,9 +5,9 @@ import Boo.Lang.Compiler.Steps
class SuppressWarnings(AbstractCompilerStep):
- _suppressed as Boo.Lang.List
+ _suppressed as List of string
- def constructor(suppressed as Boo.Lang.List):
+ def constructor(suppressed as List of string):
_suppressed = suppressed
override def Run():
diff --git a/src/UnityScript/Steps/UnityCallableResolutionService.boo b/src/UnityScript/Steps/UnityCallableResolutionService.boo
deleted file mode 100755
index 6783679..0000000
--- a/src/UnityScript/Steps/UnityCallableResolutionService.boo
+++ /dev/null
@@ -1,19 +0,0 @@
-namespace UnityScript.Steps
-
-import Boo.Lang.Compiler
-import Boo.Lang.Compiler.Ast
-import Boo.Lang.Compiler.TypeSystem
-
-class UnityCallableResolutionService(CallableResolutionService):
-
- def constructor(context as CompilerContext):
- super(context)
-
- override def CheckVarArgsParameter(parameters as (IParameter), args as ExpressionCollection):
- return super(parameters, args)
-
- override def ShouldExpandArgs(method as IMethod, args as ExpressionCollection):
- parameters = method.GetParameters()
- if len(parameters) == len(args) and parameters[-1].Type == ArgumentType(args[-1]):
- return false
- return super(method, args)
diff --git a/src/UnityScript/Steps/UnityExpandVarArgsMethodInvocations.boo b/src/UnityScript/Steps/UnityExpandVarArgsMethodInvocations.boo
deleted file mode 100755
index 1a27e98..0000000
--- a/src/UnityScript/Steps/UnityExpandVarArgsMethodInvocations.boo
+++ /dev/null
@@ -1,13 +0,0 @@
-namespace UnityScript.Steps
-
-import Boo.Lang.Compiler.Steps
-import Boo.Lang.Compiler.Ast
-import Boo.Lang.Compiler.TypeSystem
-
-class UnityExpandVarArgsMethodInvocations(ExpandVarArgsMethodInvocations):
-
- override def ExpandInvocation(node as MethodInvocationExpression, parameters as (IParameter)):
- args = node.Arguments
- if len(args) == len(parameters) and GetExpressionType(args[-1]) == parameters[-1].Type:
- return
- super(node, parameters)
diff --git a/src/UnityScript/Steps/Utilities.boo b/src/UnityScript/Steps/Utilities.boo
index 4a4c3b5..ae81266 100755
--- a/src/UnityScript/Steps/Utilities.boo
+++ b/src/UnityScript/Steps/Utilities.boo
@@ -2,20 +2,36 @@ namespace UnityScript.Steps
import Boo.Lang.Compiler
import Boo.Lang.Compiler.Ast
+import Boo.Lang.Compiler.TypeSystem
+import PatternMatching
def IsRhsOfAssignment(node as Expression):
- be = node.ParentNode as BinaryExpression
- if be is null: return false
- if be.Operator != BinaryOperatorType.Assign: return false
- return be.Right is node
+ match node.ParentNode:
+ case BinaryExpression(Operator: BinaryOperatorType.Assign, Right: rhs) and rhs is node:
+ return true
+ otherwise:
+ return false
-def IsPossibleStartCoroutineInvocation(node as MethodInvocationExpression):
- if node.ParentNode isa ExpressionStatement: return true
- if node.ParentNode isa YieldStatement: return true
- return IsRhsOfAssignment(node)
+def IsPossibleStartCoroutineInvocationForm(node as MethodInvocationExpression):
+ match node:
+ case Node(ParentNode: ExpressionStatement() | YieldStatement()) or IsRhsOfAssignment(node):
+ return true
+ /*
+ case Node(ParentNode: DeclarationStatement(Initializer: initializer)) and node is initializer:
+ return true
+ */
+ otherwise:
+ return false
def SetScriptClass(context as CompilerContext, klass as ClassDefinition):
context["ScriptClass"] = klass
def GetScriptClass(context as CompilerContext) as ClassDefinition:
return context["ScriptClass"]
+
+def ConstructorTakingNArgumentsFor(type as IType, arguments as int):
+ for ctor in type.GetConstructors():
+ return ctor if len(ctor.GetParameters()) == arguments
+ raise "no constructor in $type taking $arguments arguments"
+
+
diff --git a/src/UnityScript/TypeSystem/UnityCallableResolutionService.boo b/src/UnityScript/TypeSystem/UnityCallableResolutionService.boo
new file mode 100755
index 0000000..7410727
--- /dev/null
+++ b/src/UnityScript/TypeSystem/UnityCallableResolutionService.boo
@@ -0,0 +1,26 @@
+namespace UnityScript.TypeSystem
+
+import Boo.Lang.Compiler.Ast
+import Boo.Lang.Compiler.TypeSystem
+import Boo.Lang.Compiler.TypeSystem.Core
+
+class UnityCallableResolutionService(CallableResolutionService):
+
+ override def CheckVarArgsParameter(parameters as (IParameter), args as ExpressionCollection):
+ if IsArrayArgumentExplicitlyProvided(parameters, args):
+ return true
+ return super(parameters, args)
+
+ override def ShouldExpandArgs(method as IMethod, args as ExpressionCollection):
+ parameters = method.GetParameters()
+ if IsArrayArgumentExplicitlyProvided(parameters, args):
+ return false
+ return super(method, args)
+
+def IsArrayArgumentExplicitlyProvided(parameters as (IParameter), args as ExpressionCollection):
+ if len(parameters) != len(args):
+ return false
+
+ lastArgType = TypeSystemServices.GetExpressionType(args[-1])
+ lastParamType = parameters[-1].Type
+ return lastArgType == lastParamType or lastArgType == EmptyArrayType.Default
diff --git a/src/UnityScript/Steps/UnityDowncastPermissions.boo b/src/UnityScript/TypeSystem/UnityDowncastPermissions.boo
similarity index 62%
rename from src/UnityScript/Steps/UnityDowncastPermissions.boo
rename to src/UnityScript/TypeSystem/UnityDowncastPermissions.boo
index d96f076..e8f5544 100755
--- a/src/UnityScript/Steps/UnityDowncastPermissions.boo
+++ b/src/UnityScript/TypeSystem/UnityDowncastPermissions.boo
@@ -1,20 +1,20 @@
-namespace UnityScript.Steps
+namespace UnityScript.TypeSystem
import Boo.Lang.Compiler.TypeSystem
import Boo.Lang.Compiler.TypeSystem.Services
class UnityDowncastPermissions(DowncastPermissions):
- [property(Enabled)] _enabled = false
+ property Enabled = false
override def CanBeReachedByDowncast(expectedType as IType, actualType as IType):
if expectedType.IsArray and actualType.IsArray and IsDowncastAllowed():
return CanBeReachedByArrayDowncast(expectedType, actualType)
return super(expectedType, actualType)
-
- override protected def IsDowncastAllowed():
- return _enabled or super()
+ override def IsDowncastAllowed():
+ return Enabled or super()
+
private def CanBeReachedByArrayDowncast(expectedType as IArrayType, actualType as IArrayType):
- return expectedType.GetArrayRank() == actualType.GetArrayRank() \
- and CanBeReachedByDowncast(expectedType.GetElementType(), actualType.GetElementType())
+ return expectedType.Rank == actualType.Rank \
+ and CanBeReachedByDowncast(expectedType.ElementType, actualType.ElementType)
diff --git a/src/UnityScript/TypeSystem/UnityScriptAmbiance.boo b/src/UnityScript/TypeSystem/UnityScriptAmbiance.boo
new file mode 100644
index 0000000..4cb1229
--- /dev/null
+++ b/src/UnityScript/TypeSystem/UnityScriptAmbiance.boo
@@ -0,0 +1,30 @@
+namespace UnityScript.TypeSystem
+
+import Boo.Lang.Compiler.Services
+
+class UnityScriptAmbiance(LanguageAmbiance):
+
+ override def DefaultGeneratorTypeFor(typeName as string):
+ return "IEnumerator"
+
+ override SelfKeyword:
+ get: return "this"
+
+ override IsaKeyword:
+ get: return "instanceof"
+
+ override IsKeyword:
+ get: return "==="
+
+ override ExceptKeyword:
+ get: return "catch"
+
+ override EnsureKeyword:
+ get: return "finally"
+
+ override RaiseKeyword:
+ get: return "throw"
+
+ override CallableKeyword:
+ get: return "function"
+
diff --git a/src/UnityScript/TypeSystem/UnityScriptEntityFormatter.boo b/src/UnityScript/TypeSystem/UnityScriptEntityFormatter.boo
new file mode 100644
index 0000000..bd53418
--- /dev/null
+++ b/src/UnityScript/TypeSystem/UnityScriptEntityFormatter.boo
@@ -0,0 +1,25 @@
+namespace UnityScript.TypeSystem
+
+import Boo.Lang.Compiler.TypeSystem
+import Boo.Lang.Compiler.TypeSystem.Services
+import Boo.Lang.PatternMatching
+
+class UnityScriptEntityFormatter(EntityFormatter):
+
+ override def FormatType(type as IType) as string:
+ match type:
+ case IArrayType(ElementType, Rank):
+ return "$(FormatType(ElementType))[$(',' * (Rank - 1))]"
+ case ICallableType():
+ return FormatCallableType(type)
+ otherwise:
+ return super(type)
+
+ override def FormatGenericArguments(genericArgs as string*):
+ return ".<$(join(genericArgs, ', '))>"
+
+ def FormatCallableType(type as ICallableType):
+ signature = type.GetSignature()
+ parameters = join(FormatType(p.Type) for p in signature.Parameters, ", ")
+ returnType = FormatType(signature.ReturnType)
+ return "function($parameters): $returnType"
diff --git a/src/UnityScript/Steps/UnityScriptTypeSystem.boo b/src/UnityScript/TypeSystem/UnityScriptTypeSystem.boo
old mode 100755
new mode 100644
similarity index 84%
rename from src/UnityScript/Steps/UnityScriptTypeSystem.boo
rename to src/UnityScript/TypeSystem/UnityScriptTypeSystem.boo
index 09e9412..80c6552
--- a/src/UnityScript/Steps/UnityScriptTypeSystem.boo
+++ b/src/UnityScript/TypeSystem/UnityScriptTypeSystem.boo
@@ -1,6 +1,5 @@
-namespace UnityScript.Steps
+namespace UnityScript.TypeSystem
-import Boo.Lang.Compiler
import Boo.Lang.Compiler.TypeSystem
class UnityScriptTypeSystem(TypeSystemServices):
@@ -13,14 +12,12 @@ class UnityScriptTypeSystem(TypeSystemServices):
_ScriptBaseType as IType
_AbstractGenerator as IType
- def constructor(context as CompilerContext):
- super(context)
+ def constructor():
self._ScriptBaseType = Map(UnityScriptParameters.ScriptBaseType)
self._AbstractGenerator = Map(Boo.Lang.AbstractGenerator)
- UnityScriptParameters:
- get:
- return cast(UnityScript.UnityScriptCompilerParameters, self.Context.Parameters)
+ UnityScriptParameters as UnityScript.UnityScriptCompilerParameters:
+ get: return self.Context.Parameters
def IsScriptType(type as IType):
return type.IsSubclassOf(_ScriptBaseType)
@@ -28,13 +25,9 @@ class UnityScriptTypeSystem(TypeSystemServices):
def IsGenerator(method as IMethod):
rt = method.ReturnType
if rt is IEnumeratorType: return true
-
// for backwards compatibility
return rt.IsSubclassOf(self._AbstractGenerator)
- override def IsModule(type as System.Type):
- return false
-
override def CanBeReachedByPromotion(expected as IType, actual as IType):
result = super(expected, actual)
if result: return true
@@ -58,9 +51,9 @@ class UnityScriptTypeSystem(TypeSystemServices):
AddPrimitiveType("uint", UIntType)
AddPrimitiveType("long", LongType)
AddPrimitiveType("ulong", ULongType)
+ AddPrimitiveType("Number", DoubleType)
AddPrimitiveType("float", SingleType)
AddPrimitiveType("double", DoubleType)
- AddPrimitiveType("Number", DoubleType)
AddPrimitiveType("Function", ICallableType)
AddPrimitiveType("Array", Map(UnityScript.Lang.Array))
diff --git a/src/UnityScript/UnityScript.booproj b/src/UnityScript/UnityScript.booproj
index 46825b2..13340fa 100755
--- a/src/UnityScript/UnityScript.booproj
+++ b/src/UnityScript/UnityScript.booproj
@@ -1,5 +1,5 @@
-
+
Debug
AnyCPU
@@ -20,6 +20,7 @@
false
false
+ false
none
@@ -28,14 +29,15 @@
false
false
+ false
-
-
-
-
-
+
+
+
+
+
@@ -61,7 +63,6 @@
-
@@ -70,11 +71,21 @@
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -82,4 +93,11 @@
UnityScript.Lang
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/UnityScript/UnityScript.g b/src/UnityScript/UnityScript.g
index 47c49ad..f12798a 100755
--- a/src/UnityScript/UnityScript.g
+++ b/src/UnityScript/UnityScript.g
@@ -20,15 +20,19 @@ options
k = 2;
exportVocab = UnityScript;
defaultErrorHandler = true;
+ classHeaderPrefix = "partial";
}
tokens
{
AS="as";
BREAK="break";
+ CAST="cast";
CATCH="catch";
CLASS="class";
CONTINUE="continue";
+ DO="do";
ELSE="else";
+ EACH="each";
ENUM="enum";
EXTENDS="extends";
FALSE="false";
@@ -52,7 +56,6 @@ tokens
INTERNAL="internal";
OVERRIDE="override";
PARTIAL="partial";
- PRAGMA="pragma";
PRIVATE="private";
SET="set";
STATIC="static";
@@ -76,6 +79,10 @@ tokens
INPLACE_ADD="+=";
INPLACE_SUBTRACT="-=";
INPLACE_MULTIPLY="*=";
+ SL_COMMENT="//";
+
+ PRAGMA_ON="pragma on";
+ PRAGMA_OFF="pragma off";
/* lexer token definitions */
ID="an identifier";
@@ -101,16 +108,13 @@ tokens
INCREMENT="++";
DECREMENT="--";
ADD="+";
- INPLACE_ADD="+=";
SUBTRACT="-";
- INPLACE_SUBTRACT="-=";
MODULUS="%";
MULTIPLY="*";
EQUALITY="==";
INEQUALITY="!=";
- NOT="!";
QUESTION_MARK="?";
- ONES_COMPLEMENT="~";
+ BITWISE_NOT="~";
REFERENCE_EQUALITY="===";
REFERENCE_INEQUALITY="!==";
LESS_THAN="<";
@@ -123,6 +127,7 @@ tokens
INPLACE_SHIFT_RIGHT=">>=";
AT="@";
SCRIPT_ATTRIBUTE_MARKER="@script";
+ ASSEMBLY_ATTRIBUTE_MARKER="@assembly";
}
{
[property(CompilerContext)]
@@ -161,7 +166,7 @@ tokens
return node.ContainsAnnotation("LabelInUse")
def FlushAttributes(node as INodeWithAttributes):
- node.Attributes.Extend(_attributes)
+ node.Attributes.AddRange(_attributes)
_attributes.Clear()
def GlobalVariablesBecomeFields():
@@ -170,9 +175,6 @@ tokens
UnityScriptParameters as UnityScriptCompilerParameters:
get: return _context.Parameters
- static def ToLexicalInfo(token as antlr.IToken):
- return LexicalInfo(token.getFilename(), token.getLine(), token.getColumn())
-
static def SetEndSourceLocation(node as Node, token as antlr.IToken):
node.EndSourceLocation = ToSourceLocation(token)
@@ -180,9 +182,9 @@ tokens
text = token.getText()
tokenLength = (0 if text is null else len(text)-1)
return SourceLocation(token.getLine(), token.getColumn()+tokenLength)
-
- static def ParseDouble(text as string):
- return double.Parse(text, CultureInfo.InvariantCulture)
+
+ static def ToLexicalInfo(token as antlr.IToken):
+ return LexicalInfo(token.getFilename(), token.getLine(), token.getColumn())
static def ParseIntegerLiteralExpression(token as antlr.IToken,
s as string,
@@ -213,6 +215,9 @@ tokens
protected def VirtualKeywordHasNoEffect(token as antlr.IToken):
_context.Warnings.Add(UnityScriptWarnings.VirtualKeywordHasNoEffect(ToLexicalInfo(token)))
+ protected def UnexpectedToken(token as antlr.IToken):
+ ReportError(CompilerErrorFactory.UnexpectedToken(ToLexicalInfo(token), null, token.getText()))
+
protected def KeywordCannotBeUsedAsAnIdentifier(token as antlr.IToken):
ReportError(UnityScriptCompilerErrors.KeywordCannotBeUsedAsAnIdentifier(ToLexicalInfo(token), token.getText()))
@@ -226,30 +231,53 @@ tokens
li = ToLexicalInfo(LT(1))
ReportError(UnityScriptCompilerErrors.SemicolonExpected(li))
- static def CreateModuleName(fname as string):
- return System.IO.Path.GetFileNameWithoutExtension(fname)
+ static def IsConstructorName(name as string, type as TypeDefinition):
+ return type.NodeType != NodeType.Module and name == type.Name
- static final ValidPragmas = ("strict", "expando", "implicit", "downcast")
-
+ def AddFunctionTo(type as TypeDefinition, nameToken as IToken, getter as IToken, setter as IToken):
+
+ name = nameToken.getText()
+ location = ToLexicalInfo(nameToken)
+
+ function as Method = (Constructor(location) if IsConstructorName(name, type) else Method(location, Name: name))
+ if getter is not null or setter is not null:
+ p = type.Members[name] as Property
+ if p is null:
+ p = Property(location, Name: name)
+ type.Members.Add(p)
+ if getter is not null:
+ assert p.Getter is null
+ p.Getter = function
+ else:
+ assert p.Setter is null
+ p.Setter = function
+ FlushAttributes(p)
+ else:
+ type.Members.Add(function)
+ FlushAttributes(function)
+ return function
}
start[CompileUnit cu]
{
- module = Module(LexicalInfo(getFilename(), 1, 1))
- module.Name = CreateModuleName(getFilename())
+ module = CodeFactory.NewModule(getFilename())
cu.Modules.Add(module)
+ globals = module.Globals
}:
(
import_directive[module]
| pragma_directive[module]
+ | (AT ID ID)=> script_or_assembly_attribute[module]
)*
(
+ (AT ID ID)=> script_or_assembly_attribute[module]
+ |
(
attributes
module_member[module]
)
| module_member[module]
- | global_statement[module]
+ | compound_or_single_stmt[globals]
)*
eof:EOF
{
@@ -257,52 +285,17 @@ start[CompileUnit cu]
}
;
-attribute_parameter_value returns [Expression e]
-{
-}:
- e=integer_literal
- | e=string_literal
- //| e=array_literal
- | e=bool_literal
- | e=null_literal
- | e=double_literal
- | e=attribute_parameter_value_bitwise_expression
- | e=typeof_expression
-;
-
-attribute_parameter_value_bitwise_expression returns [Expression e]
-{
-}:
- e=attribute_parameter_value_reference_expression
- (
- op:BITWISE_OR
- rhs=attribute_parameter_value_reference_expression
- {
- e = BinaryExpression(ToLexicalInfo(op),
- Operator: BinaryOperatorType.BitwiseOr,
- Left: e,
- Right: rhs)
- }
- )*
-;
-
-attribute_parameter_value_reference_expression returns [Expression e]
-{
-}:
- e=reference_expression
-;
-
attribute_parameter[Ast.Attribute attr]
{
}:
(ID ASSIGN)=>(
- name=reference_expression ASSIGN value=attribute_parameter_value
+ name=reference_expression ASSIGN value=expression
{
attr.NamedArguments.Add(ExpressionPair(name, value))
}
) |
(
- value=attribute_parameter_value
+ value=expression
{
attr.Arguments.Add(value)
}
@@ -345,32 +338,39 @@ attribute_constructor returns [Boo.Lang.Compiler.Ast.Attribute attr]
)?
;
-module_member[Module m]
+module_member[Module module]
{
+ globals = module.Globals
}:
- class_declaration[m]
- | interface_declaration[m]
- | enum_declaration[m]
- | module_function_or_field[m]
- | script_attribute[m]
-;
-script_attribute[Module m]
-{
-}:
- SCRIPT_ATTRIBUTE_MARKER
- attr=attribute_constructor
- { m.Attributes.Add(attr); }
+ {GlobalVariablesBecomeFields()}? (module_member_modifiers VAR) => module_field[module]
+ | (declaration_statement[globals] eos)
+ |
+ (
+ mod=module_member_modifiers
+ (
+ mm=class_declaration[module]
+ | mm=interface_declaration[module]
+ | mm=enum_declaration[module]
+ | mm=function_member[module]
+ )
+ { mm.Modifiers |= mod if mm is not null }
+ )
;
-module_function_or_field[Module m]
+script_or_assembly_attribute[Module m]
{
- globals = m.Globals
}:
-
- {GlobalVariablesBecomeFields()}? (module_member_modifiers VAR) => module_field[m]
- | declaration_statement[globals] eos
- | module_function[m]
+ AT attributeKindToken:ID attr=attribute_constructor
+ {
+ attributeKind = attributeKindToken.getText()
+ if attributeKind == "assembly":
+ m.AssemblyAttributes.Add(attr)
+ elif attributeKind == "script":
+ m.Attributes.Add(attr)
+ else:
+ UnexpectedToken(attributeKindToken)
+ }
;
module_field[Module m]
@@ -381,31 +381,6 @@ module_field[Module m]
{ f.Modifiers |= mod }
;
-global_statement[Module m]
-{
- b = m.Globals
-}:
- (
- while_statement[b] |
- for_statement[b] |
- if_statement[b] |
- try_statement[b] |
- switch_statement[b]
- ) |
- (
- (
- expression_statement[b] |
- yield_statement[b] |
- return_statement[b] |
- break_statement[b] |
- continue_statement[b] |
- throw_statement[b] |
- declaration_statement[b]
- )
- eos
- )
-;
-
qname returns [Token id]
{
}:
@@ -431,29 +406,35 @@ qname returns [Token id]
pragma_directive[Module container]
{
}:
- HASH PRAGMA id:ID
+ (on:PRAGMA_ON { id=on } | off:PRAGMA_OFF { id=off })
{
pragma = id.getText()
- if pragma not in ValidPragmas:
+ if Pragmas.IsValid(pragma):
+ if on is not null:
+ Pragmas.TryToEnableOn(container, pragma)
+ else:
+ Pragmas.DisableOn(container, pragma)
+ else:
ReportError(UnityScriptCompilerErrors.UnknownPragma(ToLexicalInfo(id), pragma))
- container.Annotate(pragma)
}
;
import_directive[Module container]
{
}:
- IMPORT ns=qname eos
+ imp:IMPORT ns=qname eos
{
container.Imports.Add(
- Import(ToLexicalInfo(ns), Namespace: ns.getText()))
+ Import(ToLexicalInfo(imp), ReferenceExpression(ToLexicalInfo(ns), ns.getText())))
}
;
-eos:
+eos returns [antlr.IToken firstEOS]:
(
- (options { greedy = true; }: EOS)+ |
- { SemicolonExpected() }
+ (options { greedy = true; }:
+ t:EOS { if firstEOS is null: firstEOS = t }
+ )+
+ | { SemicolonExpected() }
)
;
@@ -489,12 +470,12 @@ member_modifiers returns [TypeMemberModifiers m]
)*
;
-class_declaration[TypeDefinition parent]
+class_declaration[TypeDefinition parent] returns [TypeMember member]
{
}:
(p:PARTIAL)? CLASS name:ID (EXTENDS baseType=type_reference)?
{
- cd = ClassDefinition(ToLexicalInfo(name), Name: name.getText())
+ member = cd = ClassDefinition(ToLexicalInfo(name), Name: name.getText())
baseTypes = cd.BaseTypes
if baseType is not null:
@@ -520,23 +501,24 @@ class_declaration[TypeDefinition parent]
(attributes)?
(mod=member_modifiers)?
(
- m=function_member[cd] |
- m=field_member[cd]
+ m=function_member[cd]
+ | m=field_member[cd]
+ | m=enum_declaration[cd]
+ | m=class_declaration[cd]
+ | m=interface_declaration[cd]
)
- {
- m.Modifiers |= mod if m is not null
- }
+ { m.Modifiers |= mod if m is not null }
)*
rbrace:RBRACE { SetEndSourceLocation(cd, rbrace) }
(EOS)*
;
-interface_declaration[TypeDefinition parent]
+interface_declaration[TypeDefinition parent] returns [TypeMember member]
{
}:
INTERFACE name:ID
{
- td = InterfaceDefinition(ToLexicalInfo(name), Name: name.getText())
+ member = td = InterfaceDefinition(ToLexicalInfo(name), Name: name.getText())
baseTypes = td.BaseTypes
FlushAttributes(td)
parent.Members.Add(td)
@@ -554,25 +536,24 @@ interface_declaration[TypeDefinition parent]
interface_member[TypeDefinition parent]
{
}:
- FUNCTION name:ID
+ FUNCTION (getter:GET | setter:SET)? memberName=identifier
{
- method = Method(ToLexicalInfo(name), Name: name.getText())
- FlushAttributes(method)
- parent.Members.Add(method)
+ function = AddFunctionTo(parent, memberName, getter, setter)
}
- LPAREN (parameter_declaration_list[method])? RPAREN
+ LPAREN (parameter_declaration_list[function])? RPAREN
(
- COLON tr=type_reference { method.ReturnType = tr; }
+ COLON tr=type_reference { function.ReturnType = tr; }
)?
(EOS)*
;
-enum_declaration [TypeDefinition container]
+enum_declaration [TypeDefinition container] returns [TypeMember member]
{
}:
ENUM name:ID
{
- ed = EnumDefinition(ToLexicalInfo(name), Name: name.getText())
+ member = ed = EnumDefinition(ToLexicalInfo(name), Name: name.getText())
+ FlushAttributes(member);
container.Members.Add(ed)
}
LBRACE
@@ -591,90 +572,45 @@ enum_declaration [TypeDefinition container]
enum_member [EnumDefinition container]
{
}:
- name:ID (ASSIGN initializer=integer_literal)?
+ (attributes)?
+ name=identifier (ASSIGN initializer=integer_literal)?
{
- em = EnumMember(ToLexicalInfo(name),
- Name: name.getText(),
- Initializer: initializer)
+ em = EnumMember(ToLexicalInfo(name), Name: name.getText(), Initializer: initializer)
+ FlushAttributes(em)
container.Members.Add(em)
}
;
-member_name returns [antlr.IToken token]
+identifier returns [antlr.IToken token]
{
}:
name:ID { token = name; }
| f:FINAL { token = f; KeywordCannotBeUsedAsAnIdentifier(token); }
+ | i:INTERNAL { token = i; KeywordCannotBeUsedAsAnIdentifier(token); }
+ | e:EACH { token = e; }
;
field_member[TypeDefinition cd] returns [TypeMember member]
{
}:
- VAR name=member_name (COLON tr=type_reference)? (ASSIGN initializer=expression)? eos
+ VAR name=identifier (COLON tr=type_reference)? (ASSIGN initializer=expression)? finalToken=eos
{
member = Field(ToLexicalInfo(name),
Name: name.getText(),
Type: tr,
Initializer: initializer)
+ if finalToken is not null: SetEndSourceLocation(member, finalToken)
FlushAttributes(member)
cd.Members.Add(member)
}
;
-function_member[ClassDefinition cd] returns [TypeMember member]
+function_member[TypeDefinition cd] returns [TypeMember member]
{
}:
- FUNCTION (getter:GET | setter:SET)? memberName=member_name
- {
- method as Method
- if memberName.getText() == cd.Name:
- member = method = Constructor(ToLexicalInfo(memberName))
- else:
- member = method = Method(ToLexicalInfo(memberName), Name: memberName.getText())
-
- if getter is not null or setter is not null:
- p = cd.Members[memberName.getText()] as Property
- if p is null:
- p = Property(ToLexicalInfo(memberName), Name: memberName.getText())
- cd.Members.Add(p)
- if getter is not null:
- p.Getter = method
- else:
- p.Setter = method
- FlushAttributes(p)
- else:
- cd.Members.Add(method)
- FlushAttributes(method)
- }
-
- function_body[method]
-
- {
- // TODO: move this error checking to a compiler step
- // as well as properly checking the type of the accessors
- // against the type of the property
- if setter is not null:
- if method.Parameters.Count != 1 or method.Parameters[0].Name != "value":
- ReportError(UnityScriptCompilerErrors.InvalidPropertySetter(ToLexicalInfo(memberName)))
- method.Parameters.Clear()
- if getter is not null:
- if method.Parameters.Count > 0:
- ReportError(UnityScriptCompilerErrors.InvalidPropertySetter(ToLexicalInfo(memberName)))
- }
-;
-
-module_function[TypeDefinition parent]
-{
-}:
- mod=module_member_modifiers
- FUNCTION name:ID
- {
- method = Method(ToLexicalInfo(name), Name: name.getText())
- method.Modifiers = mod
- FlushAttributes(method)
- parent.Members.Add(method)
- }
- function_body[method]
+ FUNCTION (getter:GET | setter:SET)? memberName=identifier
+ { member = function = AddFunctionTo(cd, memberName, getter, setter) }
+ function_body[function]
;
function_body[Method method]
@@ -701,10 +637,11 @@ parameter_declaration_list[INodeWithParameters m]
parameter_declaration[INodeWithParameters m]
{
}:
- id:ID (COLON tr=type_reference)?
+ (attributes)? id=identifier (COLON tr=type_reference)?
{
parameter = ParameterDeclaration(ToLexicalInfo(id), Name: id.getText(), Type: tr)
m.Parameters.Add(parameter)
+ FlushAttributes(parameter)
}
;
@@ -726,15 +663,23 @@ block[Block b]
{
}:
LBRACE
- (statement[b])*
+ (compound_or_single_stmt[b])*
rbrace:RBRACE { SetEndSourceLocation(b, rbrace) }
;
statement[Block b]
{
}:
- (
+ (macro_application_test) => macro_application_block[b]
+ | builtin_statement[b]
+ | (EOS)+
+;
+builtin_statement[Block b]
+{
+}:
+ (
+ do_while_statement[b] |
while_statement[b] |
for_statement[b] |
if_statement[b] |
@@ -752,9 +697,6 @@ statement[Block b]
declaration_statement[b]
)
eos
- ) |
- (
- (EOS)+
)
;
@@ -772,30 +714,23 @@ yield_statement[Block b]
{
}:
yt:YIELD (e=expression)?
- {
- b.Add(YieldStatement(ToLexicalInfo(yt), Expression: e))
- }
+ { b.Add(YieldStatement(ToLexicalInfo(yt), Expression: e)) }
;
return_statement[Block b]
{
}:
ret:RETURN (e=expression)?
- {
- b.Add(ReturnStatement(ToLexicalInfo(ret), Expression: e))
- }
+ { b.Add(ReturnStatement(ToLexicalInfo(ret), Expression: e)) }
;
break_statement[Block b]
{
}:
t:BREAK
- {
- b.Add(BreakStatement(ToLexicalInfo(t)))
- }
+ { b.Add(BreakStatement(ToLexicalInfo(t))) }
;
-
continue_statement[Block b]
{
}:
@@ -815,9 +750,7 @@ throw_statement[Block b]
{
}:
t:THROW (e=expression)?
- {
- b.Add(RaiseStatement(ToLexicalInfo(t), Exception: e))
- }
+ { b.Add(RaiseStatement(ToLexicalInfo(t), Exception: e)) }
;
@@ -825,23 +758,25 @@ expression_statement[Block b]
{
}:
e=assignment_expression
- {
- b.Add(ExpressionStatement(e))
- }
+ { b.Add(ExpressionStatement(e)) }
;
for_statement [Block container]
{
}:
f:FOR
- LPAREN
(
- ((ID | declaration) IN)=>stmt=for_in[container]
- | stmt=for_c[container]
+ (EACH LPAREN stmt=for_in[container])
+ |
+ (
+ LPAREN
+ (
+ ((identifier | declaration) IN) => stmt=for_in[container]
+ | stmt=for_c[container]
+ )
+ )
)
- {
- stmt.LexicalInfo = ToLexicalInfo(f) if stmt is not null
- }
+ { stmt.LexicalInfo = ToLexicalInfo(f) if stmt is not null }
;
for_c [Block container] returns [Statement stmt]
@@ -887,13 +822,8 @@ for_in [Block container] returns [Statement stmt]
{
}:
(
- (
- id:ID
- {
- d = Declaration(ToLexicalInfo(id), Name: id.getText())
- }
- )
- | d=declaration
+ (id=identifier { d = Declaration(ToLexicalInfo(id), Name: id.getText()) })
+ | d=declaration { DeclarationAnnotations.ForceNewVariable(d) }
)
IN iterator=expression
{
@@ -915,11 +845,34 @@ for_in [Block container] returns [Statement stmt]
declaration returns [Declaration d]
{
}:
- VAR id:ID (COLON tr=type_reference)?
+ VAR id=identifier (COLON tr=type_reference)?
+ {
+ d = Declaration(ToLexicalInfo(id), Name: id.getText(), Type: tr)
+ }
+;
+
+macro_application_test
+{
+}:
+ (member LBRACE)
+ | (member expression_list[null] LBRACE)
+;
+
+macro_application_block[Block container]
+{
+ m = MacroStatement()
+ args = m.Arguments
+ b = m.Body
+}:
+ macroName=member
+ (
+ (LBRACE) => compound_statement[b]
+ | (expression_list[args] compound_statement[b])
+ )
{
- d = Declaration(ToLexicalInfo(id))
- d.Name = id.getText()
- d.Type = tr
+ m.LexicalInfo = ToLexicalInfo(macroName)
+ m.Name = macroName.getText()
+ container.Add(m)
}
;
@@ -939,6 +892,24 @@ while_statement[Block container]
}
;
+do_while_statement[Block container]
+{
+}:
+ d:DO
+ {
+ ws = WhileStatement(ToLexicalInfo(d), Condition: BoolLiteralExpression(true))
+ b = ws.Block
+ container.Add(ws)
+ EnterLoop(ws)
+ }
+ block[b]
+ w:WHILE e=paren_expression eos
+ {
+ b.Add(BreakStatement(ToLexicalInfo(w), Modifier: StatementModifier(StatementModifierType.Unless, e)))
+ LeaveLoop(ws)
+ }
+;
+
switch_statement[Block container]
{
}:
@@ -989,29 +960,21 @@ try_statement[Block container]
}
compound_or_single_stmt[b]
(
- (
- ct:CATCH LPAREN id:ID (COLON tr=type_reference)? RPAREN
- {
- tr = SimpleTypeReference(ToLexicalInfo(id), "System.Exception") if tr is null
- handler = ExceptionHandler(
- ToLexicalInfo(ct),
- Declaration: Declaration(
- ToLexicalInfo(id),
- Name: id.getText(),
- Type: tr))
- s.ExceptionHandlers.Add(handler)
- b = handler.Block
- tr = null
- }
- compound_or_single_stmt[b]
- )+
- (
- finally_block[s]
- )?
- ) |
+ ct:CATCH LPAREN id:ID (COLON tr=type_reference)? RPAREN
+ {
+ tr = SimpleTypeReference(ToLexicalInfo(id), "System.Exception") if tr is null
+ handler = ExceptionHandler(
+ ToLexicalInfo(ct),
+ Declaration: Declaration(ToLexicalInfo(id), Name: id.getText(), Type: tr))
+ s.ExceptionHandlers.Add(handler)
+ b = handler.Block
+ tr = null
+ }
+ compound_or_single_stmt[b]
+ )*
(
finally_block[s]
- )
+ )?
;
finally_block[TryStatement s]
@@ -1051,19 +1014,22 @@ member returns [Token name]
}:
id:ID { name=id; } |
st:SET { name=st; } |
- gt:GET { name=gt; }
+ gt:GET { name=gt; } |
+ eh:EACH { name=eh; }
;
type_reference returns [TypeReference tr]
{
+ rank = 1
}:
(
(tr=simple_type_reference | tr=anonymous_function_type)
(
- LBRACK
+ lbrack:LBRACK
+ (COMMA { ++rank })*
RBRACK
{
- tr = ArrayTypeReference(tr.LexicalInfo, tr);
+ tr = ArrayTypeReference(tr.LexicalInfo, tr, IntegerLiteralExpression(ToLexicalInfo(lbrack), rank))
}
)?
)
@@ -1100,10 +1066,15 @@ function_type_parameters[ParameterDeclarationCollection parameters]
array_initializer returns [Expression e]
{
+ dimensions = List of Expression(1)
}:
- tr=simple_type_reference LBRACK count=sum RBRACK
+ tr=simple_type_reference
+ LBRACK
+ size=sum { dimensions.Add(size) }
+ (COMMA size=sum { dimensions.Add(size) })*
+ RBRACK
{
- e = CodeFactory.NewArrayInitializer(tr.LexicalInfo, tr, count)
+ e = CodeFactory.NewArrayInitializer(tr.LexicalInfo, tr, dimensions)
}
;
@@ -1173,7 +1144,6 @@ atom returns [Expression e]
e=simple_reference_expression |
e=paren_expression |
e=new_expression |
- //e=cast_expression |
e=typeof_expression
)
;
@@ -1184,19 +1154,21 @@ function_expression returns [BlockExpression e]
fn:FUNCTION
{
e = BlockExpression(ToLexicalInfo(fn))
+ e.Annotate("inline");
body = e.Body
}
LPAREN (parameter_declaration_list[e])? RPAREN
(
COLON tr=type_reference { e.ReturnType = tr; }
)?
- block[body]
+ (block[body] | returnValue=expression { body.Add(returnValue) })
;
simple_reference_expression returns [Expression e]
-{
+{
}:
- id:ID { e = ReferenceExpression(ToLexicalInfo(id), Name: id.getText()) }
+ (id:ID | each:EACH { id = each })
+ { e = ReferenceExpression(ToLexicalInfo(id), Name: id.getText()) }
;
reference_expression returns [Expression e]
@@ -1204,28 +1176,32 @@ reference_expression returns [Expression e]
}:
e=simple_reference_expression
(
- DOT
- (
- (
- memberName=member
- {
- e = MemberReferenceExpression(ToLexicalInfo(memberName), Target: e, Name: memberName.getText())
- }
- )
- |
- (
- lbrack:LESS_THAN
- {
- e = gre = GenericReferenceExpression(ToLexicalInfo(lbrack), Target: e)
- genericArguments = gre.GenericArguments
- }
- type_reference_list[genericArguments]
- GREATER_THAN
- )
- )
+ DOT e=member_reference_expression[e]
)*
;
+member_reference_expression[Expression target] returns [Expression e]
+{
+ e = target;
+}:
+ (
+ lbrack:LESS_THAN
+ {
+ e = gre = GenericReferenceExpression(ToLexicalInfo(lbrack), Target: e)
+ genericArguments = gre.GenericArguments
+ }
+ type_reference_list[genericArguments]
+ GREATER_THAN
+ )
+ |
+ (
+ memberName=member
+ {
+ e = MemberReferenceExpression(ToLexicalInfo(memberName), Target: e, Name: memberName.getText())
+ }
+ )
+;
+
paren_expression returns [Expression e]
{
}:
@@ -1235,30 +1211,42 @@ paren_expression returns [Expression e]
typeof_expression returns [Expression e]
{
}:
- t:TYPEOF
-
- ((LPAREN)? expression)=>(
- (
- (LPAREN arg=expression RPAREN)
- | arg=expression
- )
- {
- mie = MethodInvocationExpression(ToLexicalInfo(t));
- mie.Target = ReferenceExpression(ToLexicalInfo(t), Name: t.getText())
- mie.Arguments.Add(arg)
-
- e = mie
- }
- )
- |(
- (
- (LPAREN tr=type_reference RPAREN)
- | tr=type_reference
- )
- {
- e = TypeofExpression(ToLexicalInfo(t), tr);
- }
+ (TYPEOF LPAREN expression RPAREN)=>e=typeof_with_expression
+ | e=typeof_expression_alt // workaround antlr boo backend bug that only allows a single predicate per rule
+;
+
+protected
+typeof_expression_alt returns [Expression e]
+{
+}:
+ (TYPEOF LPAREN type_reference RPAREN)=>e=typeof_with_typeref
+ | e=typeof_with_expression
+;
+
+protected
+typeof_with_expression returns [Expression e]
+{
+}:
+ t:TYPEOF
+ (
+ (LPAREN arg=expression RPAREN)
+ | arg=expression
)
+ {
+ mie = MethodInvocationExpression(ToLexicalInfo(t));
+ mie.Target = ReferenceExpression(ToLexicalInfo(t), Name: t.getText())
+ mie.Arguments.Add(arg)
+
+ e = mie
+ }
+;
+
+protected
+typeof_with_typeref returns [Expression e]
+{
+}:
+ t:TYPEOF LPAREN tr=type_reference RPAREN
+ { e = TypeofExpression(ToLexicalInfo(t), tr); }
;
expression_list[ExpressionCollection ec]
@@ -1345,84 +1333,161 @@ assignment_expression returns [Expression e]
)?
;
-conditional_expression returns [Expression e]
+slicing_expression returns [Expression e]
+{
+ se as SlicingExpression
+ mce as MethodInvocationExpression
+ args as ExpressionCollection
+}:
+ e=atom
+ ( options { greedy=true; }:
+ (
+ lbrack:LBRACK
+ {
+ se = SlicingExpression(ToLexicalInfo(lbrack))
+ se.Target = e
+ e = se
+ }
+ slice[se] (COMMA slice[se])*
+ RBRACK
+ )
+ |
+ (
+ DOT e=member_reference_expression[e]
+ )
+ |
+ (
+ lparen:LPAREN
+ {
+ mce = MethodInvocationExpression(ToLexicalInfo(lparen))
+ mce.Target = e
+ e = mce
+ args = mce.Arguments
+ }
+ expression_list[args]
+ RPAREN
+ )
+ )*
+;
+
+
+postfix_unary_expression returns [Expression e]
{
}:
- e=logical_expression
+ e=slicing_expression
(
- qm:QUESTION_MARK
- trueValue=logical_expression
- COLON
- falseValue=conditional_expression
+ postinc:INCREMENT { token = postinc; operator = UnaryOperatorType.PostIncrement; } |
+ preinc:DECREMENT { token = preinc; operator= UnaryOperatorType.PostDecrement; }
+ )?
+ { e = UnaryExpression(ToLexicalInfo(token), operator, e) if token is not null }
+;
+
+unary_expression returns [Expression e]
+{
+}:
+ (
+ e=prefix_unary_expression
+ | e=postfix_unary_expression
+ )
+ (
+ tc:AS tr=type_reference { e = TryCastExpression(ToLexicalInfo(tc), Target: e, Type: tr) }
+ | c:CAST tr=type_reference { e = CastExpression(ToLexicalInfo(c), Target: e, Type: tr) }
+ )?
+;
+
+prefix_unary_expression returns [Expression e]
+{
+ uOperator = UnaryOperatorType.None
+}:
+ (
+ sub:SUBTRACT { op = sub; uOperator = UnaryOperatorType.UnaryNegation; } |
+ inc:INCREMENT { op = inc; uOperator = UnaryOperatorType.Increment; } |
+ dec:DECREMENT { op = dec; uOperator = UnaryOperatorType.Decrement; } |
+ nt:LOGICAL_NOT { op = nt; uOperator = UnaryOperatorType.LogicalNot; } |
+ oc:BITWISE_NOT { op = oc; uOperator = UnaryOperatorType.OnesComplement; }
+ )
+ e=unary_expression { e = UnaryExpression(ToLexicalInfo(op), uOperator, e) }
+;
+
+
+term returns [Expression e]
+{
+ op = BinaryOperatorType.None
+}:
+ e=unary_expression
+ ( options { greedy = true; } :
+ (
+ m:MULTIPLY { op=BinaryOperatorType.Multiply; token=m; } |
+ d:DIVISION { op=BinaryOperatorType.Division; token=d; } |
+ md:MODULUS { op=BinaryOperatorType.Modulus; token=md; }
+ )
+ r=unary_expression
{
- e = ConditionalExpression(ToLexicalInfo(qm),
- Condition: e,
- TrueValue: trueValue,
- FalseValue: falseValue)
+ be = BinaryExpression(ToLexicalInfo(token))
+ be.Operator = op
+ be.Left = e
+ be.Right = r
+ e = be
}
- )?
+ )*
;
-logical_expression returns [Expression e]
+sum returns [Expression e]
{
+ bOperator = BinaryOperatorType.None;
}:
- e=boolean_term
- (
- op:LOGICAL_OR
- rhs=boolean_term
+ e=term
+ ( options { greedy = true; } :
+ (
+ add:ADD { op=add; bOperator = BinaryOperatorType.Addition; } |
+ sub:SUBTRACT { op=sub; bOperator = BinaryOperatorType.Subtraction; }
+ )
+ r=term
{
- e = BinaryExpression(ToLexicalInfo(op),
- Operator: BinaryOperatorType.Or,
- Left: e,
- Right: rhs)
+ be = BinaryExpression(ToLexicalInfo(op))
+ be.Operator = bOperator
+ be.Left = e
+ be.Right = r
+ e = be
}
)*
;
-boolean_term returns [Expression e]
+shift returns [Expression e]
{
}:
- e=comparison_expression
- (
- op:LOGICAL_AND
- rhs=comparison_expression
+ e=sum
+ ( options { greedy = true;} :
+ (
+ sl:SHIFT_LEFT { op = BinaryOperatorType.ShiftLeft; token = sl } |
+ sr:SHIFT_RIGHT { op = BinaryOperatorType.ShiftRight; token = sr }
+ )
+ r=sum
{
- e=BinaryExpression(ToLexicalInfo(op),
- Operator: BinaryOperatorType.And,
- Left: e,
- Right: rhs)
+ e = BinaryExpression(ToLexicalInfo(token), Operator: op, Left: e, Right: r)
}
)*
;
-comparison_expression returns [Expression e]
+comparison returns [Expression e]
{
r as Expression
op = BinaryOperatorType.None;
token as IToken
}:
- e=sum
+ e=shift
( options { greedy = true; } :
(
(
(
- (te:EQUALITY { op = BinaryOperatorType.Equality; token = te; } ) |
- (ti:INEQUALITY { op = BinaryOperatorType.Inequality; token =ti }) |
+ (tni:NOT IN { op = BinaryOperatorType.NotMember; token = tni; } ) |
+ (tin:IN { op = BinaryOperatorType.Member; token = tin; } ) |
(tgt:GREATER_THAN { op = BinaryOperatorType.GreaterThan; token = tgt; } ) |
(tgte:GREATER_THAN_OR_EQUAL { op = BinaryOperatorType.GreaterThanOrEqual; token = tgte }) |
(tlt:LESS_THAN { op = BinaryOperatorType.LessThan; token = tlt; }) |
- (tlte:LESS_THAN_OR_EQUAL { op = BinaryOperatorType.LessThanOrEqual; token = tlte; }) |
- (re:REFERENCE_EQUALITY { op = BinaryOperatorType.ReferenceEquality; token = re }) |
- (rie:REFERENCE_INEQUALITY { op = BinaryOperatorType.ReferenceInequality; token = rie })
+ (tlte:LESS_THAN_OR_EQUAL { op = BinaryOperatorType.LessThanOrEqual; token = tlte; })
)
- r=sum
- ) |
- (
- (
- (tin:IN { op = BinaryOperatorType.Member; token = tin; } ) |
- (tnint:NOT IN { op = BinaryOperatorType.NotMember; token = tnint; })
- )
- r=expression
+ r=shift
) |
(
tisa:INSTANCEOF
@@ -1444,67 +1509,50 @@ comparison_expression returns [Expression e]
)*
;
-sum returns [Expression e]
+equality returns [Expression e]
{
- bOperator = BinaryOperatorType.None;
}:
- e=term
- ( options { greedy = true; } :
+ e=comparison
+ (options { greedy = true; }:
(
- add:ADD { op=add; bOperator = BinaryOperatorType.Addition; } |
- sub:SUBTRACT { op=sub; bOperator = BinaryOperatorType.Subtraction; } |
- bitor:BITWISE_OR { op=bitor; bOperator = BinaryOperatorType.BitwiseOr; } |
- eo:EXCLUSIVE_OR { op=eo; bOperator = BinaryOperatorType.ExclusiveOr; }
+ (te:EQUALITY { op = BinaryOperatorType.Equality; token = te; } ) |
+ (ti:INEQUALITY { op = BinaryOperatorType.Inequality; token = ti }) |
+ (re:REFERENCE_EQUALITY { op = BinaryOperatorType.ReferenceEquality; token = re }) |
+ (rie:REFERENCE_INEQUALITY { op = BinaryOperatorType.ReferenceInequality; token = rie })
)
- r=term
- {
- be = BinaryExpression(ToLexicalInfo(op))
- be.Operator = bOperator
- be.Left = e
- be.Right = r
- e = be
- }
+ r=comparison
+ { e = BinaryExpression(ToLexicalInfo(token), op, e, r) }
)*
;
-term returns [Expression e]
+
+bitwise_and returns [Expression e]
{
- op = BinaryOperatorType.None
}:
- e=factor
- ( options { greedy = true; } :
- (
- m:MULTIPLY { op=BinaryOperatorType.Multiply; token=m; } |
- d:DIVISION { op=BinaryOperatorType.Division; token=d; } |
- md:MODULUS { op=BinaryOperatorType.Modulus; token=md; }
- )
- r=factor
+ e=equality
+ (options { greedy = true; }:
+ token:BITWISE_AND { op = BinaryOperatorType.BitwiseAnd; }
+ r=equality
{
- be = BinaryExpression(ToLexicalInfo(token))
- be.Operator = op
- be.Left = e
- be.Right = r
- e = be
+ e = BinaryExpression(ToLexicalInfo(token), Operator: op, Left: e, Right: r)
}
)*
;
-factor returns [Expression e]
+bitwise_xor returns [Expression e]
{
}:
- e=bitwise_or
- ( options { greedy = true;} :
- (
- sl:SHIFT_LEFT { op = BinaryOperatorType.ShiftLeft; token = sl } |
- sr:SHIFT_RIGHT { op = BinaryOperatorType.ShiftRight; token = sr }
- )
- r=bitwise_or
+ e=bitwise_and
+ (options { greedy = true; }:
+ token:BITWISE_XOR { op = BinaryOperatorType.ExclusiveOr; }
+ r=bitwise_and
{
e = BinaryExpression(ToLexicalInfo(token), Operator: op, Left: e, Right: r)
}
)*
;
+
bitwise_or returns [Expression e]
{
}:
@@ -1520,112 +1568,57 @@ bitwise_or returns [Expression e]
)*
;
-bitwise_xor returns [Expression e]
+logical_and returns [Expression e]
{
}:
- e=bitwise_and
- (options { greedy = true; }:
- token:BITWISE_XOR { op = BinaryOperatorType.ExclusiveOr; }
- r=bitwise_and
+ e=bitwise_or
+ (
+ op:LOGICAL_AND
+ rhs=bitwise_or
{
- e = BinaryExpression(ToLexicalInfo(token), Operator: op, Left: e, Right: r)
+ e=BinaryExpression(ToLexicalInfo(op),
+ Operator: BinaryOperatorType.And,
+ Left: e,
+ Right: rhs)
}
)*
;
-bitwise_and returns [Expression e]
+logical_or returns [Expression e]
{
}:
- e=unary_expression
- (options { greedy = true; }:
- token:BITWISE_AND { op = BinaryOperatorType.BitwiseAnd; }
- r=unary_expression
+ e=logical_and
+ (
+ op:LOGICAL_OR
+ rhs=logical_and
{
- e = BinaryExpression(ToLexicalInfo(token), Operator: op, Left: e, Right: r)
+ e = BinaryExpression(ToLexicalInfo(op),
+ Operator: BinaryOperatorType.Or,
+ Left: e,
+ Right: rhs)
}
)*
;
-unary_expression returns [Expression e]
+conditional_expression returns [Expression e]
{
- uOperator = UnaryOperatorType.None
-}:
- (
- (
- (
- sub:SUBTRACT { op = sub; uOperator = UnaryOperatorType.UnaryNegation; } |
- inc:INCREMENT { op = inc; uOperator = UnaryOperatorType.Increment; } |
- dec:DECREMENT { op = dec; uOperator = UnaryOperatorType.Decrement; } |
- nt:NOT { op = nt; uOperator = UnaryOperatorType.LogicalNot; } |
- oc:ONES_COMPLEMENT { op = oc; uOperator = UnaryOperatorType.OnesComplement; }
- )
- e=slicing_expression
- ) |
- (
- e=slicing_expression
- (
- postinc:INCREMENT { op = postinc; uOperator = UnaryOperatorType.PostIncrement; } |
- preinc:DECREMENT { op = preinc; uOperator= UnaryOperatorType.PostDecrement; }
- )?
- )
- )
- {
- if op is not null:
- ue = UnaryExpression(ToLexicalInfo(op))
- ue.Operator = uOperator
- ue.Operand = e
- e = ue
- }
+}:
+ e=logical_or
(
- t:AS
- tr=type_reference
+ qm:QUESTION_MARK
+ trueValue=logical_or
+ COLON
+ falseValue=conditional_expression
{
- ae = TryCastExpression(ToLexicalInfo(t), Target: e, Type: tr)
- e = ae
+ e = ConditionalExpression(ToLexicalInfo(qm),
+ Condition: e,
+ TrueValue: trueValue,
+ FalseValue: falseValue)
}
)?
;
-slicing_expression returns [Expression e]
-{
- se as SlicingExpression
- mce as MethodInvocationExpression
- args as ExpressionCollection
- memberName as IToken
-}:
- e=atom
- ( options { greedy=true; }:
- (
- lbrack:LBRACK
- {
- se = SlicingExpression(ToLexicalInfo(lbrack))
- se.Target = e
- e = se
- }
- slice[se] (COMMA slice[se])*
- RBRACK
- )
- |
- (
- DOT memberName=member
- {
- e = MemberReferenceExpression(ToLexicalInfo(memberName), Target: e, Name: memberName.getText())
- }
- )
- |
- (
- lparen:LPAREN
- {
- mce = MethodInvocationExpression(ToLexicalInfo(lparen))
- mce.Target = e
- e = mce
- args = mce.Arguments
- }
- expression_list[args]
- RPAREN
- )
- )*
-;
+
literal returns [Expression e]
{
@@ -1635,7 +1628,6 @@ literal returns [Expression e]
e=string_literal |
e=array_literal |
e=hash_literal |
- //e=closure_expression |
e=re_literal |
e=bool_literal |
e=null_literal |
@@ -1647,13 +1639,22 @@ literal returns [Expression e]
array_literal returns [Expression e]
{
- lle as ListLiteralExpression
}:
lbrack:LBRACK
- {
- e = lle = ArrayLiteralExpression(ToLexicalInfo(lbrack))
- }
- expression_list[lle.Items]
+
+ (
+ (expression FOR)=>(
+ projection=expression
+ FOR LPAREN ((id=identifier | variable=declaration) IN iterator=expression) RPAREN
+ (IF filter=expression)?
+ {
+ if id is not null: variable = Declaration(ToLexicalInfo(id), Name: id.getText())
+ e = CodeFactory.NewArrayComprehension(ToLexicalInfo(lbrack), projection, variable, iterator, filter)
+ }
+ )
+ | { e = ale = ArrayLiteralExpression(ToLexicalInfo(lbrack)); items = ale.Items; } expression_list[items]
+ )
+
RBRACK
;
@@ -1695,12 +1696,7 @@ re_literal returns [RELiteralExpression re]
double_literal returns [DoubleLiteralExpression rle]
{
}:
- value:DOUBLE
- {
- rle = DoubleLiteralExpression(ToLexicalInfo(value),
- ParseDouble(value.getText()),
- IsSingle: true);
- }
+ value:DOUBLE { rle = CodeFactory.NewDoubleLiteralExpression(ToLexicalInfo(value), value.getText()) }
;
self_literal returns [SelfLiteralExpression e]
@@ -1761,10 +1757,8 @@ integer_literal returns [IntegerLiteralExpression e]
string_literal returns [Expression e]
{
}:
- dqs:DOUBLE_QUOTED_STRING
- {
- e = StringLiteralExpression(ToLexicalInfo(dqs), dqs.getText())
- }
+ (dqs:DOUBLE_QUOTED_STRING { s = dqs; } | sqs:SINGLE_QUOTED_STRING { s = sqs; })
+ { e = StringLiteralExpression(ToLexicalInfo(s), s.getText()) }
;
@@ -1782,6 +1776,8 @@ options
}
{
+ property PreserveComments = false
+
static def IsDigit(ch as char):
return ch >= char('0') and ch <= char('9')
}
@@ -1793,7 +1789,7 @@ INT:
(DIGIT)+
(
('l' | 'L') { $setType(LONG); } |
- ('f'! | 'F'!) { $setType(DOUBLE); } |
+ ('f' | 'F' | 'd' | 'D') { $setType(DOUBLE); } |
('.' DOUBLE_SUFFIX) { $setType(DOUBLE); } |
EXPONENT { $setType(DOUBLE); } |
)
@@ -1802,7 +1798,7 @@ INT:
DOT: '.' (DOUBLE_SUFFIX {$setType(DOUBLE);})?;
protected
-DOUBLE_SUFFIX: (DIGIT)+ (EXPONENT)? ('f'! | 'F'!)?;
+DOUBLE_SUFFIX: (DIGIT)+ (EXPONENT)? ('f' | 'F' | 'd' | 'D')?;
protected
EXPONENT: ('e' | 'E') ('+' | '-')? (DIGIT)+;
@@ -1849,7 +1845,14 @@ DECREMENT: "--";
ADD: '+';
-HASH: '#';
+PRAGMA_ON:
+ "#pragma"! (PRAGMA_WHITE_SPACE)+ id:ID
+ ((PRAGMA_WHITE_SPACE)+ ("off"! { $setType(PRAGMA_OFF); } | "on"!))?
+ (PRAGMA_WHITE_SPACE)*
+ NEWLINE!;
+
+protected
+PRAGMA_WHITE_SPACE: (' '! | '\t'!);
INPLACE_ADD: "+=";
@@ -1867,11 +1870,11 @@ EQUALITY: "==";
INEQUALITY: "!=";
-NOT: '!';
+LOGICAL_NOT: '!';
QUESTION_MARK: '?';
-ONES_COMPLEMENT: '~';
+BITWISE_NOT: '~';
REFERENCE_EQUALITY: "===";
@@ -1893,13 +1896,23 @@ SHIFT_RIGHT: ">>";
INPLACE_SHIFT_RIGHT: ">>=";
-AT: '@' ("script" { $setType(SCRIPT_ATTRIBUTE_MARKER); })?;
+AT: '@';
DIVISION:
- ("/*")=> ML_COMMENT { $setType(Token.SKIP); } |
+ ("/*")=> ML_COMMENT
+ {
+ if not PreserveComments:
+ $setType(Token.SKIP)
+ } |
// (RE_LITERAL)=> RE_LITERAL { $setType(RE_LITERAL); } |
'/' (
- ('/' (~('\r'|'\n'))* { $setType(Token.SKIP); }) |
+ ('/' (~('\r'|'\n'))*
+ {
+ if PreserveComments:
+ $setType(SL_COMMENT)
+ else:
+ $setType(Token.SKIP);
+ }) |
('=' { $setType(INPLACE_DIVISION); }) |
)
;
@@ -1923,8 +1936,18 @@ DOUBLE_QUOTED_STRING:
'"'!
;
+SINGLE_QUOTED_STRING:
+ '\''!
+ (
+ SQS_ESC |
+ ~('\'' | '\\' | '\r' | '\n')
+ )*
+ '\''!
+;
+
+
protected
-DQS_ESC: '\\'! ( SESC | '"' | '$') ;
+DQS_ESC: '\\'! ( SESC | '"' ) ;
protected
SQS_ESC: '\\'! ( SESC | '\'' );
@@ -1950,7 +1973,6 @@ ML_COMMENT:
{ LA(2) != char('/') }? '*'
)*
"*/"
- { $setType(Token.SKIP); }
;
protected
diff --git a/src/UnityScript/UnityScript.sln b/src/UnityScript/UnityScript.sln
index e7db1e6..59a0cfe 100644
--- a/src/UnityScript/UnityScript.sln
+++ b/src/UnityScript/UnityScript.sln
@@ -39,6 +39,6 @@ Global
{EF5AE116-19DD-42DC-847A-7BD3EE49AB01}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
- StartupItem = UnityScript.booproj
+ StartupItem = ..\us\us.booproj
EndGlobalSection
EndGlobal
diff --git a/src/UnityScript/UnityScriptCompiler.boo b/src/UnityScript/UnityScriptCompiler.boo
index ac9016b..d71ca54 100755
--- a/src/UnityScript/UnityScriptCompiler.boo
+++ b/src/UnityScript/UnityScriptCompiler.boo
@@ -5,8 +5,15 @@ import Boo.Lang.Compiler
class UnityScriptCompiler:
[getter(Parameters)]
- _parameters = UnityScriptCompilerParameters()
- _compiler = BooCompiler(_parameters)
+ _parameters as UnityScriptCompilerParameters
+ _compiler as BooCompiler
+
+ def constructor():
+ self(UnityScriptCompilerParameters())
+
+ def constructor([required] parameters as UnityScriptCompilerParameters):
+ _parameters = parameters
+ _compiler = BooCompiler(_parameters)
def Run():
return _compiler.Run()
@@ -14,59 +21,59 @@ class UnityScriptCompiler:
def Run(compileUnit as Boo.Lang.Compiler.Ast.CompileUnit):
return _compiler.Run(compileUnit)
- class Pipelines:
+ static class Pipelines:
- static def RawParsing():
- pipeline = CompilerPipeline()
- pipeline.Add(UnityScript.Steps.PreProcess())
- pipeline.Add(UnityScript.Steps.Parse())
- return pipeline
+ def RawParsing():
+ return CompilerPipeline() { UnityScript.Steps.PreProcess(), UnityScript.Steps.Parse() }
- static def Parse():
- pipeline = RawParsing()
- pipeline.Add(UnityScript.Steps.ApplySemantics())
- return pipeline
+ def Parse():
+ return RawParsing() { UnityScript.Steps.ApplySemantics(), UnityScript.Steps.ApplyDefaultVisibility() }
- static def Compile():
+ def Compile():
return AdjustBooPipeline(Boo.Lang.Compiler.Pipelines.Compile())
- static def CompileToMemory():
+ def CompileToMemory():
return AdjustBooPipeline(Boo.Lang.Compiler.Pipelines.CompileToMemory())
- static def CompileToFile():
+ def CompileToFile():
return AdjustBooPipeline(Boo.Lang.Compiler.Pipelines.CompileToFile())
- static def CompileToBoo():
+ def CompileToBoo():
return AdjustBooPipeline(Boo.Lang.Compiler.Pipelines.CompileToBoo())
- static def AdjustBooPipeline(pipeline as CompilerPipeline):
- pipeline.Insert(0, UnityScript.Steps.PreProcess())
+ def AdjustBooPipeline(pipeline as CompilerPipeline):
+ pipeline.Insert(0,
+ UnityScript.Steps.PreProcess())
- pipeline.Replace(Boo.Lang.Parser.BooParsingStep, UnityScript.Steps.Parse())
+ pipeline.Replace(Boo.Lang.Compiler.Steps.Parsing,
+ UnityScript.Steps.Parse())
- pipeline.Replace(Boo.Lang.Compiler.Steps.InitializeTypeSystemServices,
- UnityScript.Steps.InitializeUnityScriptTypeSystem())
-
pipeline.Replace(Boo.Lang.Compiler.Steps.IntroduceGlobalNamespaces,
UnityScript.Steps.IntroduceUnityGlobalNamespaces())
pipeline.InsertAfter(Boo.Lang.Compiler.Steps.PreErrorChecking,
- UnityScript.Steps.ApplySemantics())
-
+ UnityScript.Steps.ApplySemantics())
+
+ pipeline.InsertAfter(UnityScript.Steps.ApplySemantics,
+ UnityScript.Steps.ApplyDefaultVisibility())
+
pipeline.InsertBefore(Boo.Lang.Compiler.Steps.ExpandDuckTypedExpressions,
UnityScript.Steps.ProcessAssignmentToDuckMembers())
pipeline.Replace(Boo.Lang.Compiler.Steps.ProcessMethodBodiesWithDuckTyping,
UnityScript.Steps.ProcessUnityScriptMethods())
+ pipeline.InsertAfter(UnityScript.Steps.ProcessUnityScriptMethods,
+ UnityScript.Steps.AutoExplodeVarArgsInvocations())
+
pipeline.InsertAfter(UnityScript.Steps.ProcessUnityScriptMethods,
UnityScript.Steps.ProcessEvalInvocations())
pipeline.ReplaceOptional(Boo.Lang.Compiler.Steps.ExpandDuckTypedExpressions,
UnityScript.Steps.ExpandUnityDuckTypedExpressions())
- pipeline.ReplaceOptional(Boo.Lang.Compiler.Steps.ExpandVarArgsMethodInvocations,
- UnityScript.Steps.UnityExpandVarArgsMethodInvocations())
+ pipeline.InsertBefore(Boo.Lang.Compiler.Steps.EmitAssembly,
+ UnityScript.Steps.Lint())
pipeline.InsertBefore(Boo.Lang.Compiler.Steps.EmitAssembly,
UnityScript.Steps.EnableRawArrayIndexing())
@@ -76,7 +83,8 @@ class UnityScriptCompiler:
return pipeline
-[Extension] def ReplaceOptional(pipeline as CompilerPipeline, optionalPipelineStepType as System.Type, step as ICompilerStep):
+[Extension]
+def ReplaceOptional(pipeline as CompilerPipeline, optionalPipelineStepType as System.Type, step as ICompilerStep):
index = pipeline.Find(optionalPipelineStepType)
if index < 0: return
pipeline.RemoveAt(index)
diff --git a/src/UnityScript/UnityScriptCompilerParameters.boo b/src/UnityScript/UnityScriptCompilerParameters.boo
index 2b95e6c..92b4b43 100755
--- a/src/UnityScript/UnityScriptCompilerParameters.boo
+++ b/src/UnityScript/UnityScriptCompilerParameters.boo
@@ -1,25 +1,55 @@
namespace UnityScript
+import Boo.Lang.Environments
import Boo.Lang.Compiler
+import Boo.Lang.Compiler.Services
+import Boo.Lang.Compiler.TypeSystem
+import Boo.Lang.Compiler.TypeSystem.Services
+import Boo.Lang.Compiler.TypeSystem.Reflection
+import UnityScript.TypeSystem
class UnityScriptCompilerParameters(CompilerParameters):
- [property(ScriptBaseType)]
- _baseType as System.Type
+ public static final DefaultTabSize = 8
- [property(ScriptMainMethod)]
- _mainMethod as string
+ property ScriptBaseType as System.Type
- [property(Imports)]
- _imports = []
+ property ScriptMainMethod as string
- [property(Expando)]
- _expando = false
+ property Imports = List of string()
- [property(GlobalVariablesBecomeFields)]
- _globalVariablesBecomeFields = true
-
+ property Expando = false
+
+ property GlobalVariablesBecomeFields = true
+
+ property DisableEval as string
+
+ property TabSize = DefaultTabSize
+
def constructor():
- self.Ducky = true
+ self(true)
+
+ def constructor(loadDefaultReferences as bool):
+ self(ReflectionTypeSystemProvider(), loadDefaultReferences)
+
+ def constructor(reflectionTypeSystemProvider as IReflectionTypeSystemProvider, loadDefaultReferences as bool):
+ super(reflectionTypeSystemProvider, loadDefaultReferences)
+ self.Checked = false
self.OutputType = CompilerOutputType.Library
- self.References.Add(GetType().Assembly)
+ self.Environment = DeferredEnvironment() {
+ EntityFormatter: { UnityScriptEntityFormatter() },
+ TypeSystemServices: { UnityScriptTypeSystem() },
+ CallableResolutionService: { UnityCallableResolutionService() },
+ DowncastPermissions: { UnityDowncastPermissions() },
+ LanguageAmbiance: { UnityScriptAmbiance() }
+ }
+ if loadDefaultReferences:
+ self.References.Add(typeof(UnityScript.Lang.Array).Assembly)
+ self.References.Add(GetType().Assembly)
+
+ def AddToEnvironment(serviceType as System.Type, factory as ObjectFactory):
+ (Environment as DeferredEnvironment).Add(serviceType, factory)
+
+ override Ducky:
+ get: return not Strict
+ set: raise "Ducky is always equals not Strict. Set Strict instead."
diff --git a/src/us/.monolipse b/src/us/.monolipse
index 04dc6ec..d04b424 100644
--- a/src/us/.monolipse
+++ b/src/us/.monolipse
@@ -5,9 +5,9 @@
/UnityScript/src/UnityScript
-
- /UnityScript/lib/net-2.0/bin/Boo.Lang.Useful.dll
-
+
+ Boo.Lang.Useful
+
/UnityScript/bin
diff --git a/src/us/CommandLineOptions.boo b/src/us/CommandLineOptions.boo
index 13da33e..b0d3c44 100755
--- a/src/us/CommandLineOptions.boo
+++ b/src/us/CommandLineOptions.boo
@@ -1,5 +1,6 @@
namespace us
+import System
import System.IO
import Boo.Lang.Compiler
import Boo.Lang.Useful.CommandLine
@@ -7,28 +8,28 @@ import Boo.Lang.Useful.CommandLine
class CommandLineOptions(AbstractCommandLine):
[getter(References)]
- _references = []
+ _references = List of string()
[getter(Resources)]
- _resources = []
+ _resources = List of string()
[getter(OutputType)]
_outputTarget = CompilerOutputType.Library
[getter(Imports)]
- _imports = []
+ _imports = List of string()
[getter(SourceFiles)]
- _sourceFiles = []
+ _sourceFiles = List of string()
[getter(SourceDirs)]
- _srcDirs = []
+ _srcDirs = List of string()
[getter(SuppressedWarnings)]
- _suppressedWarnings = []
+ _suppressedWarnings = List of string()
[getter(Defines)]
- _defines = []
+ _defines = List of string()
[getter(Pragmas)]
_pragmas = List of string()
@@ -36,15 +37,13 @@ class CommandLineOptions(AbstractCommandLine):
def constructor(*argv as (string)):
Parse(argv)
- def GetAllSourceFiles():
+ def ForEachSourceFile(action as Action of string):
for srcFile as string in _sourceFiles:
- yield srcFile
+ action(srcFile)
for srcDir in _srcDirs:
- for fname in Directory.GetFiles(srcDir, "*.js"):
- yield fname
-
+ Useful.IO.forEachFileIn(srcDir, "*.js", action)
IsValid:
get:
@@ -52,6 +51,10 @@ class CommandLineOptions(AbstractCommandLine):
and len(self.MainMethod) > 0
and (len(self.SourceFiles) > 0
or len(self.SourceDirs) > 0))
+
+ [Option("Option has been deprecated", LongForm: "ducky")]
+ def DuckyHasBeenDeprecated(value):
+ Console.Error.WriteLine("WARNING: -ducky command line option has been deprecated and has no effect")
[Option("Specifies the output {file} name", ShortForm: "o", LongForm: "out")]
public Output = ""
@@ -67,9 +70,6 @@ class CommandLineOptions(AbstractCommandLine):
[Option("Execute resulting main method.", ShortForm: 'x', LongForm: 'execute')]
public Execute = false
-
- [Option("Enable duck typing.", LongForm: "ducky")]
- public Ducky = false
[Option("Enable expando mode.", LongForm: "expando")]
public Expando = false
@@ -83,21 +83,24 @@ class CommandLineOptions(AbstractCommandLine):
[Option("Enable verbose mode.", LongForm: "verbose")]
public Verbose = false
+ [Option("Disables eval builtin.", LongForm: "disable-eval")]
+ public DisableEval as string
+
[Option("Enables a comma separated {set} of #pragma directives on every module", LongForm: "pragmas", MaxOccurs: int.MaxValue)]
def AddPragmas(pragmas as string):
_pragmas.ExtendUnique(pragma.Trim() for pragma in pragmas.Split(char(',')))
[Option("References the specified {assembly}", ShortForm: 'r', LongForm: "reference", MaxOccurs: int.MaxValue)]
def AddReference(reference as string):
- _references.AddUnique(reference)
+ _references.AddUnique(Unquote(reference))
[Option("Includes all *.js files from {srcdir}", LongForm: "srcdir", MaxOccurs: int.MaxValue)]
def AddSourceDir(srcDir as string):
- _srcDirs.AddUnique(Path.GetFullPath(srcDir))
+ _srcDirs.AddUnique(Path.GetFullPath(Unquote(srcDir)))
[Option("Embed a managed resource {file}", LongForm: "resource", MaxOccurs: int.MaxValue)]
def AddResource(resource as string):
- _resources.AddUnique(resource)
+ _resources.AddUnique(Unquote(resource))
[Option("Suppress the warning {code}", LongForm: "nowarn", MaxOccurs: int.MaxValue)]
def SuppressWarning(code as string):
@@ -124,10 +127,18 @@ class CommandLineOptions(AbstractCommandLine):
[Option("display this help and exit", LongForm: "help")]
public DoHelp = false
+
+ [Option("Enables custom type inference rules to be specified through the attribute {type}", LongForm: "x-type-inference-rule-attribute")]
+ public TypeInferenceRuleAttribute as string
[Argument]
def AddSourceFile([required] sourceFile as string):
- self.SourceFiles.Add(sourceFile)
+ self.SourceFiles.Add(Unquote(sourceFile))
private def InvalidOption(msg as string):
raise msg
+
+def Unquote(path as string):
+ if path.StartsWith('"') or path.StartsWith("'"):
+ return path[1:-1]
+ return path
diff --git a/src/us/UnityScriptCompilerFactory.boo b/src/us/UnityScriptCompilerFactory.boo
old mode 100644
new mode 100755
index d505da7..786b6fb
--- a/src/us/UnityScriptCompilerFactory.boo
+++ b/src/us/UnityScriptCompilerFactory.boo
@@ -5,6 +5,8 @@ import Boo.Lang.Compiler
import Boo.Lang.Compiler.IO
import Boo.Lang.Compiler.Resources
+import Boo.Lang.Compiler.TypeSystem.Services
+
import System.IO
import System.Diagnostics
@@ -20,7 +22,7 @@ class UnityScriptCompilerFactory:
assemblies.Add(asm)
compiler.Parameters.References.Add(asm)
- for fname in options.GetAllSourceFiles():
+ options.ForEachSourceFile() do (fname):
compiler.Parameters.Input.Add(FileInput(fname))
for resource in options.Resources:
@@ -58,10 +60,15 @@ class UnityScriptCompilerFactory:
baseType = resolveType(assemblies, options.BaseClass)
compiler.Parameters.ScriptBaseType = baseType
compiler.Parameters.ScriptMainMethod = options.MainMethod
- compiler.Parameters.Ducky = options.Ducky
compiler.Parameters.Debug = options.Debug
compiler.Parameters.Expando = options.Expando
- compiler.Parameters.Imports.Extend(options.Imports)
+ compiler.Parameters.DisableEval = options.DisableEval
+ compiler.Parameters.Imports.AddRange(options.Imports)
+
+ if options.TypeInferenceRuleAttribute:
+ compiler.Parameters.AddToEnvironment(
+ TypeInferenceRuleProvider,
+ { CustomTypeInferenceRuleProvider(options.TypeInferenceRuleAttribute) })
if options.DebugCompiler:
compiler.Parameters.Pipeline.BeforeStep += do(sender, args as CompilerStepEventArgs):
diff --git a/src/us/us.boo b/src/us/us.boo
index b5e7dd1..cd2bd69 100755
--- a/src/us/us.boo
+++ b/src/us/us.boo
@@ -2,88 +2,68 @@ namespace us
import System
import System.Reflection
-import System.IO
import Boo.Lang.Compiler
-def Main([required] argv as (string)) as int:
+def Main(argv as (string)):
try:
- return run(argv)
+ return runWithCommandLine(argv)
+ except x as TargetInvocationException:
+ print "Execution error: ", x.InnerException
+ except x as ApplicationException:
+ print "Error:", x.Message
except x:
print "Error:", x
return 255
-
-def getAssemblyTitle():
- return cast(AssemblyTitleAttribute, getAssemblyAttribute(AssemblyTitleAttribute)).Title
-def getAssemblyVersion():
- return Assembly.GetExecutingAssembly().GetName().Version
+def runWithCommandLine(commandLine as (string)):
+ options = parseCommandLineOptions(commandLine)
+ if options.IsValid and not options.DoHelp:
+ return compile(options)
+ usage(options)
+ return 255
-def getAssemblyCopyright():
- return cast(AssemblyCopyrightAttribute, getAssemblyAttribute(AssemblyCopyrightAttribute)).Copyright
+def parseCommandLineOptions(commandLine as (string)):
+ return CommandLineOptions(*commandLine)
-def getAssemblyAttribute(type as System.Type):
- return Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), type)
-
def compile(options as CommandLineOptions):
-
compiler = UnityScriptCompilerFactory.FromCommandLineOptions(options)
results = compiler.Run()
+
if len(results.Errors):
print results.Errors.ToString(options.Verbose)
return 255
+
+ if options.Execute:
+ execute(results, options.MainMethod)
else:
- if options.Execute:
- execute(results, options.MainMethod)
- else:
- print results.Warnings.ToString() if len(results.Warnings)
- print "Successfully compiled '${len(compiler.Parameters.Input)}' file(s) to '${results.GeneratedAssemblyFileName}'."
+ print results.Warnings.ToString() if len(results.Warnings)
+ print "Successfully compiled '${len(compiler.Parameters.Input)}' file(s) to '${results.GeneratedAssemblyFileName}'."
+
return 0
-
+
def execute(result as CompilerContext, mainMethod as string):
for type in result.GeneratedAssembly.GetTypes():
method = type.GetMethod(mainMethod)
if method is not null:
method.Invoke(type(), (,))
-
+
+def usage(options as CommandLineOptions):
+ banner()
+ options.PrintOptions()
+
def banner():
print "${getAssemblyTitle()} - ${getAssemblyVersion()} ${getAssemblyCopyright()}"
print
-def run(argv as (string)):
- options = parseCommandLineOptions(argv)
-
- if options.IsValid and not options.DoHelp:
- try:
- return compile(options)
- except x as ApplicationException:
- print "ERROR:", x.Message
- except x:
- print "ERROR:", x
- else:
- usage(options)
-
- return 255
+def getAssemblyTitle():
+ return getAssemblyAttribute[of AssemblyTitleAttribute]().Title
-def parseCommandLineOptions(argv as (string)):
- if len(argv) == 1 and argv[0].StartsWith("@"):
- return CommandLineOptions(*parseResponseFile(argv[0][1:]))
- return CommandLineOptions(*argv)
+def getAssemblyVersion():
+ return Assembly.GetExecutingAssembly().GetName().Version
-def parseResponseFile(responseFile as string):
- args = []
+def getAssemblyCopyright():
+ return getAssemblyAttribute[of AssemblyCopyrightAttribute]().Copyright
- using reader = File.OpenText(responseFile):
- for line in reader:
- for arg in /\s+/.Split(line):
- continue if len(arg) == 0
- args.Add(unquote(arg))
-
- return array(string, args)
+def getAssemblyAttribute[of T(System.Attribute)]() as T:
+ return Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), T)
-def unquote(s as string):
- if s.StartsWith('"'): return s[1:-1]
- return s
-
-def usage(options as CommandLineOptions):
- banner()
- options.PrintOptions()
diff --git a/src/us/us.booproj b/src/us/us.booproj
index a254209..5953b58 100755
--- a/src/us/us.booproj
+++ b/src/us/us.booproj
@@ -1 +1,53 @@
-
Debug
AnyCPU
9.0.21022
2.0
{2C02FCE8-42AD-474F-804E-F39C5164A1DE}
Exe
us
false
us
v3.5
true
full
bin\Debug
prompt
false
false
none
bin\Release
prompt
false
false
{A4F2FB34-6254-473D-9EB4-FAF062AF1AEB}
UnityScript
{2784E7F4-5206-4BF9-99CD-96B1D94D0E19}
UnityScript.Lang
\ No newline at end of file
+
+
+
+ Debug
+ AnyCPU
+ 9.0.21022
+ 2.0
+ {2C02FCE8-42AD-474F-804E-F39C5164A1DE}
+ Exe
+ us
+ false
+ us
+ v3.5
+
+
+ true
+ full
+ bin\Debug
+ prompt
+ false
+
+ false
+
+
+ none
+ bin\Release
+ prompt
+ false
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {A4F2FB34-6254-473D-9EB4-FAF062AF1AEB}
+ UnityScript
+
+
+ {2784E7F4-5206-4BF9-99CD-96B1D94D0E19}
+ UnityScript.Lang
+
+
+
\ No newline at end of file
diff --git a/tests/integration/array-cast-6.js b/tests/ducky/Array-cast-to-native-array-of-struct.js
similarity index 100%
rename from tests/integration/array-cast-6.js
rename to tests/ducky/Array-cast-to-native-array-of-struct.js
diff --git a/tests/integration/array-length-2.js b/tests/ducky/Array-length.js
similarity index 100%
rename from tests/integration/array-length-2.js
rename to tests/ducky/Array-length.js
diff --git a/tests/integration/arrays-9.js b/tests/ducky/Array-of-struct-with-struct-loop-update-as-duck.js
similarity index 100%
rename from tests/integration/arrays-9.js
rename to tests/ducky/Array-of-struct-with-struct-loop-update-as-duck.js
diff --git a/tests/integration/arrays-10.js b/tests/ducky/Array-of-struct-with-struct-loop-update.js
similarity index 100%
rename from tests/integration/arrays-10.js
rename to tests/ducky/Array-of-struct-with-struct-loop-update.js
diff --git a/tests/integration/accessor-2-duck.js b/tests/ducky/accessor-2-duck.js
similarity index 100%
rename from tests/integration/accessor-2-duck.js
rename to tests/ducky/accessor-2-duck.js
diff --git a/tests/integration/accessor-duck.js b/tests/ducky/accessor-duck.js
similarity index 100%
rename from tests/integration/accessor-duck.js
rename to tests/ducky/accessor-duck.js
diff --git a/tests/integration/ambigous-call.js b/tests/ducky/ambigous-call.js
similarity index 100%
rename from tests/integration/ambigous-call.js
rename to tests/ducky/ambigous-call.js
diff --git a/tests/integration/array-access.js b/tests/ducky/array-access.js
similarity index 100%
rename from tests/integration/array-access.js
rename to tests/ducky/array-access.js
diff --git a/tests/integration/array-cast-2.js b/tests/ducky/array-cast-2.js
similarity index 100%
rename from tests/integration/array-cast-2.js
rename to tests/ducky/array-cast-2.js
diff --git a/tests/integration/array-cast-3.js b/tests/ducky/array-cast-3.js
similarity index 100%
rename from tests/integration/array-cast-3.js
rename to tests/ducky/array-cast-3.js
diff --git a/tests/integration/array-cast-4.js b/tests/ducky/array-cast-4.js
similarity index 100%
rename from tests/integration/array-cast-4.js
rename to tests/ducky/array-cast-4.js
diff --git a/tests/integration/array-cast-5.js b/tests/ducky/array-cast-5.js
similarity index 100%
rename from tests/integration/array-cast-5.js
rename to tests/ducky/array-cast-5.js
diff --git a/tests/integration/array-iterate.js b/tests/ducky/array-iterate.js
similarity index 100%
rename from tests/integration/array-iterate.js
rename to tests/ducky/array-iterate.js
diff --git a/tests/integration/array-nest-1.js b/tests/ducky/array-nest-1.js
similarity index 100%
rename from tests/integration/array-nest-1.js
rename to tests/ducky/array-nest-1.js
diff --git a/tests/integration/array-nest-2.js b/tests/ducky/array-nest-2.js
similarity index 100%
rename from tests/integration/array-nest-2.js
rename to tests/ducky/array-nest-2.js
diff --git a/tests/integration/array-polymorphic-foreach.js b/tests/ducky/array-polymorphic-foreach.js
similarity index 100%
rename from tests/integration/array-polymorphic-foreach.js
rename to tests/ducky/array-polymorphic-foreach.js
diff --git a/tests/integration/array-push-typesjs.js b/tests/ducky/array-push-typesjs.js
similarity index 100%
rename from tests/integration/array-push-typesjs.js
rename to tests/ducky/array-push-typesjs.js
diff --git a/tests/integration/auto-coroutine-2-duck.js b/tests/ducky/auto-coroutine-2-duck.js
similarity index 100%
rename from tests/integration/auto-coroutine-2-duck.js
rename to tests/ducky/auto-coroutine-2-duck.js
diff --git a/tests/integration/auto-coroutine-duck.js b/tests/ducky/auto-coroutine-duck.js
similarity index 100%
rename from tests/integration/auto-coroutine-duck.js
rename to tests/ducky/auto-coroutine-duck.js
diff --git a/tests/integration/auto-coroutine.js b/tests/ducky/auto-coroutine.js
similarity index 100%
rename from tests/integration/auto-coroutine.js
rename to tests/ducky/auto-coroutine.js
diff --git a/tests/integration/boolcast.js b/tests/ducky/boolcast.js
similarity index 100%
rename from tests/integration/boolcast.js
rename to tests/ducky/boolcast.js
diff --git a/tests/integration/coroutine-return.js b/tests/ducky/coroutine-return.js
similarity index 77%
rename from tests/integration/coroutine-return.js
rename to tests/ducky/coroutine-return.js
index 53bf072..ebf751b 100755
--- a/tests/integration/coroutine-return.js
+++ b/tests/ducky/coroutine-return.js
@@ -1,7 +1,6 @@
/*
test
*/
-// Duck typed objects return Coroutine instead of string
var shipType = "test";
Test();
diff --git a/tests/integration/duck-1.js b/tests/ducky/duck-1.js
similarity index 100%
rename from tests/integration/duck-1.js
rename to tests/ducky/duck-1.js
diff --git a/tests/integration/duck-equality-operator-1.js b/tests/ducky/duck-equality-operator-1.js
similarity index 100%
rename from tests/integration/duck-equality-operator-1.js
rename to tests/ducky/duck-equality-operator-1.js
diff --git a/tests/integration/duck-implicit-bool-1.js b/tests/ducky/duck-implicit-bool-1.js
similarity index 100%
rename from tests/integration/duck-implicit-bool-1.js
rename to tests/ducky/duck-implicit-bool-1.js
diff --git a/tests/ducky/duck-implicit-bool-and-with-simple-ref.js b/tests/ducky/duck-implicit-bool-and-with-simple-ref.js
new file mode 100644
index 0000000..f53a227
--- /dev/null
+++ b/tests/ducky/duck-implicit-bool-and-with-simple-ref.js
@@ -0,0 +1,22 @@
+/*
+yes
+*/
+import UnityScript.Tests.CSharp;
+
+class Foo extends OperatorBoolProperties {
+
+ function foo() {
+ print("foo");
+ return false;
+ }
+
+ function run() {
+
+ if (boolOperatorTestFalse && foo())
+ print ("Fail");
+ else
+ print ("yes");
+ }
+}
+
+new Foo().run();
\ No newline at end of file
diff --git a/tests/ducky/duck-implicit-bool-and.js b/tests/ducky/duck-implicit-bool-and.js
new file mode 100644
index 0000000..8943bea
--- /dev/null
+++ b/tests/ducky/duck-implicit-bool-and.js
@@ -0,0 +1,14 @@
+/*
+yes
+*/
+import UnityScript.Tests.CSharp;
+
+function foo() {
+ print("foo");
+ return false;
+}
+
+if (OperatorBoolProperties.boolOperatorTestFalse && foo())
+ print ("Fail");
+else
+ print ("yes");
\ No newline at end of file
diff --git a/tests/integration/duck-implicit-bool-full.js b/tests/ducky/duck-implicit-bool-full.js
similarity index 100%
rename from tests/integration/duck-implicit-bool-full.js
rename to tests/ducky/duck-implicit-bool-full.js
diff --git a/tests/integration/duck-implicit-bool-simple.js b/tests/ducky/duck-implicit-bool-simple.js
similarity index 100%
rename from tests/integration/duck-implicit-bool-simple.js
rename to tests/ducky/duck-implicit-bool-simple.js
diff --git a/tests/ducky/duck-negation.js b/tests/ducky/duck-negation.js
new file mode 100644
index 0000000..a68cbe4
--- /dev/null
+++ b/tests/ducky/duck-negation.js
@@ -0,0 +1,10 @@
+/*
+42
+42
+*/
+function abs(i) {
+ return i >= 0 ? i : -i;
+}
+
+print(abs(42));
+print(abs(-42));
diff --git a/tests/integration/duck-return-property.js b/tests/ducky/duck-return-property.js
similarity index 100%
rename from tests/integration/duck-return-property.js
rename to tests/ducky/duck-return-property.js
diff --git a/tests/integration/duck.js b/tests/ducky/duck.js
similarity index 100%
rename from tests/integration/duck.js
rename to tests/ducky/duck.js
diff --git a/tests/integration/ducktyped-1.js b/tests/ducky/ducktyped-1.js
similarity index 100%
rename from tests/integration/ducktyped-1.js
rename to tests/ducky/ducktyped-1.js
diff --git a/tests/integration/ducktyping-2.js b/tests/ducky/ducktyping-2.js
similarity index 100%
rename from tests/integration/ducktyping-2.js
rename to tests/ducky/ducktyping-2.js
diff --git a/tests/integration/ducktyping-3.js b/tests/ducky/ducktyping-3.js
similarity index 100%
rename from tests/integration/ducktyping-3.js
rename to tests/ducky/ducktyping-3.js
diff --git a/tests/integration/ducktyping.js b/tests/ducky/ducktyping.js
similarity index 100%
rename from tests/integration/ducktyping.js
rename to tests/ducky/ducktyping.js
diff --git a/tests/integration/ducky-1.js b/tests/ducky/ducky-1.js
similarity index 100%
rename from tests/integration/ducky-1.js
rename to tests/ducky/ducky-1.js
diff --git a/tests/integration/ducky_2.js b/tests/ducky/ducky_2.js
similarity index 100%
rename from tests/integration/ducky_2.js
rename to tests/ducky/ducky_2.js
diff --git a/tests/integration/ducky_3.js b/tests/ducky/ducky_3.js
similarity index 100%
rename from tests/integration/ducky_3.js
rename to tests/ducky/ducky_3.js
diff --git a/tests/integration/ducky_4.js b/tests/ducky/ducky_4.js
similarity index 100%
rename from tests/integration/ducky_4.js
rename to tests/ducky/ducky_4.js
diff --git a/tests/integration/ducky_5.js b/tests/ducky/ducky_5.js
similarity index 100%
rename from tests/integration/ducky_5.js
rename to tests/ducky/ducky_5.js
diff --git a/tests/integration/ducky_6.js b/tests/ducky/ducky_6.js
similarity index 100%
rename from tests/integration/ducky_6.js
rename to tests/ducky/ducky_6.js
diff --git a/tests/integration/implicit_conversion.js b/tests/ducky/implicit-conversion.js
similarity index 100%
rename from tests/integration/implicit_conversion.js
rename to tests/ducky/implicit-conversion.js
diff --git a/tests/integration/arrays-7.js b/tests/ducky/native-array-of-struct-with-struct-loop-update-as-duck.js
similarity index 100%
rename from tests/integration/arrays-7.js
rename to tests/ducky/native-array-of-struct-with-struct-loop-update-as-duck.js
diff --git a/tests/integration/arrays-5.js b/tests/ducky/native-array-to-Array-as-duck.js
similarity index 100%
rename from tests/integration/arrays-5.js
rename to tests/ducky/native-array-to-Array-as-duck.js
diff --git a/tests/integration/null-assign.js b/tests/ducky/null-assign.js
similarity index 100%
rename from tests/integration/null-assign.js
rename to tests/ducky/null-assign.js
diff --git a/tests/ducky/var-with-no-initializer.js b/tests/ducky/var-with-no-initializer.js
new file mode 100644
index 0000000..b8140f6
--- /dev/null
+++ b/tests/ducky/var-with-no-initializer.js
@@ -0,0 +1,10 @@
+/*
+0
+*/
+function run() {
+ var obj;
+ obj = new Object[0];
+ print(obj.length);
+}
+
+run();
diff --git a/tests/integration/virtual-test.js b/tests/ducky/virtual-test.js
similarity index 91%
rename from tests/integration/virtual-test.js
rename to tests/ducky/virtual-test.js
index 904feec..b3ff5fa 100755
--- a/tests/integration/virtual-test.js
+++ b/tests/ducky/virtual-test.js
@@ -20,7 +20,7 @@ class Test1 extends BaseTest {
print("Test1 " + p);
}
- // implicit shadowing, gives a warning
+ // implicit shadowing, gives a warning in non strict mode
function DoStuffNotVirtual (p : float) {
print("Test1");
}
diff --git a/tests/error-messages/Boo.Lang.List-is-not-visible-by-default.js b/tests/error-messages/Boo.Lang.List-is-not-visible-by-default.js
new file mode 100755
index 0000000..82b7897
--- /dev/null
+++ b/tests/error-messages/Boo.Lang.List-is-not-visible-by-default.js
@@ -0,0 +1,4 @@
+/*
+Boo.Lang.List-is-not-visible-by-default.js(4,8): BCE0018: The name 'List' does not denote a valid type ('not found'). Did you mean 'System.Collections.Generic.List'?
+*/
+var l: List.;
diff --git a/tests/error-messages/array-instantiation-with-array-multiplication.js b/tests/error-messages/array-instantiation-with-array-multiplication.js
new file mode 100644
index 0000000..994eb35
--- /dev/null
+++ b/tests/error-messages/array-instantiation-with-array-multiplication.js
@@ -0,0 +1,7 @@
+/*
+array-instantiation-with-array-multiplication.js(6,21): BCE0022: Cannot convert 'System.Array' to 'int'.
+*/
+function start() {
+ var a = new int[2];
+ var b = new int[a*3];
+}
diff --git a/tests/error-messages/array-struct-warning.js b/tests/error-messages/array-struct-warning.js
index 84e89d0..28e4534 100644
--- a/tests/error-messages/array-struct-warning.js
+++ b/tests/error-messages/array-struct-warning.js
@@ -1,7 +1,6 @@
/*
*/
-// Gives a warning about writing to a temporary but it actually works correctly.
var arr = new UnityScript.Tests.CSharp.Vector3[5];
for (var i=0;i'.
+*/
+#pragma strict
+
+var l = new System.Collections.Generic.List.();
+l.Foo();
\ No newline at end of file
diff --git a/tests/error-messages/incompatible-initializer-1.js b/tests/error-messages/incompatible-initializer-1.js
index 4d5a7ad..c0342a8 100644
--- a/tests/error-messages/incompatible-initializer-1.js
+++ b/tests/error-messages/incompatible-initializer-1.js
@@ -1,10 +1,8 @@
/*
-incompatible-initializer-1.js(8,43): BCE0022: Cannot convert 'null' to 'float'.
-incompatible-initializer-1.js(10,23): BCE0022: Cannot convert 'null' to 'float'.
+incompatible-initializer-1.js(6,43): BCE0022: Cannot convert 'null' to 'float'.
+incompatible-initializer-1.js(8,23): BCE0022: Cannot convert 'null' to 'float'.
*/
-// When running this script it currently generates a InvalidProgramException
-// C# gives a compiler error when assigning null to a float.
private var eventGebeurdeOpTijd : float = null;
eventGebeurdeOpTijd = null;
diff --git a/tests/error-messages/invalid-array-index.js b/tests/error-messages/invalid-array-index.js
new file mode 100755
index 0000000..14b1db6
--- /dev/null
+++ b/tests/error-messages/invalid-array-index.js
@@ -0,0 +1,13 @@
+/*
+invalid-array-index.js(11,25): BCE0022: Cannot convert 'UnityScript.Tests.CSharp.Vector3' to 'int'.
+*/
+import UnityScript.Tests.CSharp;
+
+var tiles : int[,];
+var v2 = Vector3(1, 1, 1);
+
+function Start () {
+ tiles = new int[5, 5];
+ print (tiles[0, v2]);
+}
+
diff --git a/tests/error-messages/invalid-attribute-sequence.js b/tests/error-messages/invalid-attribute-sequence.js
new file mode 100644
index 0000000..3f09231
--- /dev/null
+++ b/tests/error-messages/invalid-attribute-sequence.js
@@ -0,0 +1,4 @@
+/*
+invalid-attribute-sequence.js(4,2): BCE0043: Unexpected token: foo.
+*/
+@foo bar()
diff --git a/tests/error-messages/invalid-generator-return-type.js b/tests/error-messages/invalid-generator-return-type.js
new file mode 100644
index 0000000..7f69ce5
--- /dev/null
+++ b/tests/error-messages/invalid-generator-return-type.js
@@ -0,0 +1,8 @@
+/*
+invalid-generator-return-type.js(4,17): BCE0101: Return type 'String[]' cannot be used on a generator. Did you mean 'IEnumerator'? You can also use 'System.Collections.IEnumerable' or 'object'.
+*/
+function foo(): String[] {
+ yield "foo";
+}
+
+foo();
diff --git a/tests/error-messages/invalid-setter-return-type.js b/tests/error-messages/invalid-setter-return-type.js
new file mode 100644
index 0000000..4b108d9
--- /dev/null
+++ b/tests/error-messages/invalid-setter-return-type.js
@@ -0,0 +1,6 @@
+/*
+invalid-setter-return-type.js(4,30): UCE0009: Property setter can not declare return type.
+*/
+function set invalid(value): Object {
+ print('wut?');
+}
diff --git a/tests/error-messages/invalid-setter.js b/tests/error-messages/invalid-setter.js
new file mode 100644
index 0000000..1e07e23
--- /dev/null
+++ b/tests/error-messages/invalid-setter.js
@@ -0,0 +1,6 @@
+/*
+invalid-setter.js(4,14): UCE0003: Property setter must have a single argument named 'value'.
+*/
+function set invalid() {
+ print('wut?');
+}
diff --git a/tests/error-messages/iterator-warning.js b/tests/error-messages/iterator-warning.js
index 07b5d56..b697e78 100644
--- a/tests/error-messages/iterator-warning.js
+++ b/tests/error-messages/iterator-warning.js
@@ -1,7 +1,6 @@
/*
*/
-// Gives a warning about writing to a temporary but it actually works correctly.
var arr;
arr = new String[5];
diff --git a/tests/error-messages/loop-with-no-unreacheable-code-shouldnt-cause-warning.js b/tests/error-messages/loop-with-no-unreacheable-code-shouldnt-cause-warning.js
new file mode 100644
index 0000000..53906c7
--- /dev/null
+++ b/tests/error-messages/loop-with-no-unreacheable-code-shouldnt-cause-warning.js
@@ -0,0 +1,8 @@
+/*
+*/
+function Positive(n: int[]): boolean {
+ for (var i in n) {
+ return true;
+ }
+ return false;
+}
diff --git a/tests/error-messages/nolinenumber.js b/tests/error-messages/nolinenumber.js
index 50cff92..3f3ab5f 100755
--- a/tests/error-messages/nolinenumber.js
+++ b/tests/error-messages/nolinenumber.js
@@ -1,5 +1,5 @@
/*
-nolinenumber.js(14,18): BCE0101: Return type 'void' cannot be used on a generator. Did you mean 'void*' ? Or use a 'System.Collections.IEnumerable' or 'object'.
+nolinenumber.js(14,18): BCE0101: Return type 'void' cannot be used on a generator. Did you mean 'IEnumerator'? You can also use 'System.Collections.IEnumerable' or 'object'.
*/
class A
diff --git a/tests/error-messages/non-strict-does-not-warn-about-downcast.js b/tests/error-messages/non-strict-does-not-warn-about-downcast.js
new file mode 100644
index 0000000..a880887
--- /dev/null
+++ b/tests/error-messages/non-strict-does-not-warn-about-downcast.js
@@ -0,0 +1,4 @@
+/*
+*/
+var o: Object = "";
+var s: String = o;
diff --git a/tests/error-messages/pragma-strict-2.js b/tests/error-messages/pragma-strict-2.js
deleted file mode 100755
index 116b259..0000000
--- a/tests/error-messages/pragma-strict-2.js
+++ /dev/null
@@ -1,7 +0,0 @@
-/*
-pragma-strict-2.js(7,5): BCE0019: 'Foo' is not a member of 'UnityScript.Tests.Component'.
-*/
-#pragma strict
-
-var com = GetComponent(UnityScript.Tests.ComponentFoo);
-com.Foo();
\ No newline at end of file
diff --git a/tests/error-messages/pragma-strict-3js.js b/tests/error-messages/pragma-strict-3js.js
deleted file mode 100755
index 1005cea..0000000
--- a/tests/error-messages/pragma-strict-3js.js
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-pragma-strict-3js.js(9,5): BCE0005: Unknown identifier: 'test1'.
-pragma-strict-3js.js(10,11): BCE0005: Unknown identifier: 'test1'.
-*/
-#pragma strict
-
-function Start()
-{
- test1 = true;
- print(test1);
-}
\ No newline at end of file
diff --git a/tests/error-messages/pragma-strict-4.js b/tests/error-messages/pragma-strict-4.js
deleted file mode 100644
index 4f396db..0000000
--- a/tests/error-messages/pragma-strict-4.js
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
-pragma-strict-4.js(13,15): BCE0022: Cannot convert 'Foo' to 'Bar'.
-*/
-#pragma strict
-
-class Foo {
-}
-
-class Bar extends Foo {
-}
-
-var foo:Foo = new Bar();
-var bar:Bar = foo;
diff --git a/tests/error-messages/pragma-strict.js b/tests/error-messages/pragma-strict.js
deleted file mode 100755
index fc78da2..0000000
--- a/tests/error-messages/pragma-strict.js
+++ /dev/null
@@ -1,8 +0,0 @@
-/*
-pragma-strict.js(7,9): BCE0019: 'ToUpper' is not a member of 'Object'.
-*/
-#pragma strict
-
-var o : Object;
-print(o.ToUpper());
-
diff --git a/tests/error-messages/rethrow-outside-catch.js b/tests/error-messages/rethrow-outside-catch.js
new file mode 100644
index 0000000..77dd895
--- /dev/null
+++ b/tests/error-messages/rethrow-outside-catch.js
@@ -0,0 +1,4 @@
+/*
+rethrow-outside-catch.js(4,1): BCE0081: A throw statement with no arguments is not allowed outside an exception handler.
+*/
+throw;
diff --git a/tests/error-messages/static-instance-overload-resolution.js b/tests/error-messages/static-instance-overload-resolution.js
new file mode 100644
index 0000000..6c0b1de
--- /dev/null
+++ b/tests/error-messages/static-instance-overload-resolution.js
@@ -0,0 +1,9 @@
+/*
+*/
+var startInfo = new System.Diagnostics.ProcessStartInfo();
+
+function Start() {
+ var process = System.Diagnostics.Process.Start(startInfo);
+ process.WaitForExit(); // just to use the variable
+}
+
diff --git a/tests/error-messages/conditional-compilation-with-pragma-strict.js b/tests/error-messages/strict-conditional-compilation.js
similarity index 52%
rename from tests/error-messages/conditional-compilation-with-pragma-strict.js
rename to tests/error-messages/strict-conditional-compilation.js
index 21a305b..48fd25a 100755
--- a/tests/error-messages/conditional-compilation-with-pragma-strict.js
+++ b/tests/error-messages/strict-conditional-compilation.js
@@ -1,5 +1,5 @@
/*
-conditional-compilation-with-pragma-strict.js(11,5): BCE0019: 'Foo' is not a member of 'UnityScript.Tests.Component'.
+strict-conditional-compilation.js(11,5): BCE0019: 'Foo' is not a member of 'UnityScript.Tests.Component'.
*/
#pragma strict
diff --git a/tests/error-messages/strict-disallows-dynamic-dispatching.js b/tests/error-messages/strict-disallows-dynamic-dispatching.js
new file mode 100755
index 0000000..7d5b4ce
--- /dev/null
+++ b/tests/error-messages/strict-disallows-dynamic-dispatching.js
@@ -0,0 +1,8 @@
+/*
+strict-disallows-dynamic-dispatching.js(7,9): BCE0019: 'ToUpper' is not a member of 'Object'.
+*/
+#pragma strict
+
+var o : Object;
+print(o.ToUpper());
+
diff --git a/tests/error-messages/strict-disallows-implicit-variable-declaration.js b/tests/error-messages/strict-disallows-implicit-variable-declaration.js
new file mode 100755
index 0000000..82560bb
--- /dev/null
+++ b/tests/error-messages/strict-disallows-implicit-variable-declaration.js
@@ -0,0 +1,11 @@
+/*
+strict-disallows-implicit-variable-declaration.js(9,5): BCE0005: Unknown identifier: 'test1'.
+strict-disallows-implicit-variable-declaration.js(10,11): BCE0005: Unknown identifier: 'test1'.
+*/
+#pragma strict
+
+function Start()
+{
+ test1 = true;
+ print(test1);
+}
\ No newline at end of file
diff --git a/tests/error-messages/strict-nongeneric-GetComponent.js b/tests/error-messages/strict-nongeneric-GetComponent.js
new file mode 100755
index 0000000..4f5358a
--- /dev/null
+++ b/tests/error-messages/strict-nongeneric-GetComponent.js
@@ -0,0 +1,7 @@
+/*
+strict-nongeneric-GetComponent.js(7,5): BCE0019: 'Foo' is not a member of 'UnityScript.Tests.Component'.
+*/
+#pragma strict
+
+var com = GetComponent(UnityScript.Tests.ComponentFoo);
+com.Foo();
\ No newline at end of file
diff --git a/tests/error-messages/strict-warns-about-array-downcast.js b/tests/error-messages/strict-warns-about-array-downcast.js
new file mode 100644
index 0000000..0420312
--- /dev/null
+++ b/tests/error-messages/strict-warns-about-array-downcast.js
@@ -0,0 +1,10 @@
+/*
+strict-warns-about-array-downcast.js(10,23): BCW0028: WARNING: Implicit downcast from 'Object[]' to 'String[]'.
+*/
+#pragma strict
+
+function foo(): Object[] {
+ return new String[1];
+}
+
+var ss: String[] = foo();
diff --git a/tests/error-messages/strict-warns-about-downcast.js b/tests/error-messages/strict-warns-about-downcast.js
new file mode 100644
index 0000000..edb8dd9
--- /dev/null
+++ b/tests/error-messages/strict-warns-about-downcast.js
@@ -0,0 +1,18 @@
+/*
+strict-warns-about-downcast.js(14,15): BCW0028: WARNING: Implicit downcast from 'Foo' to 'Bar'.
+strict-warns-about-downcast.js(17,10): BCW0028: WARNING: Implicit downcast from 'Foo' to 'Bar'.
+*/
+#pragma strict
+
+class Foo {
+}
+
+class Bar extends Foo {
+}
+
+var foo:Foo = new Bar();
+var bar:Bar = foo;
+var foos:Foo[] = [];
+
+for (var b: Bar in foos)
+ print(b);
diff --git a/tests/error-messages/strict-warns-about-duck-downcast.js b/tests/error-messages/strict-warns-about-duck-downcast.js
new file mode 100644
index 0000000..2f54fae
--- /dev/null
+++ b/tests/error-messages/strict-warns-about-duck-downcast.js
@@ -0,0 +1,10 @@
+/*
+strict-warns-about-duck-downcast.js(9,5): BCW0028: WARNING: Implicit downcast from 'Object' to 'String'.
+*/
+
+#pragma strict
+
+var duck;
+var s : String;
+s = duck;
+print(s);
diff --git a/tests/error-messages/strict-with-downcast-off-disallows-downcast.js b/tests/error-messages/strict-with-downcast-off-disallows-downcast.js
new file mode 100644
index 0000000..3570672
--- /dev/null
+++ b/tests/error-messages/strict-with-downcast-off-disallows-downcast.js
@@ -0,0 +1,14 @@
+/*
+strict-with-downcast-off-disallows-downcast.js(14,15): BCE0022: Cannot convert 'Foo' to 'Bar'.
+*/
+#pragma strict
+#pragma downcast off
+
+class Foo {
+}
+
+class Bar extends Foo {
+}
+
+var foo:Foo = new Bar();
+var bar:Bar = foo;
diff --git a/tests/error-messages/strict-with-downcast-off-disallows-duck-downcast.js b/tests/error-messages/strict-with-downcast-off-disallows-duck-downcast.js
new file mode 100644
index 0000000..073333d
--- /dev/null
+++ b/tests/error-messages/strict-with-downcast-off-disallows-duck-downcast.js
@@ -0,0 +1,11 @@
+/*
+strict-with-downcast-off-disallows-duck-downcast.js(10,5): BCE0022: Cannot convert 'Object' to 'String'.
+*/
+
+#pragma strict
+#pragma downcast off
+
+var duck;
+var s : String;
+s = duck;
+print(s);
diff --git a/tests/error-messages/strict-with-pragma-downcast-does-not-warn-about-downcast.js b/tests/error-messages/strict-with-pragma-downcast-does-not-warn-about-downcast.js
new file mode 100644
index 0000000..2bee619
--- /dev/null
+++ b/tests/error-messages/strict-with-pragma-downcast-does-not-warn-about-downcast.js
@@ -0,0 +1,7 @@
+/*
+*/
+#pragma strict
+#pragma downcast
+
+var o: Object = "";
+var s: String = o;
diff --git a/tests/error-messages/switch-has-no-cases.js b/tests/error-messages/switch-has-no-cases.js
new file mode 100644
index 0000000..f23afb5
--- /dev/null
+++ b/tests/error-messages/switch-has-no-cases.js
@@ -0,0 +1,7 @@
+/*
+switch-has-no-cases.js(5,9): BCW0000: WARNING: switch statement has no cases.
+*/
+function foo(f) {
+ switch (f) {
+ }
+}
diff --git a/tests/error-messages/unused-variable.js b/tests/error-messages/unused-variable.js
index 0bc3fbb..0021899 100644
--- a/tests/error-messages/unused-variable.js
+++ b/tests/error-messages/unused-variable.js
@@ -1,5 +1,20 @@
/*
+unused-variable.js(11,7): BCW0003: WARNING: Unused local variable 'unused'.
+unused-variable.js(15,7): BCW0003: WARNING: Unused local variable 'unused'.
+unused-variable.js(19,7): BCW0003: WARNING: Unused local variable 'unused'.
*/
// Unused member variables should not give any warnings.
// This warning also shows up when the variable is used in a function.
-var target : String;
\ No newline at end of file
+var target : String;
+
+function f() {
+ var unused;
+}
+
+function g() {
+ var unused: Object;
+}
+
+function h() {
+ var unused = 42;
+}
diff --git a/tests/error-messages/yield-from-try-catch-finally.js b/tests/error-messages/yield-from-try-catch-finally.js
new file mode 100644
index 0000000..51682ea
--- /dev/null
+++ b/tests/error-messages/yield-from-try-catch-finally.js
@@ -0,0 +1,12 @@
+/*
+yield-from-try-catch-finally.js(7,15): BCE0099: yield cannot be used inside a try, catch or finally block.
+yield-from-try-catch-finally.js(8,21): BCE0099: yield cannot be used inside a try, catch or finally block.
+yield-from-try-catch-finally.js(9,19): BCE0099: yield cannot be used inside a try, catch or finally block.
+*/
+function foo() {
+ try { yield 42; }
+ catch (e) { yield 42; }
+ finally { yield 42; }
+}
+
+foo();
diff --git a/tests/eval/class-3.js b/tests/eval/assembly-references-are-visible-inside-eval-1.js
similarity index 100%
rename from tests/eval/class-3.js
rename to tests/eval/assembly-references-are-visible-inside-eval-1.js
diff --git a/tests/eval/assembly-references-are-visible-inside-eval-2.js b/tests/eval/assembly-references-are-visible-inside-eval-2.js
new file mode 100755
index 0000000..61a0748
--- /dev/null
+++ b/tests/eval/assembly-references-are-visible-inside-eval-2.js
@@ -0,0 +1,17 @@
+/*
+1
+Hello World
+*/
+
+static function test() {
+ // only referenced assemblies are available to eval scripts
+ // so let's make sure we have a reference to UnityScript.Tests.CSharp
+ var v = UnityScript.Tests.CSharp.Vector3(0, 0, 0);
+
+ eval( "var p = UnityScript.Tests.CSharp.Vector3(1,1,1); "
+ + " print(p.x); ");
+
+ eval( "UnityScript.Tests.CSharp.StaticTest.PrintSomething(\"Hello World\");");
+}
+
+test();
diff --git a/tests/eval/eval-in-static-function-2.js b/tests/eval/eval-in-static-function-2.js
index d9013da..9ffdddd 100755
--- a/tests/eval/eval-in-static-function-2.js
+++ b/tests/eval/eval-in-static-function-2.js
@@ -1,3 +1,4 @@
+// category FailsOnMono
/*
script(1,7): BCE0020: An instance of type 'eval-in-static-function-2' is required to access non static member 'a'.
script(1,11): BCE0020: An instance of type 'eval-in-static-function-2' is required to access non static member 'bar'.
diff --git a/tests/eval/class-2.js b/tests/eval/imports-are-visible-inside-eval-1.js
similarity index 100%
rename from tests/eval/class-2.js
rename to tests/eval/imports-are-visible-inside-eval-1.js
diff --git a/tests/eval/imports-are-visible-inside-eval-2.js b/tests/eval/imports-are-visible-inside-eval-2.js
new file mode 100755
index 0000000..d0663d2
--- /dev/null
+++ b/tests/eval/imports-are-visible-inside-eval-2.js
@@ -0,0 +1,14 @@
+/*
+1
+Hello World
+*/
+import UnityScript.Tests.CSharp;
+
+static function test() {
+ eval( "var p = Vector3(1,1,1); "
+ + " print(p.x); ");
+
+ eval( "StaticTest.PrintSomething(\"Hello World\");");
+}
+
+test();
\ No newline at end of file
diff --git a/tests/expando/expando-gc-3.js b/tests/expando/expando-gc-3.js
index dd38ad2..83fbff8 100755
--- a/tests/expando/expando-gc-3.js
+++ b/tests/expando/expando-gc-3.js
@@ -1,3 +1,4 @@
+// category FailsOnMono
/*
1
0
diff --git a/tests/generics/generic-dictionary-of-string-to-function.js b/tests/generics/generic-dictionary-of-string-to-function.js
new file mode 100644
index 0000000..8fb36b1
--- /dev/null
+++ b/tests/generics/generic-dictionary-of-string-to-function.js
@@ -0,0 +1,13 @@
+/*
+foo
+bar
+*/
+import System.Collections.Generic;
+
+var dict : Dictionary.;
+dict = new Dictionary.();
+dict["foo"] = function() print("foo");
+dict["bar"] = function() print("bar");
+
+dict["foo"]();
+dict["bar"]();
diff --git a/tests/generics/generic-method-arguments-in-generic-class.js b/tests/generics/generic-method-arguments-in-generic-class.js
new file mode 100644
index 0000000..85a6bf1
--- /dev/null
+++ b/tests/generics/generic-method-arguments-in-generic-class.js
@@ -0,0 +1,6 @@
+/*
+GenericMethod(System.String, System.Int32)
+*/
+import UnityScript.Tests.CSharp;
+
+Generics.GenericClass..GenericMethod.("", 42);
diff --git a/tests/generics/generic-method-arguments.js b/tests/generics/generic-method-arguments.js
new file mode 100644
index 0000000..358b85e
--- /dev/null
+++ b/tests/generics/generic-method-arguments.js
@@ -0,0 +1,11 @@
+/*
+Foo.Bar
+*/
+import UnityScript.Tests.CSharp;
+
+class Foo {
+ function Bar() { print("Foo.Bar"); }
+}
+
+var foo = Generics.Instantiate.();
+foo.Bar();
diff --git a/tests/generics/generic-method-overload-in-base-class.js b/tests/generics/generic-method-overload-in-base-class.js
new file mode 100644
index 0000000..ec0522e
--- /dev/null
+++ b/tests/generics/generic-method-overload-in-base-class.js
@@ -0,0 +1,16 @@
+/*
+Bar
+*/
+import UnityScript.Tests.CSharp;
+
+class Bar {
+}
+
+function run() {
+ var f = GetComponentsInChildren.();
+ print(f);
+}
+
+run();
+
+
diff --git a/tests/integration/array-comprehension-1.js b/tests/integration/array-comprehension-1.js
new file mode 100644
index 0000000..2c36647
--- /dev/null
+++ b/tests/integration/array-comprehension-1.js
@@ -0,0 +1,19 @@
+/*
+System.Int32[]
+[0, 2, 4]
+System.Int32[]
+[1, 3, 5]
+*/
+
+function printArray(a: int[]) {
+ print("[" + String.Join(", ", [i.ToString() for (i in a)]) + "]");
+}
+
+var doubles = [i*2 for (i in range(0, 3))];
+var odds = [i for (i in range(0, 6)) if (i % 2 != 0)];
+
+print(doubles.GetType());
+printArray(doubles);
+
+print(odds.GetType());
+printArray(odds);
diff --git a/tests/integration/array-initializer-in-static-field.js b/tests/integration/array-initializer-in-static-field.js
new file mode 100644
index 0000000..9a07c48
--- /dev/null
+++ b/tests/integration/array-initializer-in-static-field.js
@@ -0,0 +1,6 @@
+/*
+1, 2, 3, 4
+*/
+static var a:int[] = [1, 2, 3, 4];
+
+print(String.Join(", ", [i.ToString() for (i in a)]));
diff --git a/tests/integration/array-instantiation-with-object-argument-in-strict-mode.js b/tests/integration/array-instantiation-with-object-argument-in-strict-mode.js
new file mode 100644
index 0000000..23b52fb
--- /dev/null
+++ b/tests/integration/array-instantiation-with-object-argument-in-strict-mode.js
@@ -0,0 +1,12 @@
+/*
+2
+*/
+#pragma strict
+
+function newStringArray(i) {
+ return new String[i];
+}
+
+print(newStringArray(2).Length);
+
+
diff --git a/tests/integration/array-instantiation-with-object-argument.js b/tests/integration/array-instantiation-with-object-argument.js
new file mode 100644
index 0000000..bc0140f
--- /dev/null
+++ b/tests/integration/array-instantiation-with-object-argument.js
@@ -0,0 +1,10 @@
+/*
+2
+*/
+function newStringArray(i) {
+ return new String[i];
+}
+
+print(newStringArray(2).Length);
+
+
diff --git a/tests/integration/array-length-duck-typed.js b/tests/integration/array-length-duck-typed.js
new file mode 100644
index 0000000..9b99a7a
--- /dev/null
+++ b/tests/integration/array-length-duck-typed.js
@@ -0,0 +1,15 @@
+/*
+1
+1
+*/
+import UnityScript.Tests;
+
+function run() {
+ var components = GetComponents(ComponentFoo);
+ print(components.length);
+
+ var cpnts:Component[] = components;
+ print(cpnts.length);
+}
+
+run();
diff --git a/tests/integration/array-nesting.js b/tests/integration/array-nesting.js
new file mode 100644
index 0000000..2219dd8
--- /dev/null
+++ b/tests/integration/array-nesting.js
@@ -0,0 +1,20 @@
+/*
+System.Int32[][]
+1
+2
+3
+4
+System.String[][]
+foo
+bar
+baz
+*/
+function dump(a) {
+ print(a.GetType());
+ for (var nested in a)
+ for (var i in nested) print(i);
+}
+
+var nestedInts = [[1, 2], [3, 4]];
+dump(nestedInts);
+dump([["foo", "bar"], ["baz"]]);
diff --git a/tests/integration/array-push-2.js b/tests/integration/array-push-2.js
index 410af1a..7c95a55 100644
--- a/tests/integration/array-push-2.js
+++ b/tests/integration/array-push-2.js
@@ -12,8 +12,7 @@ array.push(1);
print (array[0]);
print (array[1]);
-pushed = array.push("bird", "fish");
-print (pushed );
+print (array.push("bird", "fish"));
print (array[2]);
print (array[3]);
diff --git a/tests/integration/array-push.js b/tests/integration/array-push.js
index b946617..6046fa7 100644
--- a/tests/integration/array-push.js
+++ b/tests/integration/array-push.js
@@ -12,11 +12,11 @@ array.push(1);
print (array[0]);
print (array[1]);
+var pushed;
pushed = array.push("bird");
array.push("fish");
print (array[2]);
print (array[3]);
-
print (pushed );
diff --git a/tests/integration/array-shift.js b/tests/integration/array-shift.js
index 7cbe5be..5962e86 100644
--- a/tests/integration/array-shift.js
+++ b/tests/integration/array-shift.js
@@ -6,7 +6,7 @@ fish
*/
var array = new Array("cat", "dog", "bird", "fish");
-shifted = array.shift();
+var shifted = array.shift();
print ( shifted );
print ( array[0] );
diff --git a/tests/integration/array-slice.js b/tests/integration/array-slice.js
index 429489b..0194551 100644
--- a/tests/integration/array-slice.js
+++ b/tests/integration/array-slice.js
@@ -8,7 +8,7 @@ canary
parrot
*/
var pets_array = new Array("cat", "dog", "fish", "canary", "parrot");
-fourLeggedPets_array = pets_array.slice(0, 2);
+var fourLeggedPets_array = pets_array.slice(0, 2);
print ( fourLeggedPets_array[0] );
print ( fourLeggedPets_array[1] );
diff --git a/tests/integration/array-unshift.js b/tests/integration/array-unshift.js
index 30ec9fc..4caef6b 100644
--- a/tests/integration/array-unshift.js
+++ b/tests/integration/array-unshift.js
@@ -17,8 +17,7 @@ print ( array[0] );
print ( array[1] );
print ( array[2] );
-n = array.unshift("ferrets", "gophers", "engineers");
-print ( n );
+print (array.unshift("ferrets", "gophers", "engineers"));
print ( array[0] );
print ( array[1] );
diff --git a/tests/integration/array-length.js b/tests/integration/array-with-initial-length.js
similarity index 100%
rename from tests/integration/array-length.js
rename to tests/integration/array-with-initial-length.js
diff --git a/tests/integration/array-with-two-dimensions.js b/tests/integration/array-with-two-dimensions.js
new file mode 100644
index 0000000..84cb527
--- /dev/null
+++ b/tests/integration/array-with-two-dimensions.js
@@ -0,0 +1,9 @@
+/*
+System.Int32[,]
+2
+3
+*/
+var a:int[,] = new int[2, 3];
+print(a.GetType());
+for (var i=0; i= 12) break;
+} while (true);
+
+i = 100;
+do {
+ print(i);
+ var j = 0;
+ do {
+ print(i + ", " + j);
+ if (++j >= 2) break;
+ } while (true);
+ print("***");
+} while (++i < 102);
+
+
diff --git a/tests/integration/double-precision-can-be-used-for-literals.js b/tests/integration/double-precision-can-be-used-for-literals.js
new file mode 100644
index 0000000..c24b8ef
--- /dev/null
+++ b/tests/integration/double-precision-can-be-used-for-literals.js
@@ -0,0 +1,9 @@
+/*
+System.Double
+-4.42330604244772
+*/
+var e = -4.42330604244772d;
+print(e.GetType());
+var g = System.Convert.ToString(e);
+print(g);
+
diff --git a/tests/integration/empty-array-literal-as-return-value.js b/tests/integration/empty-array-literal-as-return-value.js
new file mode 100644
index 0000000..0cd8a76
--- /dev/null
+++ b/tests/integration/empty-array-literal-as-return-value.js
@@ -0,0 +1,8 @@
+/*
+System.String[]
+*/
+function foo(): String[] {
+ return [];
+}
+
+print(foo().GetType());
diff --git a/tests/integration/empty-array-literal-as-yield-value.js b/tests/integration/empty-array-literal-as-yield-value.js
new file mode 100644
index 0000000..3ff937d
--- /dev/null
+++ b/tests/integration/empty-array-literal-as-yield-value.js
@@ -0,0 +1,9 @@
+/*
+System.String[]
+*/
+function foo(): System.Collections.Generic.IEnumerable. {
+ yield [];
+}
+
+for (var f in foo())
+ print(f.GetType());
diff --git a/tests/integration/float-1.js b/tests/integration/float-1.js
index cc8a4eb..ba85782 100644
--- a/tests/integration/float-1.js
+++ b/tests/integration/float-1.js
@@ -1,10 +1,37 @@
/*
System.Single
System.Single
+System.Single
+System.Single
+System.Single
+System.Single
+System.Single
+System.Double
+System.Single
*/
-value = .5;
-System.Console.WriteLine(value.GetType());
+var v1 = .5;
+print(v1.GetType());
+
+var v2 = .5f;
+print(v2.GetType());
+
+var v3 = .55;
+print(v3.GetType());
+
+var v4 = .55f;
+print(v4.GetType());
+
+var v5 = .555;
+print(v5.GetType());
+
+var v6 = .555f;
+print(v6.GetType());
+
+var v7 = .5555;
+print(v7.GetType());
-value = .5f;
-System.Console.WriteLine(value.GetType());
+var v8 = .5555d;
+print(v8.GetType());
+var v9 = .5555f; // forces single precision
+print(v9.GetType());
diff --git a/tests/integration/float-array-literal.js b/tests/integration/float-array-literal.js
new file mode 100644
index 0000000..a35789e
--- /dev/null
+++ b/tests/integration/float-array-literal.js
@@ -0,0 +1,10 @@
+/*
+1
+0.7
+*/
+function run() {
+ var floats:float[] = [1.0, 0.7f];
+ for (var f in floats) print(f);
+}
+
+run();
diff --git a/tests/integration/float-overload-is-preferred-over-int-for-double-argument-2.js b/tests/integration/float-overload-is-preferred-over-int-for-double-argument-2.js
new file mode 100644
index 0000000..f21c849
--- /dev/null
+++ b/tests/integration/float-overload-is-preferred-over-int-for-double-argument-2.js
@@ -0,0 +1,7 @@
+/*
+F(float, float)
+*/
+
+import UnityScript.Tests.CSharp;
+
+NumericOverloads.F(0.16, 0.19);
diff --git a/tests/integration/float-overload-is-preferred-over-int-for-double-argument-strict-downcast.js b/tests/integration/float-overload-is-preferred-over-int-for-double-argument-strict-downcast.js
new file mode 100644
index 0000000..fa88e6e
--- /dev/null
+++ b/tests/integration/float-overload-is-preferred-over-int-for-double-argument-strict-downcast.js
@@ -0,0 +1,10 @@
+/*
+F(float, float)
+*/
+
+#pragma strict
+#pragma downcast
+
+function F(a:float, b:float) { print("F(float, float)"); }
+function F(a:int, b:int) {}
+F(0.16, 0.19);
diff --git a/tests/integration/float-overload-is-preferred-over-int-for-double-argument-strict.js b/tests/integration/float-overload-is-preferred-over-int-for-double-argument-strict.js
new file mode 100644
index 0000000..e9f4931
--- /dev/null
+++ b/tests/integration/float-overload-is-preferred-over-int-for-double-argument-strict.js
@@ -0,0 +1,9 @@
+/*
+F(float, float)
+*/
+
+#pragma strict
+
+function F(a:float, b:float) { print("F(float, float)"); }
+function F(a:int, b:int) {}
+F(0.16, 0.19);
diff --git a/tests/integration/float-overload-is-preferred-over-int-for-double-argument.js b/tests/integration/float-overload-is-preferred-over-int-for-double-argument.js
new file mode 100644
index 0000000..7c9ca41
--- /dev/null
+++ b/tests/integration/float-overload-is-preferred-over-int-for-double-argument.js
@@ -0,0 +1,7 @@
+/*
+F(float, float)
+*/
+
+function F(a:float, b:float) { print("F(float, float)"); }
+function F(a:int, b:int) {}
+F(0.16, 0.19);
diff --git a/tests/integration/for-in-switch-break.js b/tests/integration/for-in-switch-break.js
new file mode 100755
index 0000000..f053fac
--- /dev/null
+++ b/tests/integration/for-in-switch-break.js
@@ -0,0 +1,41 @@
+/*
+5
+4
+3
+2
+JS for: Boom
+5
+4
+3
+2
+JS for in: Boom
+*/
+function Start() {
+ for (var a=1; a<=2; ++a) {
+ switch (a) {
+ case 1:
+ for (var b=5; b>0; b--) {
+ print(b);
+ if (b == 2) {
+ break;
+ }
+ }
+ print("JS for: Boom");
+ break;
+
+ case 2:
+ var ts : int[] = [5,4,3,2,1,0];
+ for (var t in ts) {
+ print(t);
+ if (t == 2) {
+ break;
+ }
+ }
+ print("JS for in: Boom");
+ break;
+ }
+ }
+}
+
+Start();
+
diff --git a/tests/integration/for-var-reuse.js b/tests/integration/for-var-reuse.js
new file mode 100644
index 0000000..0ff2f3b
--- /dev/null
+++ b/tests/integration/for-var-reuse.js
@@ -0,0 +1,16 @@
+/*
+FOO
+BAR
+after: bar
+*/
+#pragma strict
+
+function test() {
+ var array: Array = new Array("foo", "bar");
+ var s: String;
+ for (s in array)
+ print(s.ToUpper());
+ print("after: " + s);
+}
+
+test();
diff --git a/tests/integration/functions-as-ternary-operands.js b/tests/integration/functions-as-ternary-operands.js
new file mode 100644
index 0000000..6f298c5
--- /dev/null
+++ b/tests/integration/functions-as-ternary-operands.js
@@ -0,0 +1,23 @@
+/*
+foo
+bar
+foo
+bar
+*/
+function choose(value) {
+ var f = value ? f1 : f2;
+ f();
+}
+
+function invoke(value) {
+ (value ? f1 : f2)();
+}
+
+function f1() { print('foo'); }
+function f2() { print('bar'); }
+
+choose(true);
+choose(false);
+
+invoke(true);
+invoke(false);
diff --git a/tests/integration/implicit-array-to-native-array-cast.js b/tests/integration/implicit-array-to-native-array-cast.js
new file mode 100644
index 0000000..193f46d
--- /dev/null
+++ b/tests/integration/implicit-array-to-native-array-cast.js
@@ -0,0 +1,8 @@
+/*
+0,1,2
+*/
+var output : int[];
+var array = Array(0, 1, 2);
+output = array;
+print(join(output, ","));
+
diff --git a/tests/integration/implict-bool-hierarchy.js b/tests/integration/implict-bool-hierarchy.js
new file mode 100644
index 0000000..0ed08bb
--- /dev/null
+++ b/tests/integration/implict-bool-hierarchy.js
@@ -0,0 +1,56 @@
+/*
+yes
+yes
+*/
+class Component {
+ static function op_Implicit(self: Component): boolean {
+ return self.enabled;
+ }
+
+ function Component(enabled: boolean) {
+ this.enabled = enabled;
+ }
+
+ private var enabled: boolean;
+}
+
+class Rigidbody extends Component {
+ function Rigidbody() {
+ super(false);
+ }
+
+ function get isKinematic() {
+ return true;
+ }
+}
+
+class Collider extends Component {
+ function Collider() {
+ super(true);
+ }
+}
+
+class Behaviour extends Component {
+
+ function Behaviour() { super(true); }
+
+ function get rigidbody() { return new Rigidbody(); }
+ function get collider() { return new Collider(); }
+}
+
+class Foo extends Behaviour {
+ function Start() {
+
+ if (rigidbody && rigidbody.isKinematic)
+ print("fail");
+ else
+ print("yes");
+
+ if (!collider)
+ print("fail");
+ else
+ print("yes");
+ }
+}
+
+new Foo().Start();
diff --git a/tests/integration/inferred-GetComponent.js b/tests/integration/inferred-GetComponent.js
new file mode 100644
index 0000000..ef23e80
--- /dev/null
+++ b/tests/integration/inferred-GetComponent.js
@@ -0,0 +1,13 @@
+/*
+foo
+bar
+*/
+#pragma strict
+
+import UnityScript.Tests;
+
+var foo = InferredGetComponent(ComponentFoo);
+foo.Foo();
+
+var bar = InferredGetComponent(ComponentBar);
+bar.Bar();
\ No newline at end of file
diff --git a/tests/integration/interface-properties.js b/tests/integration/interface-properties.js
new file mode 100644
index 0000000..86c2920
--- /dev/null
+++ b/tests/integration/interface-properties.js
@@ -0,0 +1,22 @@
+/*
+foo
+bar
+*/
+interface I {
+ function get message(): String;
+}
+
+class Foo implements I {
+ function get message() { return "foo"; }
+}
+
+class Bar implements I {
+ function get message() { return "bar"; }
+}
+
+function doIt(i: I) {
+ print(i.message);
+}
+
+doIt(new Foo());
+doIt(new Bar());
diff --git a/tests/integration/internal-field.js b/tests/integration/internal-field.js
new file mode 100644
index 0000000..0bebe72
--- /dev/null
+++ b/tests/integration/internal-field.js
@@ -0,0 +1,8 @@
+/*
+True
+*/
+import System.Reflection;
+
+internal var i = 42;
+
+print(GetType().GetField("i", BindingFlags.Instance|BindingFlags.NonPublic).IsAssembly);
diff --git a/tests/integration/linq-array-ToList.js b/tests/integration/linq-array-ToList.js
new file mode 100644
index 0000000..3a93592
--- /dev/null
+++ b/tests/integration/linq-array-ToList.js
@@ -0,0 +1,8 @@
+/*
+System.Collections.Generic.List`1[System.Int32]
+*/
+import System.Linq.Enumerable;
+
+var a = [1, 2, 3];
+var l = a.ToList(); // Enumerable.ToList(a)
+print(l.GetType());
diff --git a/tests/integration/linq-function-inference.js b/tests/integration/linq-function-inference.js
new file mode 100644
index 0000000..c82fa9d
--- /dev/null
+++ b/tests/integration/linq-function-inference.js
@@ -0,0 +1,10 @@
+/*
+1
+3
+*/
+import System.Linq.Enumerable;
+
+var a = [1, 2, 3];
+var oddNumbers = a.Where(function(i) { return i % 2 != 0; });
+for (var i in oddNumbers) print(i);
+
diff --git a/tests/integration/linq-lambda-inference.js b/tests/integration/linq-lambda-inference.js
new file mode 100644
index 0000000..5d373b2
--- /dev/null
+++ b/tests/integration/linq-lambda-inference.js
@@ -0,0 +1,17 @@
+/*
+1
+3
+1
+3
+*/
+import System.Linq.Enumerable;
+
+function foreach(items, action: function(Object)) {
+ for (var item in items) action(item);
+}
+
+var odd = [1, 2, 3].Where(function(i) i % 2 != 0);
+var p = function(o) print(o);
+foreach(odd, p);
+foreach(odd, function(o) print(o));
+
diff --git a/tests/integration/multidimensional-array-of-struct.js b/tests/integration/multidimensional-array-of-struct.js
new file mode 100644
index 0000000..cf544f2
--- /dev/null
+++ b/tests/integration/multidimensional-array-of-struct.js
@@ -0,0 +1,15 @@
+/*
+5
+5
+*/
+class TStruc extends System.ValueType {
+ var blub : int;
+}
+
+var oneDim = new TStruc[5];
+var multiDim = new TStruc[5,5];
+oneDim[0].blub = 5;
+print(oneDim[0].blub);
+
+multiDim[0,0].blub = 5;
+print(multiDim[0,0].blub);
diff --git a/tests/integration/multidimensional-arrays-1.js b/tests/integration/multidimensional-arrays-1.js
new file mode 100644
index 0000000..f2a450f
--- /dev/null
+++ b/tests/integration/multidimensional-arrays-1.js
@@ -0,0 +1,17 @@
+/*
+012 123 234
+123 234 345
+234 345 456
+*/
+import System;
+import UnityScript.Tests.CSharp;
+
+var a = MultidimensionalArrays.GetArray(3, 3, 3);
+for (var i = 0; i<3; ++i) {
+ for (var j = 0; j<3; ++j) {
+ for (var k = 0; k<3; ++k)
+ Console.Write(a[i, j, k]);
+ Console.Write(" ");
+ }
+ Console.WriteLine();
+}
diff --git a/tests/integration/nested-classes.js b/tests/integration/nested-classes.js
new file mode 100644
index 0000000..154c9d9
--- /dev/null
+++ b/tests/integration/nested-classes.js
@@ -0,0 +1,55 @@
+/*
+public class A extends Object {
+}
+public class A.B extends Object {
+}
+public class A.B.C extends E {
+ public var value;
+}
+private class A.D extends Object {
+}
+internal class E extends Object {
+}
+*/
+
+import System.Reflection;
+
+class A {
+
+ public class B {
+ class C extends E {
+ var value = "C.value";
+ }
+ }
+
+ private class D {
+ }
+}
+
+internal class E {
+}
+
+function printEffectiveTypeDeclaration(type: System.Type) {
+ print(visibilityOf(type) + " class " + fullNameOf(type) + " extends " + type.BaseType.Name + " {");
+ printFieldsOf(type);
+ print("}");
+}
+
+function printFieldsOf(type: System.Type) {
+ for (var f in type.GetFields(BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.Instance))
+ print("\t" + (f.IsPublic ? "public" : "private") + " var " + f.Name + ";");
+}
+
+function visibilityOf(type: System.Type) {
+ if (type.IsPublic || type.IsNestedPublic) return "public";
+ if (type.IsNestedPrivate) return "private";
+ if (type.IsNestedFamily) return "protected";
+ return "internal";
+}
+
+function fullNameOf(type: System.Type) {
+ return type.FullName.Replace("+", ".");
+}
+
+for (var type in [A, A.B, A.B.C, A.D, E])
+ printEffectiveTypeDeclaration(type);
\ No newline at end of file
diff --git a/tests/integration/not-in.js b/tests/integration/not-in.js
new file mode 100644
index 0000000..0fe9712
--- /dev/null
+++ b/tests/integration/not-in.js
@@ -0,0 +1,7 @@
+/*
+not
+yeah
+*/
+var array = ["apple", "orange", "kiwi"];
+for each (var item in ["microsoft", "apple"])
+ print(item not in array ? "not" : "yeah");
\ No newline at end of file
diff --git a/tests/integration/null-initializer.js b/tests/integration/null-initializer.js
new file mode 100644
index 0000000..49944ac
--- /dev/null
+++ b/tests/integration/null-initializer.js
@@ -0,0 +1,10 @@
+/*
+System.Object[]
+*/
+function run() {
+ var obj = null;
+ obj = new Object[0];
+ print(obj.GetType());
+}
+
+run();
diff --git a/tests/integration/parse_int.js b/tests/integration/parse_int.js
index 3d20db4..2e0fa7e 100644
--- a/tests/integration/parse_int.js
+++ b/tests/integration/parse_int.js
@@ -1,4 +1,8 @@
/*
+42
+2
1
*/
-print(parseInt(1.5));
\ No newline at end of file
+print(parseInt(42.5d));
+print(parseInt(2));
+print(parseInt(1.5f));
\ No newline at end of file
diff --git a/tests/integration/quack-fu.js b/tests/integration/quack-fu.js
new file mode 100644
index 0000000..7aaa861
--- /dev/null
+++ b/tests/integration/quack-fu.js
@@ -0,0 +1,25 @@
+/*
+Eric Idle
+*/
+class Expando implements Boo.Lang.IQuackFu {
+
+ private var _attrs = {};
+
+ function QuackGet(name: String, parameters: Object[]) {
+ return _attrs[name];
+ }
+
+ function QuackSet(name: String, parameters: Object[], value) {
+ _attrs[name] = value;
+ return value;
+ }
+
+ function QuackInvoke(name: String, args: Object[]) {
+ throw new System.NotImplementedException();
+ }
+}
+
+var e = new Expando();
+e.firstName = "Eric";
+e.lastName = "Idle";
+print(e.firstName + " " + e.lastName);
diff --git a/tests/integration/rethrow.js b/tests/integration/rethrow.js
new file mode 100644
index 0000000..c5d6bc4
--- /dev/null
+++ b/tests/integration/rethrow.js
@@ -0,0 +1,18 @@
+/*
+caught
+recaught
+*/
+function rethrow() {
+ try {
+ throw new System.ApplicationException();
+ } catch (e) {
+ print("caught");
+ throw;
+ }
+}
+
+try {
+ rethrow();
+} catch (e:System.ApplicationException) {
+ print("recaught");
+}
diff --git a/tests/integration/script-attributes.js b/tests/integration/script-attributes.js
index 115a78a..595c5ea 100644
--- a/tests/integration/script-attributes.js
+++ b/tests/integration/script-attributes.js
@@ -1,12 +1,11 @@
-/*
+/*
yes
-*/
+*/
import UnityScript.Tests;
-
@script AttributeWithMask (AttributeMaskEnum.Foo | AttributeMaskEnum.Bar)
-var attr : AttributeWithMask = GetType().GetCustomAttributes(AttributeWithMask, false)[0];
+var attr = GetType().GetCustomAttributes(AttributeWithMask, false)[0] as AttributeWithMask;
if (attr.mask == (AttributeMaskEnum.Foo | AttributeMaskEnum.Bar))
print ("yes");
\ No newline at end of file
diff --git a/tests/integration/script-properties.js b/tests/integration/script-properties.js
new file mode 100755
index 0000000..bf5d609
--- /dev/null
+++ b/tests/integration/script-properties.js
@@ -0,0 +1,17 @@
+/*
+42
+-1
+*/
+private var _v = 42;
+
+function get v() {
+ return _v;
+}
+
+function set v(value) {
+ _v = value;
+}
+
+print(v);
+v = -1;
+print(v);
diff --git a/tests/integration/shift-left-bitwise-or.js b/tests/integration/shift-left-bitwise-or.js
new file mode 100644
index 0000000..37ecf3f
--- /dev/null
+++ b/tests/integration/shift-left-bitwise-or.js
@@ -0,0 +1,5 @@
+/*
+768
+*/
+var value = 1<<9 | 1<<8;
+print(value);
diff --git a/tests/integration/static-instance-overload-resolution.js b/tests/integration/static-instance-overload-resolution.js
new file mode 100644
index 0000000..e594aed
--- /dev/null
+++ b/tests/integration/static-instance-overload-resolution.js
@@ -0,0 +1,16 @@
+/*
+static
+instance
+*/
+class Foo {
+ static function Bar(value) {
+ print("static");
+ }
+
+ function Bar() {
+ print("instance");
+ }
+}
+
+Foo.Bar(42);
+new Foo().Bar();
diff --git a/tests/integration/switch-3.js b/tests/integration/switch-3.js
index d75a8d6..c3f3df1 100644
--- a/tests/integration/switch-3.js
+++ b/tests/integration/switch-3.js
@@ -2,12 +2,11 @@
True
*/
var journalList = Array ("TT");
-
-for (var N : String in journalList)
-{
- switch(N){
- case "TT":
- print ("True");
- break;
- }
+for (var N in journalList) {
+ var selector = N as String;
+ switch (selector) {
+ case "TT":
+ print ("True");
+ break;
+ }
}
diff --git a/tests/integration/typecast-1.js b/tests/integration/typecast-1.js
index df19d01..ee54a20 100644
--- a/tests/integration/typecast-1.js
+++ b/tests/integration/typecast-1.js
@@ -3,12 +3,12 @@ Right
*/
import UnityScript.Tests;
-b = transform as MonoBehaviour;
+var b = transform as MonoBehaviour;
if (b != null) {
print ("Wrong");
}
-c = transform as Transform;
+var c = transform as Transform;
if (c != null) {
print ("Right");
}
\ No newline at end of file
diff --git a/tests/integration/typeof-1.js b/tests/integration/typeof-1.js
index a17c8e2..776d643 100644
--- a/tests/integration/typeof-1.js
+++ b/tests/integration/typeof-1.js
@@ -1,6 +1,9 @@
/*
System.Int32
Foo
+Foo
+Foo[]
+System.String
*/
import UnityScript.Tests;
@@ -8,5 +11,10 @@ class Foo {
}
print(typeof(1));
-test = new Foo();
-print(typeof(test));
\ No newline at end of file
+var test = new Foo();
+print(typeof(test));
+print(typeof(Foo));
+print(typeof(Foo[]));
+
+var a = ["foo"];
+print(typeof(a[0]));
\ No newline at end of file
diff --git a/tests/integration/typeof-2.js b/tests/integration/typeof-2.js
new file mode 100644
index 0000000..91bb013
--- /dev/null
+++ b/tests/integration/typeof-2.js
@@ -0,0 +1,5 @@
+/*
+String
+*/
+
+print(typeof(String).Name);
\ No newline at end of file
diff --git a/tests/integration/uint-1.js b/tests/integration/uint-1.js
new file mode 100644
index 0000000..7b2bba1
--- /dev/null
+++ b/tests/integration/uint-1.js
@@ -0,0 +1,9 @@
+/*
+2147483648
+*/
+function run() {
+ var myUInt : uint = 2147483648;
+ print(myUInt);
+}
+
+run();
diff --git a/tests/integration/ulong-bitshift-1.js b/tests/integration/ulong-bitshift-1.js
new file mode 100644
index 0000000..b13be21
--- /dev/null
+++ b/tests/integration/ulong-bitshift-1.js
@@ -0,0 +1,13 @@
+/*
+2
+*/
+#pragma strict
+
+function Start()
+{
+ var x : ulong = 1;
+ x = x << 1;
+ print(x);
+}
+
+Start();
diff --git a/tests/integration/ulong-bitshift-overflow-regression.js b/tests/integration/ulong-bitshift-overflow-regression.js
new file mode 100644
index 0000000..a1f150d
--- /dev/null
+++ b/tests/integration/ulong-bitshift-overflow-regression.js
@@ -0,0 +1,23 @@
+/*
+0.04210299
+*/
+#pragma strict
+
+function randomNumber2D(x: float, y: float): float {
+ var a: ulong = x * System.Convert.ToSingle(uint.MaxValue);
+ var b: ulong = y * System.Convert.ToSingle(uint.MaxValue);
+
+ //hash numbers
+ var key : ulong = (a << 32) | b;
+ key = (~key) + (key << 18);
+ key = (key & ~(key >> 31)) | (~key & (key >> 31));
+ key = (key + (key << 2)) + (key << 4); //key = key * 21;
+ key = (key & ~(key >> 11)) | (~key & (key >> 11));
+ key = key + (key << 6);
+ key = (key & ~(key >> 22)) | (~key & (key >> 22));
+
+ //discard 32 most significant bits and scale to between 0 and 1
+ return (key & 0xFFFFFFFF) / System.Convert.ToSingle(uint.MaxValue);
+}
+
+print(randomNumber2D(.9996847, .4148785));
diff --git a/tests/integration/value-types-1.js b/tests/integration/value-types-1.js
new file mode 100644
index 0000000..f0b8629
--- /dev/null
+++ b/tests/integration/value-types-1.js
@@ -0,0 +1,27 @@
+/*
+True
+True
+True
+True
+Pair(foo, bar)
+*/
+class Pair extends System.ValueType {
+ var First: Object;
+ var Second: Object;
+
+ function Pair(fst, snd) {
+ First = fst;
+ Second = snd;
+ }
+
+ override function ToString() {
+ return "Pair(" + First + ", " + Second + ")";
+ }
+}
+
+var type = Pair;
+print(type.IsValueType);
+print(type.IsSealed);
+for (var field in ["First", "Second"])
+ print(type.GetField(field).IsPublic);
+print(new Pair("foo", "bar"));
diff --git a/tests/integration/varargs-in-constructor-with-vector3.js b/tests/integration/varargs-in-constructor-with-vector3.js
new file mode 100644
index 0000000..f6e9dd2
--- /dev/null
+++ b/tests/integration/varargs-in-constructor-with-vector3.js
@@ -0,0 +1,55 @@
+/*
+2
+1
+1
+0
+0
+2
+1
+0
+0
+*/
+import UnityScript.Tests.CSharp;
+
+class C1 extends VarArgsConstructors {
+ function C1() {
+ super(Vector3(0, 0, 0), Vector3(0, 0, 0));
+ }
+}
+
+class C2 extends VarArgsConstructors {
+ function C2() {
+ super([Vector3(0, 0, 0)]);
+ }
+}
+
+class C3 extends VarArgsConstructors {
+ function C3() {
+ super([]);
+ }
+}
+
+class C4 extends VarArgsConstructors {
+ function C4() {
+ super();
+ }
+}
+
+
+function printArrayLen(o: VarArgsConstructors) {
+ print(o.array.Length);
+}
+
+var items = [
+ VarArgsConstructors(Vector3(0, 0, 0), Vector3(0, 0, 0)),
+ VarArgsConstructors([Vector3(0, 0, 0)]),
+ VarArgsConstructors(Vector3(0, 0, 0)),
+ VarArgsConstructors([]),
+ VarArgsConstructors(),
+ C1(),
+ C2(),
+ C3(),
+ C4()
+];
+for (var item in items)
+ printArrayLen(item);
diff --git a/tests/integration/varargs-with-vector3.js b/tests/integration/varargs-with-vector3.js
new file mode 100644
index 0000000..87fa970
--- /dev/null
+++ b/tests/integration/varargs-with-vector3.js
@@ -0,0 +1,10 @@
+/*
+2
+1
+0
+*/
+import UnityScript.Tests.CSharp;
+
+print(VarArgsMethods.WithVector3(Vector3(0, 0, 0), Vector3(0, 0, 0)));
+print(VarArgsMethods.WithVector3([Vector3(0, 0, 0)]));
+print(VarArgsMethods.WithVector3([]));
diff --git a/tests/integration/vars-1.js b/tests/integration/vars-1.js
index 3f7a80f..72a119f 100644
--- a/tests/integration/vars-1.js
+++ b/tests/integration/vars-1.js
@@ -1,6 +1,5 @@
/*
*/
-import NUnit.Framework;
import System.Reflection;
var a = "foo";
@@ -11,18 +10,26 @@ var flags = BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.Instance|Bin
var type = GetType();
function AssertField(name:String) {
- field = type.GetField(name, flags);
- Assert.IsNotNull(field, name);
+ var field = type.GetField(name, flags);
+ if (field == null) throw name;
return field;
}
-fa = AssertField("a");
-fb = AssertField("b");
-fc = AssertField("c");
+function AssertIsTrue(condition:boolean, description:String) {
+ if (!condition) throw description;
+}
+
+function AssertIsFalse(condition:boolean, description:String) {
+ if (condition) throw description;
+}
+
+var fa = AssertField("a");
+var fb = AssertField("b");
+var fc = AssertField("c");
-Assert.IsTrue(fa.IsPublic, "public a");
-Assert.IsFalse(fa.IsStatic, "instance a");
-Assert.IsTrue(fb.IsPrivate, "private b");
-Assert.IsFalse(fb.IsStatic, "instance b");
-Assert.IsTrue(fc.IsPublic, "public c");
-Assert.IsTrue(fc.IsStatic, "static c");
+AssertIsTrue(fa.IsPublic, "public a");
+AssertIsFalse(fa.IsStatic, "instance a");
+AssertIsTrue(fb.IsPrivate, "private b");
+AssertIsFalse(fb.IsStatic, "instance b");
+AssertIsTrue(fc.IsPublic, "public c");
+AssertIsTrue(fc.IsStatic, "static c");
diff --git a/tests/integration/yield-null.js b/tests/integration/yield-null.js
new file mode 100644
index 0000000..e056e45
--- /dev/null
+++ b/tests/integration/yield-null.js
@@ -0,0 +1,15 @@
+/*
+before
+after
+*/
+
+function generator() {
+ print("before");
+ yield null;
+ print("after");
+}
+
+for (var e in generator()) {
+ if (e != null)
+ throw "expected null";
+}
diff --git a/tests/parser/array-types.js b/tests/parser/array-types.js
new file mode 100644
index 0000000..48a9369
--- /dev/null
+++ b/tests/parser/array-types.js
@@ -0,0 +1,10 @@
+/*
+a1 as (int)
+
+a2 as (int, 2)
+
+a3 as (int, 3)
+*/
+var a1:int[];
+var a2:int[,];
+var a3:int[,,];
diff --git a/tests/parser/attributes-1.js b/tests/parser/attributes-1.js
index 047b9ca..1500e09 100644
--- a/tests/parser/attributes-1.js
+++ b/tests/parser/attributes-1.js
@@ -4,7 +4,10 @@
class Foo:
[AnotherOne(true, Name: 'foo')]
- def bar():
+ def bar([NotNull] arg1):
+ pass
+
+ def baz(arg1, [Required((arg2 > 0))] arg2 as int):
pass
[AttributeForField(Foo.Bar)]
@@ -15,7 +18,10 @@ class Foo:
class Foo {
@AnotherOne(true, Name="foo")
- function bar() {
+ function bar(@NotNull arg1) {
+ }
+
+ function baz(arg1, @Required(arg2 > 0) arg2: int) {
}
@AttributeForField(Foo.Bar)
diff --git a/tests/parser/attributes-for-script-and-assembly-before-import.js b/tests/parser/attributes-for-script-and-assembly-before-import.js
new file mode 100644
index 0000000..b031dd7
--- /dev/null
+++ b/tests/parser/attributes-for-script-and-assembly-before-import.js
@@ -0,0 +1,17 @@
+/*
+import Foo
+
+[AttributeForField]
+f as float
+
+[module: SomeScriptAttribute]
+[assembly: SomeAssemblyAttribute]
+*/
+@script SomeScriptAttribute()
+@assembly SomeAssemblyAttribute()
+
+import Foo;
+
+@AttributeForField var f:float;
+
+
diff --git a/tests/parser/attributes-for-script-and-assembly.js b/tests/parser/attributes-for-script-and-assembly.js
new file mode 100644
index 0000000..017a819
--- /dev/null
+++ b/tests/parser/attributes-for-script-and-assembly.js
@@ -0,0 +1,10 @@
+/*
+[AttributeForField]
+f as float
+
+[module: SomeScriptAttribute]
+[assembly: SomeAssemblyAttribute]
+*/
+@script SomeScriptAttribute()
+@assembly SomeAssemblyAttribute()
+@AttributeForField var f:float;
diff --git a/tests/parser/class-modifiers.js b/tests/parser/class-modifiers.js
new file mode 100644
index 0000000..0e18f92
--- /dev/null
+++ b/tests/parser/class-modifiers.js
@@ -0,0 +1,25 @@
+/*
+final class C1:
+ pass
+
+internal class C2:
+ pass
+
+internal final class C3:
+ pass
+
+static class C4:
+ pass
+*/
+
+final class C1 {
+}
+
+internal class C2 {
+}
+
+internal final class C3 {
+}
+
+static class C4 {
+}
\ No newline at end of file
diff --git a/tests/parser/do-while-1.js b/tests/parser/do-while-1.js
new file mode 100644
index 0000000..95cb05f
--- /dev/null
+++ b/tests/parser/do-while-1.js
@@ -0,0 +1,11 @@
+/*
+i = 0
+
+while true:
+ print(i)
+ break unless ((++i) < 2)
+*/
+var i = 0;
+do {
+ print(i);
+} while (++i < 2);
diff --git a/tests/parser/do-while-false.js b/tests/parser/do-while-false.js
new file mode 100644
index 0000000..cf19167
--- /dev/null
+++ b/tests/parser/do-while-false.js
@@ -0,0 +1,6 @@
+/*
+while true:
+ break unless false
+*/
+do {
+} while (false);
diff --git a/tests/parser/empty-blocks.js b/tests/parser/empty-blocks.js
new file mode 100644
index 0000000..3ea9258
--- /dev/null
+++ b/tests/parser/empty-blocks.js
@@ -0,0 +1,10 @@
+/*
+def Start():
+ pass
+*/
+function Start() {
+ {}
+}
+
+{ {} }
+
diff --git a/tests/parser/empty-map-literal.js b/tests/parser/empty-map-literal.js
new file mode 100644
index 0000000..61fc0d0
--- /dev/null
+++ b/tests/parser/empty-map-literal.js
@@ -0,0 +1,7 @@
+/*
+def f():
+ return {}
+*/
+function f() {
+ return {};
+}
diff --git a/tests/parser/enums.js b/tests/parser/enums.js
new file mode 100644
index 0000000..6f52877
--- /dev/null
+++ b/tests/parser/enums.js
@@ -0,0 +1,33 @@
+/*
+enum E1:
+
+ Foo
+
+ Bar
+
+public enum E2:
+
+ Foo
+
+ Bar
+
+[flags]
+enum E3:
+
+ [attr]
+ Foo = 1
+
+ [attr]
+ Bar = 2
+*/
+enum E1 { Foo, Bar }
+public enum E2 { Foo, Bar }
+
+@flags
+enum E3 {
+ @attr Foo = 1,
+ @attr
+ Bar = 2
+}
+
+
diff --git a/tests/parser/for-each-in-1.js b/tests/parser/for-each-in-1.js
new file mode 100644
index 0000000..314b968
--- /dev/null
+++ b/tests/parser/for-each-in-1.js
@@ -0,0 +1,15 @@
+/*
+testString = 'Test'
+
+for i in testString:
+ print(i)
+for k in testString:
+ print(k)
+*/
+var testString = "Test";
+for each (var i in testString) {
+ print (i);
+}
+for each (k in testString) {
+ print (k);
+}
\ No newline at end of file
diff --git a/tests/parser/for-each-in-2.js b/tests/parser/for-each-in-2.js
new file mode 100644
index 0000000..024a39d
--- /dev/null
+++ b/tests/parser/for-each-in-2.js
@@ -0,0 +1,24 @@
+/*
+enum Options:
+
+ each = 42
+
+def each(each as Object):
+ pass
+
+each = 'Test'
+
+for each in (1, 2, 3):
+ print(each)
+*/
+
+enum Options {
+ each = 42
+}
+
+function each(each: Object) {
+}
+
+var each = "Test";
+for each (var each in [1, 2, 3])
+ print(each);
\ No newline at end of file
diff --git a/tests/parser/lambdas.js b/tests/parser/lambdas.js
new file mode 100755
index 0000000..63052e2
--- /dev/null
+++ b/tests/parser/lambdas.js
@@ -0,0 +1,11 @@
+/*
+fn = { i | i * 2 }
+
+doubledEven = (1, 2, 3).Where({ i | (i % 2) == 0 }).Select({ i | i * 2 })
+
+foo({ i, j | i * j }, { i, j | i < j })
+*/
+var fn = function(i) i*2;
+var doubledEven = [1, 2, 3].Where(function(i) i%2 == 0).Select(function(i) i*2);
+foo(function(i, j) i*j, function(i, j) i < j);
+
diff --git a/tests/parser/macro-application-blocks.js b/tests/parser/macro-application-blocks.js
new file mode 100644
index 0000000..799e1a9
--- /dev/null
+++ b/tests/parser/macro-application-blocks.js
@@ -0,0 +1,26 @@
+/*
+match foo:
+ when bar:
+ return 42
+ when baz | gazonk:
+ return (-1)
+ otherwise :
+ return null
+unchecked
+*/
+match foo {
+ when bar {
+ return 42;
+ }
+ when baz | gazonk {
+ return -1;
+ }
+ otherwise {
+ return null;
+ }
+}
+
+unchecked {
+
+}
+
diff --git a/tests/parser/nested-classes.js b/tests/parser/nested-classes.js
new file mode 100644
index 0000000..630af6a
--- /dev/null
+++ b/tests/parser/nested-classes.js
@@ -0,0 +1,25 @@
+/*
+class A:
+
+ class B:
+
+ [attr]
+ public class C:
+ pass
+
+ [attr]
+ internal class D:
+ pass
+*/
+
+class A {
+
+ class B {
+ @attr
+ public class C {}
+ }
+
+ @attr
+ internal class D {
+ }
+}
\ No newline at end of file
diff --git a/tests/parser/nested-enums.js b/tests/parser/nested-enums.js
new file mode 100644
index 0000000..eb96d33
--- /dev/null
+++ b/tests/parser/nested-enums.js
@@ -0,0 +1,34 @@
+/*
+class Container:
+
+ enum E1:
+
+ Foo
+
+ Bar
+
+ public enum E2:
+
+ Foo
+
+ Bar
+
+ [flags]
+ enum E3:
+
+ Foo = 1
+
+ Bar = 2
+*/
+class Container {
+ enum E1 { Foo, Bar }
+ public enum E2 { Foo, Bar }
+
+ @flags
+ enum E3 {
+ Foo = 1,
+ Bar = 2
+ }
+
+}
+
diff --git a/tests/parser/nested-interfaces.js b/tests/parser/nested-interfaces.js
new file mode 100644
index 0000000..7bf8616
--- /dev/null
+++ b/tests/parser/nested-interfaces.js
@@ -0,0 +1,25 @@
+/*
+class A:
+
+ class B:
+
+ [attr]
+ public interface C:
+ pass
+
+ [attr]
+ internal interface D:
+ pass
+*/
+
+class A {
+
+ class B {
+ @attr
+ public interface C {}
+ }
+
+ @attr
+ internal interface D {
+ }
+}
\ No newline at end of file
diff --git a/tests/parser/plusplus-minusminus.js b/tests/parser/plusplus-minusminus.js
new file mode 100644
index 0000000..fe25cb7
--- /dev/null
+++ b/tests/parser/plusplus-minusminus.js
@@ -0,0 +1,5 @@
+/*
+value = (((((a++) + (b--)) - (c++)) + ((++d) * (-e))) + (~(--f)))
+*/
+value = a++ + b-- - c++ + ++d * -e + ~--f;
+
diff --git a/tests/parser/pragma-strict-followed-by-identifier.js b/tests/parser/pragma-strict-followed-by-identifier.js
new file mode 100644
index 0000000..6fdbb4a
--- /dev/null
+++ b/tests/parser/pragma-strict-followed-by-identifier.js
@@ -0,0 +1,6 @@
+/*
+print(Math.add(1, 1))
+*/
+#pragma strict
+
+print(Math.add(1, 1));
diff --git a/tests/parser/pragma-strict-followed-by-tab.js b/tests/parser/pragma-strict-followed-by-tab.js
new file mode 100644
index 0000000..96e4d93
--- /dev/null
+++ b/tests/parser/pragma-strict-followed-by-tab.js
@@ -0,0 +1,6 @@
+/*
+print(Math.add(1, 1))
+*/
+#pragma strict
+
+print(Math.add(1, 1));
diff --git a/tests/parser/scientific-notation.js b/tests/parser/scientific-notation.js
index a273d5c..a635475 100644
--- a/tests/parser/scientific-notation.js
+++ b/tests/parser/scientific-notation.js
@@ -2,8 +2,10 @@
f1 = 10.0F
f2 = 0.1F
f3 = 1.0F
+f4 = 0.00173F
*/
f1 = 0.1e+2;
f2 = 10e-2;
f3 = 0.0000000001e+10;
+f4 = 1.73e-3;
diff --git a/tests/parser/shift-left-bitwise-or.js b/tests/parser/shift-left-bitwise-or.js
new file mode 100644
index 0000000..a0aef34
--- /dev/null
+++ b/tests/parser/shift-left-bitwise-or.js
@@ -0,0 +1,4 @@
+/*
+value = ((1 << 9) | (1 << 8))
+*/
+value = 1<<9 | 1<<8;
diff --git a/tests/parser/strings.js b/tests/parser/strings.js
new file mode 100644
index 0000000..e7ce5eb
--- /dev/null
+++ b/tests/parser/strings.js
@@ -0,0 +1,6 @@
+/*
+s = '\'this\' is a string'
+s = 'and so is "this"'
+*/
+s = "'this' is a string";
+s = 'and so is "this"';
diff --git a/tests/parser/try-finally.js b/tests/parser/try-finally.js
new file mode 100644
index 0000000..1f983b0
--- /dev/null
+++ b/tests/parser/try-finally.js
@@ -0,0 +1,11 @@
+/*
+try:
+ raise System.ApplicationException('testing...')
+ensure:
+ print('yes...')
+*/
+try {
+ throw new System.ApplicationException("testing...");
+} finally {
+ print("yes...");
+}
diff --git a/tests/parser/typeof-1.js b/tests/parser/typeof-1.js
new file mode 100644
index 0000000..6642032
--- /dev/null
+++ b/tests/parser/typeof-1.js
@@ -0,0 +1,5 @@
+/*
+print(typeof(String).Name)
+*/
+
+print(typeof(String).Name);
\ No newline at end of file
diff --git a/tests/pragma/downcast-plus-strict-for-each-in-arrays.js b/tests/pragma/downcast-plus-strict-for-each-in-arrays.js
new file mode 100755
index 0000000..af72e7c
--- /dev/null
+++ b/tests/pragma/downcast-plus-strict-for-each-in-arrays.js
@@ -0,0 +1,19 @@
+/*
+Bar
+*/
+#pragma strict
+#pragma downcast
+
+class Foo {
+}
+
+class Bar extends Foo {
+}
+
+function useBar(bar: Bar) {
+ print(bar);
+}
+
+var array: Array = [new Bar()];
+for (var b: Bar in array)
+ useBar(b);
\ No newline at end of file
diff --git a/tests/pragma/pragma-checked-1.js b/tests/pragma/pragma-checked-1.js
new file mode 100644
index 0000000..0bfa5b6
--- /dev/null
+++ b/tests/pragma/pragma-checked-1.js
@@ -0,0 +1,12 @@
+/*
+overflow!
+*/
+#pragma checked
+
+try {
+ var mv: int = int.MaxValue;
+ var i = mv + 1;
+ print(i);
+} catch (e: System.OverflowException) {
+ print("overflow!");
+}
diff --git a/tests/integration/pragma-expando-1.js b/tests/pragma/pragma-expando-1.js
similarity index 100%
rename from tests/integration/pragma-expando-1.js
rename to tests/pragma/pragma-expando-1.js
diff --git a/tests/integration/pragma-expando-2.js b/tests/pragma/pragma-expando-2.js
similarity index 100%
rename from tests/integration/pragma-expando-2.js
rename to tests/pragma/pragma-expando-2.js
diff --git a/tests/projects/ducky-mixed-with-pragma-strict/1-ducky-operators-main.js b/tests/projects/ducky-mixed-with-pragma-strict/1-ducky-operators-main.js
new file mode 100644
index 0000000..d20f427
--- /dev/null
+++ b/tests/projects/ducky-mixed-with-pragma-strict/1-ducky-operators-main.js
@@ -0,0 +1,6 @@
+/*
+42
+*/
+#pragma strict
+
+print(Math.add(21.0, 21));
diff --git a/tests/projects/ducky-mixed-with-pragma-strict/2-ducky-operator.js b/tests/projects/ducky-mixed-with-pragma-strict/2-ducky-operator.js
new file mode 100644
index 0000000..68c61dc
--- /dev/null
+++ b/tests/projects/ducky-mixed-with-pragma-strict/2-ducky-operator.js
@@ -0,0 +1,3 @@
+static class Math {
+ function add(x, y) { return x + y; }
+}
diff --git a/tests/projects/interfaces/1-interfaces-main.js b/tests/projects/interfaces/1-interfaces-main.js
new file mode 100644
index 0000000..612c177
--- /dev/null
+++ b/tests/projects/interfaces/1-interfaces-main.js
@@ -0,0 +1,10 @@
+/*
+42
+*/
+class Impl implements Interface {
+ function get value() { return 42; }
+}
+
+function dump(itf: Interface) { print(itf.value); }
+
+dump(new Impl());
diff --git a/tests/projects/interfaces/Interface.js b/tests/projects/interfaces/Interface.js
new file mode 100644
index 0000000..e4d4765
--- /dev/null
+++ b/tests/projects/interfaces/Interface.js
@@ -0,0 +1,3 @@
+interface Interface {
+ function get value(): int;
+}
diff --git a/tests/semantics/EmptyFileBegetsEmptyBehaviour.js b/tests/semantics/EmptyFileBegetsEmptyBehaviour.js
new file mode 100644
index 0000000..be369d9
--- /dev/null
+++ b/tests/semantics/EmptyFileBegetsEmptyBehaviour.js
@@ -0,0 +1,11 @@
+/*
+import UnityScript.Tests
+
+partial public class EmptyFileBegetsEmptyBehaviour(UnityScript.Tests.MonoBehaviour):
+
+ public virtual def Awake() as void:
+ pass
+
+ public def constructor():
+ super()
+*/
\ No newline at end of file
diff --git a/tests/semantics/Magic2Class.js b/tests/semantics/Magic2Class.js
index 47ce26f..9bbfb3a 100755
--- a/tests/semantics/Magic2Class.js
+++ b/tests/semantics/Magic2Class.js
@@ -1,16 +1,19 @@
/*
import UnityScript.Tests
-partial class Magic2Class:
+partial public class Magic2Class(Object):
- public virtual def foo():
+ public virtual def foo() as void:
pass
- public virtual def bar():
+ public virtual def bar() as void:
pass
- public virtual def Awake():
+ public virtual def Awake() as void:
pass
+
+ public def constructor():
+ super()
*/
class Magic2Class
{
diff --git a/tests/semantics/MagicClass.js b/tests/semantics/MagicClass.js
index 6d31c23..333c993 100755
--- a/tests/semantics/MagicClass.js
+++ b/tests/semantics/MagicClass.js
@@ -1,20 +1,28 @@
/*
import UnityScript.Tests
-partial class MagicClass(AnotherMagicClass):
+public class AnotherMagicClass(UnityScript.Tests.MonoBehaviour):
- public virtual def foo():
- pass
+ public def constructor():
+ super()
+
+partial public class MagicClass(AnotherMagicClass):
- public virtual def bar():
+ public virtual def foo() as void:
pass
- public def constructor(value):
+ public virtual def bar() as void:
pass
- public virtual def Awake():
+ public def constructor(value as Object):
+ super()
+
+ public virtual def Awake() as void:
pass
*/
+class AnotherMagicClass extends MonoBehaviour {
+}
+
class MagicClass extends AnotherMagicClass {
function foo() {
}
diff --git a/tests/semantics/class-3.js b/tests/semantics/class-3.js
index f57d535..d5676b7 100755
--- a/tests/semantics/class-3.js
+++ b/tests/semantics/class-3.js
@@ -1,43 +1,48 @@
/*
import UnityScript.Tests
-class Person:
+public class Person(Object):
- public _name as string
+ public _name as String
private _age as int
- public def constructor(name as string, age as int):
- _name = name
- _age = age
+ public def constructor(name as String, age as int):
+ super()
+ self._name = name
+ self._age = age
- Name:
+ public Name as String:
public virtual get:
- return _name
+ return self._name
- Age:
+ public Age as int:
public virtual get:
- return _age
+ return self._age
- public virtual def ToString() as string:
- return ((_name + ', ') + _age)
+ public override def ToString() as String:
+ return Boo.Lang.Runtime.RuntimeServices.op_Addition(Boo.Lang.Runtime.RuntimeServices.op_Addition(self._name, ', '), self._age)
- public static def StaticFunction():
+ public static def StaticFunction() as void:
pass
-partial class class-3(UnityScript.Tests.MonoBehaviour):
+partial public class class-3(UnityScript.Tests.MonoBehaviour):
- public p as Person = Person('Eric Idle', 42)
+ public p as Person
- public virtual def Awake():
- print(p.ToString())
+ public virtual def Awake() as void:
+ Boo.Lang.Builtins.print(self.p.ToString())
+
+ public def constructor():
+ super()
+ self.p = Person('Eric Idle', 42)
*/
class Person {
- var _name:string;
+ var _name:String;
private var _age:int;
- function Person(name:string, age:int) {
+ function Person(name:String, age:int) {
_name = name;
_age = age;
}
@@ -50,7 +55,7 @@ class Person {
return _age;
}
- function ToString() : string {
+ function ToString() : String {
return _name + ", " + _age;
}
diff --git a/tests/semantics/coroutine.js b/tests/semantics/coroutine.js
old mode 100755
new mode 100644
index d323879..219d24e
--- a/tests/semantics/coroutine.js
+++ b/tests/semantics/coroutine.js
@@ -1,28 +1,56 @@
/*
import UnityScript.Tests
-partial class coroutine(UnityScript.Tests.MonoBehaviour):
-
- private def spam():
- yield
- yield 0
- yield 1
- yield 2
-
- public virtual def Awake():
- enumerate = spam()
- for e in enumerate:
- print(e)
+partial public class coroutine(UnityScript.Tests.MonoBehaviour):
+
+ private def spam() as System.Collections.IEnumerator:
+ return coroutine.$spam$2().GetEnumerator()
+
+ public virtual def Awake() as void:
+ enumerate = self.StartCoroutine_Auto(self.spam())
+ $iterator$1 = UnityScript.Lang.UnityRuntimeServices.GetEnumerator(enumerate)
+ while $iterator$1.MoveNext():
+ e = $iterator$1.get_Current()
+ Boo.Lang.Builtins.print(e)
+ UnityScript.Lang.UnityRuntimeServices.Update($iterator$1, e)
+
+ public def constructor():
+ super()
+
+ [System.Runtime.CompilerServices.CompilerGeneratedAttribute]
+ internal final class $spam$2(Boo.Lang.GenericGenerator[of int]):
+
+ public virtual def GetEnumerator() as System.Collections.Generic.IEnumerator[of int]:
+ return coroutine.$spam$2.$()
+
+ public def constructor():
+ super()
+
+ [System.Runtime.CompilerServices.CompilerGeneratedAttribute]
+ internal final class $(Boo.Lang.GenericGeneratorEnumerator[of int], System.Collections.IEnumerator):
+
+ public def constructor():
+ super()
+
+ public virtual def MoveNext() as boolean:
+ __switch__(self._state, $state$0, $state$1, $state$2, $state$3)
+ :$state$0
+ return self.YieldDefault(2)
+ :$state$2
+ return self.Yield(3, 42)
+ :$state$3
+ self.YieldDefault(1)
+ :$state$1
+
+
*/
private function spam()
{
- // Allow for this shorthand form of yield.
- // It should yield 0
+ // shorthand form of yield.
+ // same as yield 0 in this case
yield;
- yield 0;
- yield 1;
- yield 2;
+ yield 42;
}
enumerate = spam();
diff --git a/tests/semantics/fields-1.js b/tests/semantics/fields-1.js
index 41cb3f8..528770b 100644
--- a/tests/semantics/fields-1.js
+++ b/tests/semantics/fields-1.js
@@ -1,18 +1,16 @@
/*
import UnityScript.Tests
-class Fields:
+public class Fields(Object):
- public FirstName as string
+ public FirstName as String
- public LastName as string
+ public LastName as String
-partial class fields-1(UnityScript.Tests.MonoBehaviour):
-
- public virtual def Awake():
- pass
+ public def constructor():
+ super()
*/
class Fields {
- var FirstName:string;
- var LastName:string;
+ var FirstName:String;
+ var LastName:String;
}
diff --git a/tests/semantics/functions-2.js b/tests/semantics/functions-2.js
index 2a864d5..39e51d5 100755
--- a/tests/semantics/functions-2.js
+++ b/tests/semantics/functions-2.js
@@ -1,18 +1,22 @@
/*
import UnityScript.Tests
-partial class functions-2(UnityScript.Tests.MonoBehaviour):
+partial public class functions-2(UnityScript.Tests.MonoBehaviour):
- public value = 1
+ public value as int
- private def spam(thirdValue):
- return ((value + 2) + thirdValue)
+ private def spam(thirdValue as Object) as System.Object:
+ return Boo.Lang.Runtime.RuntimeServices.InvokeBinaryOperator('op_Addition', (self.value + 2), thirdValue)
- private def eggs():
- print(spam(3))
+ private def eggs() as void:
+ Boo.Lang.Builtins.print(self.spam(3))
- public virtual def Awake():
- eggs()
+ public virtual def Awake() as void:
+ self.eggs()
+
+ public def constructor():
+ super()
+ self.value = 1
*/
var value = 1;
diff --git a/tests/semantics/magic-members.js b/tests/semantics/magic-members.js
index 0671b02..74bcdad 100755
--- a/tests/semantics/magic-members.js
+++ b/tests/semantics/magic-members.js
@@ -1,17 +1,21 @@
/*
import UnityScript.Tests
-partial class magic-members(UnityScript.Tests.MonoBehaviour):
+partial public class magic-members(UnityScript.Tests.MonoBehaviour):
- public value = 5
+ public value as int
- public virtual def Awake():
+ public virtual def Awake() as void:
if 1:
otherValue1 = 7
else:
otherValue2 = 7
while 0:
otherValue3 = 7
+
+ public def constructor():
+ super()
+ self.value = 5
*/
// When a variable declaration is inside of a block it shouldnt become a member variable
diff --git a/tests/semantics/single-update-function.js b/tests/semantics/single-update-function.js
index 1f95365..d8986c8 100755
--- a/tests/semantics/single-update-function.js
+++ b/tests/semantics/single-update-function.js
@@ -1,12 +1,16 @@
/*
import UnityScript.Tests
-partial class single-update-function(UnityScript.Tests.MonoBehaviour):
+partial public class single-update-function(UnityScript.Tests.MonoBehaviour):
- public virtual def Update():
+ public virtual def Update() as void:
pass
- public virtual def Awake():
+ public virtual def Awake() as void:
pass
+
+ public def constructor():
+ super()
+
*/
function Update() {}
diff --git a/tests/semantics/variables.js b/tests/semantics/variables.js
index 5bb9329..286cc0a 100644
--- a/tests/semantics/variables.js
+++ b/tests/semantics/variables.js
@@ -1,12 +1,16 @@
/*
import UnityScript.Tests
-partial class variables(UnityScript.Tests.MonoBehaviour):
+partial public class variables(UnityScript.Tests.MonoBehaviour):
- public value = 5
+ public value as int
- public virtual def Awake():
+ public virtual def Awake() as void:
otherValue = 7
+
+ public def constructor():
+ super()
+ self.value = 5
*/
var value = 5;
diff --git a/tests/stacktrace/stacktrace-2.js b/tests/stacktrace/stacktrace-2.js
old mode 100644
new mode 100755
index 81f81c1..30dc6f4
--- a/tests/stacktrace/stacktrace-2.js
+++ b/tests/stacktrace/stacktrace-2.js
@@ -1,6 +1,7 @@
+// category FailsOnMono
/*
-stacktrace-2.js:16
-stacktrace-2.js:9
+stacktrace-2.js:17
+stacktrace-2.js:10
*/
import UnityScript.Tests;
import System.Runtime.CompilerServices;
diff --git a/tests/us/eval-can-be-disabled.js b/tests/us/eval-can-be-disabled.js
new file mode 100644
index 0000000..8bdc8b2
--- /dev/null
+++ b/tests/us/eval-can-be-disabled.js
@@ -0,0 +1,2 @@
+
+ eval("42");
diff --git a/todo.txt b/todo.txt
index f7bf8a7..9f1570c 100644
--- a/todo.txt
+++ b/todo.txt
@@ -1,12 +1,10 @@
-*** Eval ***
+* unchecked expression support: unchecked(1 << 31)
+* pragma unchecked to enable unchecked arithmetic for the whole module
-*) current imports should be effective inside eval code
-*) cache eval assemblies used in static methods
-*) for-loop variables should be visible to eval
-*) propagate strict mode?
+* current imports should be effective inside eval code
+* cache eval assemblies used in static methods
+* for-loop variables should be visible to eval
+* propagate strict mode to eval?
-************
-print usage information for bin/us
-
-->* lexical scopes for 'for' statements
+* lexical scopes for 'for' statements