Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of github.com:bamboo/unityscript

  • Loading branch information...
commit 89c6eb63b0af94dd4f69cc5f3f8eec77fc619d08 2 parents 3feb661 + d1e745c
@bamboo bamboo authored
View
2  refresh-tests.boo
@@ -54,7 +54,7 @@ Normalize string.
def GenerateTestFixtureSource(
header as string,
- srcDirs as (string),
+ srcDirs as string*,
testCaseProducer as callable(string) as string*,
categoryProducer as callable(string) as string):
View
4 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 {
View
4 src/UnityScript.Tests/DuckyIntegrationTestFixture.boo
@@ -394,6 +394,10 @@ class DuckyIntegrationTestFixture(AbstractIntegrationTestFixture):
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")
View
8 src/UnityScript.Tests/ErrorMessagesTestFixture.Generated.boo
@@ -54,6 +54,10 @@ partial class ErrorMessagesTestFixture:
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")
@@ -90,6 +94,10 @@ partial class ErrorMessagesTestFixture:
RunTestCase("tests/error-messages/iterator-warning.js")
+ [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")
View
4 src/UnityScript.Tests/ProjectIntegrationTestFixture.Generated.boo
@@ -8,4 +8,8 @@ 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")
View
4 src/UnityScript.Tests/StrictIntegrationTestFixture.Generated.boo
@@ -392,6 +392,10 @@ partial class StrictIntegrationTestFixture(AbstractIntegrationTestFixture):
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")
View
126 src/UnityScript/Parser/UnityScriptLexer.boo
@@ -594,8 +594,8 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
): // 1827
mDIGIT(false)
else: // line 1969
- goto _loop317_breakloop
- :_loop317_breakloop
+ goto _loop318_breakloop
+ :_loop318_breakloop
_ttype = testLiteralsTable(_ttype)
if (_createToken and (_token is null) and (_ttype != Token.SKIP)):
_token = makeToken(_ttype)
@@ -688,17 +688,17 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
if ((cached_LA1==char('0')) and (cached_LA2==char('x'))):
match("0x")
- _cnt321 as int = 0
+ _cnt322 as int = 0
while true:
if ((tokenSet_0_.member(cast(int, cached_LA1)))):
mHEXDIGIT(false)
else:
- if (_cnt321 >= 1):
- goto _loop321_breakloop
+ if (_cnt322 >= 1):
+ goto _loop322_breakloop
else:
raise NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn())
- ++_cnt321
- :_loop321_breakloop
+ ++_cnt322
+ :_loop322_breakloop
if ((cached_LA1==char('L') or cached_LA1==char('l'))):
_givenValue = cached_LA1
if ((_givenValue == char('l'))): // 1831
@@ -712,17 +712,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
- _cnt325 as int = 0
+ _cnt326 as int = 0
while true:
if ((((cached_LA1 >= char('0')) and (cached_LA1 <= char('9'))))):
mDIGIT(false)
else:
- if (_cnt325 >= 1):
- goto _loop325_breakloop
+ if (_cnt326 >= 1):
+ goto _loop326_breakloop
else:
raise NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn())
- ++_cnt325
- :_loop325_breakloop
+ ++_cnt326
+ :_loop326_breakloop
_givenValue = cached_LA1
if ((_givenValue == char('L'))
or (_givenValue ==char('l'))
@@ -818,17 +818,17 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
_ttype as int; _token as IToken; _begin = text.Length;
_ttype = DOUBLE_SUFFIX
- _cnt334 as int = 0
+ _cnt335 as int = 0
while true:
if ((((cached_LA1 >= char('0')) and (cached_LA1 <= char('9'))))):
mDIGIT(false)
else:
- if (_cnt334 >= 1):
- goto _loop334_breakloop
+ if (_cnt335 >= 1):
+ goto _loop335_breakloop
else:
raise NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn())
- ++_cnt334
- :_loop334_breakloop
+ ++_cnt335
+ :_loop335_breakloop
if ((cached_LA1==char('E') or cached_LA1==char('e'))):
mEXPONENT(false)
else: // line 2053
@@ -879,17 +879,17 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
pass // 947
else: // line 1969
raise NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn())
- _cnt341 as int = 0
+ _cnt342 as int = 0
while true:
if ((((cached_LA1 >= char('0')) and (cached_LA1 <= char('9'))))):
mDIGIT(false)
else:
- if (_cnt341 >= 1):
- goto _loop341_breakloop
+ if (_cnt342 >= 1):
+ goto _loop342_breakloop
else:
raise NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn())
- ++_cnt341
- :_loop341_breakloop
+ ++_cnt342
+ :_loop342_breakloop
if (_createToken and (_token is null) and (_ttype != Token.SKIP)):
_token = makeToken(_ttype)
_token.setText(text.ToString(_begin, text.Length-_begin))
@@ -1129,31 +1129,31 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
_saveIndex = text.Length
match("#pragma")
text.Length = _saveIndex
- _cnt365 as int = 0
+ _cnt366 as int = 0
while true:
if ((cached_LA1==char('\t') or cached_LA1==char(' '))):
mPRAGMA_WHITE_SPACE(false)
else:
- if (_cnt365 >= 1):
- goto _loop365_breakloop
+ if (_cnt366 >= 1):
+ goto _loop366_breakloop
else:
raise NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn())
- ++_cnt365
- :_loop365_breakloop
+ ++_cnt366
+ :_loop366_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'))):
- _cnt368 as int = 0
+ _cnt369 as int = 0
while true:
if ((cached_LA1==char('\t') or cached_LA1==char(' '))):
mPRAGMA_WHITE_SPACE(false)
else:
- if (_cnt368 >= 1):
- goto _loop368_breakloop
+ if (_cnt369 >= 1):
+ goto _loop369_breakloop
else:
raise NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn())
- ++_cnt368
- :_loop368_breakloop
+ ++_cnt369
+ :_loop369_breakloop
if ((cached_LA1==char('o')) and (cached_LA2==char('f'))):
_saveIndex = text.Length
match("off")
@@ -1174,8 +1174,8 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
if ((cached_LA1==char('\t') or cached_LA1==char(' '))):
mPRAGMA_WHITE_SPACE(false)
else:
- goto _loop371_breakloop
- :_loop371_breakloop
+ goto _loop372_breakloop
+ :_loop372_breakloop
_saveIndex = text.Length
mNEWLINE(false)
text.Length = _saveIndex
@@ -1450,18 +1450,18 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
_ttype as int; _token as IToken; _begin = text.Length;
_ttype = DIVISION
- synPredMatched398 as bool = false
+ synPredMatched399 as bool = false
if ((cached_LA1==char('/')) and (cached_LA2==char('*'))):
- _m398 as int = mark()
- synPredMatched398 = true
+ _m399 as int = mark()
+ synPredMatched399 = true
++inputState.guessing
try:
match("/*")
except x as RecognitionException:
- synPredMatched398 = false
- rewind(_m398)
+ synPredMatched399 = false
+ rewind(_m399)
--inputState.guessing
- if synPredMatched398:
+ if synPredMatched399:
mML_COMMENT(false)
if 0 == inputState.guessing:
if not PreserveComments:
@@ -1475,8 +1475,8 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
if ((tokenSet_1_.member(cast(int, cached_LA1)))):
match(tokenSet_1_)
else:
- goto _loop403_breakloop
- :_loop403_breakloop
+ goto _loop404_breakloop
+ :_loop404_breakloop
if 0 == inputState.guessing:
if PreserveComments:
_ttype = SL_COMMENT
@@ -1508,8 +1508,8 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
elif ((tokenSet_2_.member(cast(int, cached_LA1)))): // line 2102
match(tokenSet_2_)
else:
- goto _loop432_breakloop
- :_loop432_breakloop
+ goto _loop433_breakloop
+ :_loop433_breakloop
match("*/")
if (_createToken and (_token is null) and (_ttype != Token.SKIP)):
_token = makeToken(_ttype)
@@ -1520,7 +1520,7 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
_ttype as int; _token as IToken; _begin = text.Length;
_ttype = WHITE_SPACE
- _cnt407 as int = 0
+ _cnt408 as int = 0
while true:
_givenValue = cached_LA1
if ((_givenValue == char(' '))): // 1831
@@ -1534,12 +1534,12 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
): // 1827
mNEWLINE(false)
else: // line 1969
- if (_cnt407 >= 1):
- goto _loop407_breakloop
+ if (_cnt408 >= 1):
+ goto _loop408_breakloop
else:
raise NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn())
- ++_cnt407
- :_loop407_breakloop
+ ++_cnt408
+ :_loop408_breakloop
if 0 == inputState.guessing:
_ttype = Token.SKIP;
if (_createToken and (_token is null) and (_ttype != Token.SKIP)):
@@ -1560,8 +1560,8 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
elif ((tokenSet_3_.member(cast(int, cached_LA1)))): // line 2102
match(tokenSet_3_)
else:
- goto _loop411_breakloop
- :_loop411_breakloop
+ goto _loop412_breakloop
+ :_loop412_breakloop
_saveIndex = text.Length
match('"')
text.Length = _saveIndex
@@ -1610,8 +1610,8 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
elif ((tokenSet_4_.member(cast(int, cached_LA1)))): // line 2102
match(tokenSet_4_)
else:
- goto _loop415_breakloop
- :_loop415_breakloop
+ goto _loop416_breakloop
+ :_loop416_breakloop
_saveIndex = text.Length
match('\'')
text.Length = _saveIndex
@@ -1712,17 +1712,17 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
_ttype = RE_LITERAL
match('/')
- _cnt435 as int = 0
+ _cnt436 as int = 0
while true:
if ((tokenSet_5_.member(cast(int, cached_LA1)))):
mRE_CHAR(false)
else:
- if (_cnt435 >= 1):
- goto _loop435_breakloop
+ if (_cnt436 >= 1):
+ goto _loop436_breakloop
else:
raise NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn())
- ++_cnt435
- :_loop435_breakloop
+ ++_cnt436
+ :_loop436_breakloop
match('/')
if (_createToken and (_token is null) and (_ttype != Token.SKIP)):
_token = makeToken(_ttype)
@@ -1780,17 +1780,17 @@ class UnityScriptLexer(antlr.CharScanner, TokenStream):
or (_givenValue ==char('8'))
or (_givenValue ==char('9'))
): // 1827
- _cnt441 as int = 0
+ _cnt442 as int = 0
while 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 (_cnt441 >= 1):
- goto _loop441_breakloop
+ if (_cnt442 >= 1):
+ goto _loop442_breakloop
else:
raise NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn())
- ++_cnt441
- :_loop441_breakloop
+ ++_cnt442
+ :_loop442_breakloop
elif ((_givenValue == char('x'))): // 1831
match('x')
mDIGIT(false)
View
391 src/UnityScript/Parser/UnityScriptParser.boo
@@ -195,9 +195,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)
@@ -205,6 +202,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 ToLexicalInfo(token as antlr.IToken):
+ return LexicalInfo(token.getFilename(), token.getLine(), token.getColumn())
static def ParseIntegerLiteralExpression(token as antlr.IToken,
s as string,
@@ -253,7 +253,42 @@ class UnityScriptParser(antlr.LLkParser):
static def CreateModuleName(fname as string):
return System.IO.Path.GetFileNameWithoutExtension(fname)
-
+
+ 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 name == type.Name 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
+
+ def ValidateFunctionDeclaration(function as Method, getter as IToken, setter as IToken):
+ // 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 function.Parameters.Count != 1 or function.Parameters[0].Name != "value":
+ ReportError(UnityScriptCompilerErrors.InvalidPropertySetter(function.LexicalInfo))
+ function.Parameters.Clear()
+ return
+ if getter is not null:
+ if function.Parameters.Count > 0:
+ ReportError(UnityScriptCompilerErrors.InvalidPropertySetter(function.LexicalInfo))
protected def initialize():
tokenNames = tokenNames_
@@ -610,17 +645,17 @@ class UnityScriptParser(antlr.LLkParser):
raise NoViableAltException(LT(1), getFilename())
eos()
elif ((_givenValue == EOS)): // 1831
- _cnt111 as int = 0
+ _cnt112 as int = 0
while true:
if ((LA(1)==EOS) and (tokenSet_12_.member(cast(int, LA(2))))):
match(EOS)
else:
- if (_cnt111 >= 1):
- goto _loop111_breakloop
+ if (_cnt112 >= 1):
+ goto _loop112_breakloop
else:
raise NoViableAltException(LT(1), getFilename())
- ++_cnt111
- :_loop111_breakloop
+ ++_cnt112
+ :_loop112_breakloop
else: // line 1969
raise NoViableAltException(LT(1), getFilename())
except ex as RecognitionException:
@@ -678,8 +713,8 @@ class UnityScriptParser(antlr.LLkParser):
match(DOT)
e=member_reference_expression(e)
else:
- goto _loop197_breakloop
- :_loop197_breakloop
+ goto _loop198_breakloop
+ :_loop198_breakloop
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
@@ -1199,8 +1234,8 @@ class UnityScriptParser(antlr.LLkParser):
match(COMMA)
enum_member(ed)
else:
- goto _loop76_breakloop
- :_loop76_breakloop
+ goto _loop77_breakloop
+ :_loop77_breakloop
_givenValue = LA(1)
if ((_givenValue == COMMA)): // 1831
match(COMMA)
@@ -1220,8 +1255,8 @@ class UnityScriptParser(antlr.LLkParser):
if ((LA(1)==EOS) and (tokenSet_30_.member(cast(int, LA(2))))):
match(EOS)
else:
- goto _loop79_breakloop
- :_loop79_breakloop
+ goto _loop80_breakloop
+ :_loop80_breakloop
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
@@ -1518,8 +1553,8 @@ class UnityScriptParser(antlr.LLkParser):
if 0 == inputState.guessing:
++rank
else:
- goto _loop166_breakloop
- :_loop166_breakloop
+ goto _loop167_breakloop
+ :_loop167_breakloop
match(RBRACK)
if 0 == inputState.guessing:
tr = ArrayTypeReference(tr.LexicalInfo, tr, IntegerLiteralExpression(ToLexicalInfo(lbrack), rank))
@@ -1551,8 +1586,8 @@ class UnityScriptParser(antlr.LLkParser):
if 0 == inputState.guessing:
typeReferences.Add(tr)
else:
- goto _loop182_breakloop
- :_loop182_breakloop
+ goto _loop183_breakloop
+ :_loop183_breakloop
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
@@ -1586,36 +1621,10 @@ class UnityScriptParser(antlr.LLkParser):
raise NoViableAltException(LT(1), getFilename())
memberName=identifier()
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)
+ member = function = AddFunctionTo(cd, memberName, getter, setter)
+ function_body(function)
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)))
+ ValidateFunctionDeclaration(function, getter, setter)
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
@@ -1628,16 +1637,28 @@ class UnityScriptParser(antlr.LLkParser):
parent as TypeDefinition
) as void: //throws RecognitionException, TokenStreamException
- name as IToken = null
+ getter as IToken = null
+ setter as IToken = null
try: // for error handling
match(FUNCTION)
- name = LT(1)
- match(ID)
+ _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 ==INTERNAL)
+ or (_givenValue ==ID)
+ ): // 1827
+ pass // 947
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
+ memberName=identifier()
if 0 == inputState.guessing:
- method = Method(ToLexicalInfo(name), Name: name.getText())
- FlushAttributes(method)
- parent.Members.Add(method)
+ function = AddFunctionTo(parent, memberName, getter, setter)
match(LPAREN)
_givenValue = LA(1)
if ((_givenValue == FINAL)
@@ -1645,18 +1666,20 @@ class UnityScriptParser(antlr.LLkParser):
or (_givenValue ==ID)
or (_givenValue ==AT)
): // 1827
- parameter_declaration_list(method)
+ parameter_declaration_list(function)
elif ((_givenValue == RPAREN)): // 1831
pass // 947
else: // line 1969
raise NoViableAltException(LT(1), getFilename())
match(RPAREN)
+ if 0 == inputState.guessing:
+ ValidateFunctionDeclaration(function, getter, setter)
_givenValue = LA(1)
if ((_givenValue == COLON)): // 1831
match(COLON)
tr=type_reference()
if 0 == inputState.guessing:
- method.ReturnType = tr;
+ function.ReturnType = tr;
elif ((_givenValue == FUNCTION)
or (_givenValue ==RBRACE)
or (_givenValue ==EOS)
@@ -1669,8 +1692,8 @@ class UnityScriptParser(antlr.LLkParser):
if ((LA(1)==EOS)):
match(EOS)
else:
- goto _loop72_breakloop
- :_loop72_breakloop
+ goto _loop73_breakloop
+ :_loop73_breakloop
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
@@ -1678,6 +1701,40 @@ class UnityScriptParser(antlr.LLkParser):
else:
raise
+ 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
+
+ try: // for error handling
+ _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);
+ else: // line 1969
+ raise NoViableAltException(LT(1), getFilename())
+ except ex as RecognitionException:
+ if (0 == inputState.guessing):
+ reportError(ex)
+ recover(ex,tokenSet_36_)
+ else:
+ raise
+ return token
+
public def parameter_declaration_list(
m as INodeWithParameters
) as void: //throws RecognitionException, TokenStreamException
@@ -1690,12 +1747,12 @@ class UnityScriptParser(antlr.LLkParser):
match(COMMA)
parameter_declaration(m)
else:
- goto _loop94_breakloop
- :_loop94_breakloop
+ goto _loop95_breakloop
+ :_loop95_breakloop
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_36_)
+ recover(ex,tokenSet_37_)
else:
raise
@@ -1732,7 +1789,7 @@ class UnityScriptParser(antlr.LLkParser):
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_37_)
+ recover(ex,tokenSet_38_)
else:
raise
@@ -1765,40 +1822,6 @@ class UnityScriptParser(antlr.LLkParser):
raise
return e
- 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
-
- try: // for error handling
- _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);
- else: // line 1969
- raise NoViableAltException(LT(1), getFilename())
- except ex as RecognitionException:
- if (0 == inputState.guessing):
- reportError(ex)
- recover(ex,tokenSet_38_)
- else:
- raise
- return token
-
public def compound_statement(
b as Block
) as void: //throws RecognitionException, TokenStreamException
@@ -1810,8 +1833,8 @@ class UnityScriptParser(antlr.LLkParser):
if ((LA(1)==EOS) and (tokenSet_39_.member(cast(int, LA(2))))):
match(EOS)
else:
- goto _loop101_breakloop
- :_loop101_breakloop
+ goto _loop102_breakloop
+ :_loop102_breakloop
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
@@ -1888,8 +1911,8 @@ class UnityScriptParser(antlr.LLkParser):
if ((tokenSet_2_.member(cast(int, LA(1))))):
statement(b)
else:
- goto _loop104_breakloop
- :_loop104_breakloop
+ goto _loop105_breakloop
+ :_loop105_breakloop
rbrace = LT(1)
match(RBRACE)
if 0 == inputState.guessing:
@@ -1966,10 +1989,10 @@ class UnityScriptParser(antlr.LLkParser):
f = LT(1)
match(FOR)
match(LPAREN)
- synPredMatched127 as bool = false
+ synPredMatched128 as bool = false
if ((tokenSet_42_.member(cast(int, LA(1)))) and (tokenSet_43_.member(cast(int, LA(2))))):
- _m127 as int = mark()
- synPredMatched127 = true
+ _m128 as int = mark()
+ synPredMatched128 = true
++inputState.guessing
try:
_givenValue = LA(1)
@@ -1984,10 +2007,10 @@ class UnityScriptParser(antlr.LLkParser):
raise NoViableAltException(LT(1), getFilename())
match(IN)
except x as RecognitionException:
- synPredMatched127 = false
- rewind(_m127)
+ synPredMatched128 = false
+ rewind(_m128)
--inputState.guessing
- if synPredMatched127:
+ if synPredMatched128:
stmt=for_in(container)
elif ((tokenSet_44_.member(cast(int, LA(1)))) and (tokenSet_45_.member(cast(int, LA(2))))): // line 2102
stmt=for_c(container)
@@ -2077,8 +2100,8 @@ class UnityScriptParser(antlr.LLkParser):
tr = null
compound_or_single_stmt(b)
else:
- goto _loop154_breakloop
- :_loop154_breakloop
+ goto _loop155_breakloop
+ :_loop155_breakloop
if ((LA(1)==FINALLY) and (tokenSet_2_.member(cast(int, LA(2))))):
finally_block(s)
elif ((tokenSet_12_.member(cast(int, LA(1)))) and (tokenSet_17_.member(cast(int, LA(2))))): // line 2102
@@ -2131,22 +2154,22 @@ class UnityScriptParser(antlr.LLkParser):
if 0 == inputState.guessing:
item.Arguments.Add(e);
else:
- goto _loop142_breakloop
- :_loop142_breakloop
- _cnt144 as int = 0
+ goto _loop143_breakloop
+ :_loop143_breakloop
+ _cnt145 as int = 0
while true:
if ((tokenSet_2_.member(cast(int, LA(1))))):
statement(itemBlock)
else:
- if (_cnt144 >= 1):
- goto _loop144_breakloop
+ if (_cnt145 >= 1):
+ goto _loop145_breakloop
else:
raise NoViableAltException(LT(1), getFilename())
- ++_cnt144
- :_loop144_breakloop
+ ++_cnt145
+ :_loop145_breakloop
else:
- goto _loop145_breakloop
- :_loop145_breakloop
+ goto _loop146_breakloop
+ :_loop146_breakloop
_givenValue = LA(1)
if ((_givenValue == DEFAULT)): // 1831
d = LT(1)
@@ -2156,17 +2179,17 @@ class UnityScriptParser(antlr.LLkParser):
item = MacroStatement(ToLexicalInfo(d), Name: d.getText())
itemBlock = item.Body
switchBlock.Add(item)
- _cnt148 as int = 0
+ _cnt149 as int = 0
while true:
if ((tokenSet_2_.member(cast(int, LA(1))))):
statement(itemBlock)
else:
- if (_cnt148 >= 1):
- goto _loop148_breakloop
+ if (_cnt149 >= 1):
+ goto _loop149_breakloop
else:
raise NoViableAltException(LT(1), getFilename())
- ++_cnt148
- :_loop148_breakloop
+ ++_cnt149
+ :_loop149_breakloop
elif ((_givenValue == RBRACE)): // 1831
pass // 947
else: // line 1969
@@ -2176,8 +2199,8 @@ class UnityScriptParser(antlr.LLkParser):
if ((LA(1)==EOS) and (tokenSet_12_.member(cast(int, LA(2))))):
match(EOS)
else:
- goto _loop150_breakloop
- :_loop150_breakloop
+ goto _loop151_breakloop
+ :_loop151_breakloop
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
@@ -2899,8 +2922,8 @@ class UnityScriptParser(antlr.LLkParser):
if 0 == inputState.guessing:
parameters.Add(ParameterDeclaration(Type: parameterType, Name: "arg" + len(parameters)))
else:
- goto _loop172_breakloop
- :_loop172_breakloop
+ goto _loop173_breakloop
+ :_loop173_breakloop
elif ((_givenValue == RPAREN)): // 1831
pass // 947
else: // line 1969
@@ -2931,8 +2954,8 @@ class UnityScriptParser(antlr.LLkParser):
if 0 == inputState.guessing:
dimensions.Add(size)
else:
- goto _loop175_breakloop
- :_loop175_breakloop
+ goto _loop176_breakloop
+ :_loop176_breakloop
match(RBRACK)
if 0 == inputState.guessing:
e = CodeFactory.NewArrayInitializer(tr.LexicalInfo, tr, dimensions)
@@ -2976,8 +2999,8 @@ class UnityScriptParser(antlr.LLkParser):
be.Right = r
e = be
else:
- goto _loop249_breakloop
- :_loop249_breakloop
+ goto _loop250_breakloop
+ :_loop250_breakloop
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
@@ -3006,18 +3029,18 @@ class UnityScriptParser(antlr.LLkParser):
try: // for error handling
- synPredMatched186 as bool = false
+ synPredMatched187 as bool = false
if ((LA(1)==NEW) and (LA(2)==ID)):
- _m186 as int = mark()
- synPredMatched186 = true
+ _m187 as int = mark()
+ synPredMatched187 = true
++inputState.guessing
try:
new_array_expression()
except x as RecognitionException:
- synPredMatched186 = false
- rewind(_m186)
+ synPredMatched187 = false
+ rewind(_m187)
--inputState.guessing
- if synPredMatched186:
+ if synPredMatched187:
e=new_array_expression()
elif ((LA(1)==NEW) and (LA(2)==ID)): // line 2102
match(NEW)
@@ -3079,8 +3102,8 @@ class UnityScriptParser(antlr.LLkParser):
if 0 == inputState.guessing:
ec.Add(e);
else:
- goto _loop215_breakloop
- :_loop215_breakloop
+ goto _loop216_breakloop
+ :_loop216_breakloop
elif ((_givenValue == RPAREN)
or (_givenValue ==RBRACK)
): // 1827
@@ -3274,10 +3297,10 @@ class UnityScriptParser(antlr.LLkParser):
try: // for error handling
- synPredMatched204 as bool = false
+ synPredMatched205 as bool = false
if ((LA(1)==TYPEOF) and (tokenSet_13_.member(cast(int, LA(2))))):
- _m204 as int = mark()
- synPredMatched204 = true
+ _m205 as int = mark()
+ synPredMatched205 = true
++inputState.guessing
try:
match(TYPEOF)
@@ -3285,10 +3308,10 @@ class UnityScriptParser(antlr.LLkParser):
expression()
match(RPAREN)
except x as RecognitionException:
- synPredMatched204 = false
- rewind(_m204)
+ synPredMatched205 = false
+ rewind(_m205)
--inputState.guessing
- if synPredMatched204:
+ if synPredMatched205:
e=typeof_with_expression()
elif ((LA(1)==TYPEOF) and (tokenSet_13_.member(cast(int, LA(2))))): // line 2102
e=typeof_expression_alt()
@@ -3371,10 +3394,10 @@ class UnityScriptParser(antlr.LLkParser):
try: // for error handling
- synPredMatched207 as bool = false
+ synPredMatched208 as bool = false
if ((LA(1)==TYPEOF) and (LA(2)==LPAREN)):
- _m207 as int = mark()
- synPredMatched207 = true
+ _m208 as int = mark()
+ synPredMatched208 = true
++inputState.guessing
try:
match(TYPEOF)
@@ -3382,10 +3405,10 @@ class UnityScriptParser(antlr.LLkParser):
type_reference()
match(RPAREN)
except x as RecognitionException:
- synPredMatched207 = false
- rewind(_m207)
+ synPredMatched208 = false
+ rewind(_m208)
--inputState.guessing
- if synPredMatched207:
+ if synPredMatched208:
e=typeof_with_typeref()
elif ((LA(1)==TYPEOF) and (tokenSet_13_.member(cast(int, LA(2))))): // line 2102
e=typeof_with_expression()
@@ -3585,8 +3608,8 @@ class UnityScriptParser(antlr.LLkParser):
match(COMMA)
slice(se)
else:
- goto _loop231_breakloop
- :_loop231_breakloop
+ goto _loop232_breakloop
+ :_loop232_breakloop
match(RBRACK)
elif ((LA(1)==DOT) and (tokenSet_52_.member(cast(int, LA(2))))): // line 2102
match(DOT)
@@ -3602,8 +3625,8 @@ class UnityScriptParser(antlr.LLkParser):
expression_list(args)
match(RPAREN)
else:
- goto _loop234_breakloop
- :_loop234_breakloop
+ goto _loop235_breakloop
+ :_loop235_breakloop
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
@@ -3793,8 +3816,8 @@ class UnityScriptParser(antlr.LLkParser):
be.Right = r
e = be
else:
- goto _loop245_breakloop
- :_loop245_breakloop
+ goto _loop246_breakloop
+ :_loop246_breakloop
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
@@ -3830,8 +3853,8 @@ class UnityScriptParser(antlr.LLkParser):
if 0 == inputState.guessing:
e = BinaryExpression(ToLexicalInfo(token), Operator: op, Left: e, Right: r)
else:
- goto _loop253_breakloop
- :_loop253_breakloop
+ goto _loop254_breakloop
+ :_loop254_breakloop
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
@@ -3910,8 +3933,8 @@ class UnityScriptParser(antlr.LLkParser):
be.Right = r
e = be
else:
- goto _loop265_breakloop
- :_loop265_breakloop
+ goto _loop266_breakloop
+ :_loop266_breakloop
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
@@ -3959,8 +3982,8 @@ class UnityScriptParser(antlr.LLkParser):
if 0 == inputState.guessing:
e = BinaryExpression(ToLexicalInfo(token), op, e, r)
else:
- goto _loop273_breakloop
- :_loop273_breakloop
+ goto _loop274_breakloop
+ :_loop274_breakloop
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
@@ -3986,8 +4009,8 @@ class UnityScriptParser(antlr.LLkParser):
if 0 == inputState.guessing:
e = BinaryExpression(ToLexicalInfo(token), Operator: op, Left: e, Right: r)
else:
- goto _loop276_breakloop
- :_loop276_breakloop
+ goto _loop277_breakloop
+ :_loop277_breakloop
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
@@ -4013,8 +4036,8 @@ class UnityScriptParser(antlr.LLkParser):
if 0 == inputState.guessing:
e = BinaryExpression(ToLexicalInfo(token), Operator: op, Left: e, Right: r)
else:
- goto _loop279_breakloop
- :_loop279_breakloop
+ goto _loop280_breakloop
+ :_loop280_breakloop
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
@@ -4040,8 +4063,8 @@ class UnityScriptParser(antlr.LLkParser):
if 0 == inputState.guessing:
e = BinaryExpression(ToLexicalInfo(token), Operator: op, Left: e, Right: r)
else:
- goto _loop282_breakloop
- :_loop282_breakloop
+ goto _loop283_breakloop
+ :_loop283_breakloop
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
@@ -4068,8 +4091,8 @@ class UnityScriptParser(antlr.LLkParser):
Left: e,
Right: rhs)
else:
- goto _loop285_breakloop
- :_loop285_breakloop
+ goto _loop286_breakloop
+ :_loop286_breakloop
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
@@ -4096,8 +4119,8 @@ class UnityScriptParser(antlr.LLkParser):
Left: e,
Right: rhs)
else:
- goto _loop288_breakloop
- :_loop288_breakloop
+ goto _loop289_breakloop
+ :_loop289_breakloop
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
@@ -4144,19 +4167,19 @@ class UnityScriptParser(antlr.LLkParser):
try: // for error handling
lbrack = LT(1)
match(LBRACK)
- synPredMatched296 as bool = false
+ synPredMatched297 as bool = false
if ((tokenSet_13_.member(cast(int, LA(1)))) and (tokenSet_55_.member(cast(int, LA(2))))):
- _m296 as int = mark()
- synPredMatched296 = true
+ _m297 as int = mark()
+ synPredMatched297 = true
++inputState.guessing
try:
expression()
match(FOR)
except x as RecognitionException:
- synPredMatched296 = false
- rewind(_m296)
+ synPredMatched297 = false
+ rewind(_m297)
--inputState.guessing
- if synPredMatched296:
+ if synPredMatched297:
projection=expression()
match(FOR)
match(LPAREN)
@@ -4245,8 +4268,8 @@ class UnityScriptParser(antlr.LLkParser):
if 0 == inputState.guessing:
dle.Items.Add(pair);
else:
- goto _loop304_breakloop
- :_loop304_breakloop
+ goto _loop305_breakloop
+ :_loop305_breakloop
elif ((_givenValue == RBRACE)): // 1831
pass // 947
else: // line 1969
@@ -4393,7 +4416,7 @@ class UnityScriptParser(antlr.LLkParser):
except ex as RecognitionException:
if (0 == inputState.guessing):
reportError(ex)
- recover(ex,tokenSet_37_)
+ recover(ex,tokenSet_38_)
else:
raise
return ep
@@ -4669,15 +4692,15 @@ class UnityScriptParser(antlr.LLkParser):
return data
public static final tokenSet_35_ = BitSet(mk_tokenSet_35_())
private static def mk_tokenSet_36_() as (long):
- data = (4611686018427387904L, 0L, )
+ data = (9080382714285645730L, 17188463409159L, 0L, 0L, )
return data
public static final tokenSet_36_ = BitSet(mk_tokenSet_36_())
private static def mk_tokenSet_37_() as (long):
- data = (1152921504606846976L, 2L, 0L, 0L, )
+ data = (4611686018427387904L, 0L, )
return data
public static final tokenSet_37_ = BitSet(mk_tokenSet_37_())
private static def mk_tokenSet_38_() as (long):
- data = (9080382714285645730L, 17188463409159L, 0L, 0L, )
+ data = (1152921504606846976L, 2L, 0L, 0L, )
return data
public static final tokenSet_38_ = BitSet(mk_tokenSet_38_())
private static def mk_tokenSet_39_() as (long):
View
6 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,6 +40,8 @@ class ApplySemantics(AbstractVisitorCompilerStep):
override def OnModule(module as Module):
SetUpDefaultImports(module)
+ if ModuleContainsOnlyTypeDefinitions(module):
+ return
script = FindOrCreateScriptClass(module)
MakeItPartial(script)
@@ -48,6 +51,9 @@ class ApplySemantics(AbstractVisitorCompilerStep):
module.Members.Add(script)
SetScriptClass(Context, script)
+ def ModuleContainsOnlyTypeDefinitions(module as Module):
+ return module.Globals.IsEmpty and module.Attributes.IsEmpty and module.Members.All({ m | m isa TypeDefinition })
+
def SetUpMainMethod(module as Module, script as TypeDefinition):
TransformGlobalVariablesIntoFields(module, script)
View
93 src/UnityScript/UnityScript.g
@@ -172,9 +172,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)
@@ -182,6 +179,9 @@ tokens
text = token.getText()
tokenLength = (0 if text is null else len(text)-1)
return SourceLocation(token.getLine(), token.getColumn()+tokenLength)
+
+ 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,
@@ -230,7 +230,42 @@ tokens
static def CreateModuleName(fname as string):
return System.IO.Path.GetFileNameWithoutExtension(fname)
-
+
+ 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 name == type.Name 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
+
+ def ValidateFunctionDeclaration(function as Method, getter as IToken, setter as IToken):
+ // 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 function.Parameters.Count != 1 or function.Parameters[0].Name != "value":
+ ReportError(UnityScriptCompilerErrors.InvalidPropertySetter(function.LexicalInfo))
+ function.Parameters.Clear()
+ return
+ if getter is not null:
+ if function.Parameters.Count > 0:
+ ReportError(UnityScriptCompilerErrors.InvalidPropertySetter(function.LexicalInfo))
}
start[CompileUnit cu]
@@ -524,15 +559,14 @@ interface_declaration[TypeDefinition parent] returns [TypeMember member]
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
+ { ValidateFunctionDeclaration(function, getter, setter) }
(
- COLON tr=type_reference { method.ReturnType = tr; }
+ COLON tr=type_reference { function.ReturnType = tr; }
)?
(EOS)*
;
@@ -598,42 +632,9 @@ function_member[ClassDefinition cd] returns [TypeMember member]
{
}:
FUNCTION (getter:GET | setter:SET)? memberName=identifier
- {
- 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)))
- }
+ { member = function = AddFunctionTo(cd, memberName, getter, setter) }
+ function_body[function]
+ { ValidateFunctionDeclaration(function, getter, setter) }
;
function_body[Method method]
View
9 tests/error-messages/for-with-unreachable-update.js
@@ -0,0 +1,9 @@
+/*
+for-with-unreachable-update.js(5,32): BCW0015: WARNING: Unreachable code detected.
+*/
+function Positive(n: int): boolean {
+ for (var i = 0; i < n; ++i) { // ++i is unreachable
+ return true;
+ }
+ return false;
+}
View
8 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;
+}
View
22 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());
View
10 tests/projects/interfaces/1-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());
View
3  tests/projects/interfaces/Interface.js
@@ -0,0 +1,3 @@
+interface Interface {
+ function get value(): int;
+}
View
8 tests/semantics/fields-1.js
@@ -9,14 +9,6 @@ public class Fields(Object):
public def constructor():
super()
-
-partial public class fields-1(UnityScript.Tests.MonoBehaviour):
-
- public virtual def Awake() as void:
- pass
-
- public def constructor():
- super()
*/
class Fields {
var FirstName:String;
Please sign in to comment.
Something went wrong with that request. Please try again.