Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
EasyLang/snippets.txt
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
119 lines (103 sloc)
3.2 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public TokenList getSourceTokenUntil(String... any) { | |
LinkedList<Token> queue = new LinkedList<Token>(); | |
while (true) { | |
Token token = getSourceToken(); | |
if (token == null || token.length() == 0) | |
break; | |
queue.add(token); | |
for (String s : any) { | |
if (token.equals(s)) { | |
return new TokenList(queue); | |
} | |
} | |
} | |
return new TokenList(queue); | |
} | |
--- | |
if( mytype.nativeClass instanceof RayInteger ) | |
{ | |
RayInteger ri = (RayInteger) mytype.nativeClass; | |
ri.setIntValue(Long.parseLong(value.s())); | |
} else if( mytype.nativeClass instanceof RayString && value.length() > 0) | |
{ | |
RayInteger ri = (RayInteger) mytype.nativeClass; | |
ri.setStringValue(value.s().substring(1,value.length()-2)); // remove quotes | |
} | |
--- | |
RayMethod method = rayVar.getType().getMethod(methodName.s()); | |
if (method == null) { | |
RayLog.warn("methodName.s() " + rayVar.getInstance() + " " + methodName.s()); | |
RayUtils.runtimeExcp("fuu"); | |
} | |
--- | |
/** | |
RaySource rsrc = new RaySource(); | |
rsrc.src = ta.getText().toCharArray(); | |
int i=0; | |
while (true) | |
{ | |
i++; | |
RayString rs = RayUtils.getSourceToken(rsrc); | |
if (rs == null || i>100) | |
break; | |
RayLog.log("'"+rs+"'"); | |
} | |
*/ | |
--- | |
/* | |
private RayString getToken2() | |
{ | |
int start, end; | |
if (src[pos] == ';') // ende | |
{ | |
// kill following ; \r \n ' '; | |
while ((pos < src.length) && ((src[pos] == ' ') || (src[pos] == '\t'))) | |
pos++; | |
} | |
else if ((pos < src.length) && ((src[pos] == '\n') || (src[pos] == '\r'))) | |
{ | |
} | |
else if (src[pos] == 'a') // var oder ident | |
{ | |
// kill following ; \r \n; | |
} | |
else if (src[pos] == '1') // nr anf | |
{ | |
// kill following ; \r \n; | |
} | |
while ((pos < src.length) && ((src[pos] == '\n') || (src[pos] == '\r'))) | |
pos++; | |
int p= pos; | |
while (true) | |
{ | |
if (p >= src.length) | |
if (p == pos) | |
return null; | |
else | |
{ | |
p--; | |
break; | |
} | |
if (src[p] == ';') | |
break; | |
p++; | |
} | |
int pp= pos; | |
pos= p + 1; | |
// RayLog.log( pp + " " + pos); | |
return new RayString(src, pp, p); | |
} | |
*/ | |
--- | |
from RayMethod: | |
protected RayVar makeARayVar(RayClass rayClass, String varType, String varName, String instanceType, List<RayClassInterface> params) { | |
RayClassInterface varTypeClass = RayLang.instance.getClass(varType); | |
if (varTypeClass == null) | |
RayUtils.runtimeExcp(varType + " not found"); | |
RayClassInterface instanceTypeClass = RayLang.instance.getClass(instanceType); | |
RayUtils.assert_(instanceTypeClass == varTypeClass, instanceTypeClass + " != " + varTypeClass); // check for inhertiance ? // TODO: check using equals ? | |
Visibility v = Visibility.protected_; | |
RayVar rayVar = new RayVar(v, varType, varName); | |
rayVar.setValue(instanceTypeClass.getNewInstance(params)); | |
return rayVar; | |
} | |