gw.lang.parser.Keyword.getName()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(109)

本文整理了Java中gw.lang.parser.Keyword.getName()方法的一些代码示例,展示了Keyword.getName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Keyword.getName()方法的具体详情如下:
包路径:gw.lang.parser.Keyword
类名称:Keyword
方法名:getName

Keyword.getName介绍

暂无

代码示例

代码示例来源:origin: org.gosu-lang.gosu/gosu-core-api

public String keyword() {
 switch( this ) {
  case Enhancement:
   return Keyword.KW_enhancement.getName();
  case Interface:
   return Keyword.KW_interface.getName();
  case Structure:
   return Keyword.KW_structure.getName();
  case Annotation:
   return Keyword.KW_annotation.getName();
  case Enum:
   return Keyword.KW_enum.getName();
  case Class:
  case Program:
  case Template:
  case Eval:
  case JavaClass:
    return Keyword.KW_class.getName();
  default:
   return "<unknown>";
 }
}

代码示例来源:origin: gosu-lang/old-gosu-repo

public static boolean isExactKeywordMatch( String strValue )
{
 Keyword keyword = RESERVED_WORDS.get( strValue );
 return keyword.getName().equals( strValue );
}

代码示例来源:origin: org.gosu-lang.gosu/gosu-core

public ThisSymbol( IType thisType, ISymbolTable symTable )
 {
  super( Keyword.KW_this.getName(), thisType, symTable, null );
  setModifiers( Modifier.FINAL );
 }
}

代码示例来源:origin: gosu-lang/old-gosu-repo

public ThisSymbol( IType thisType, ISymbolTable symTable )
 {
  super( Keyword.KW_this.getName(), thisType, symTable, null );
  setModifiers( Modifier.FINAL );
 }
}

代码示例来源:origin: org.gosu-lang.gosu/gosu-core

private boolean isSuperCall( Expression rootExpression, Expression indexExpression )
{
 return indexExpression instanceof TypeLiteral &&
     rootExpression instanceof Identifier &&
     ((Identifier)rootExpression).getSymbol().getName().equals( Keyword.KW_super.getName() );
}

代码示例来源:origin: org.gosu-lang.gosu/gosu-core

private Symbol makeThisSymbol()
{
 return new ReadOnlySymbol( Keyword.KW_this.getName(), TypeLord.getConcreteType( _gosuClass ), Symbol.MEMBER_STACK_PROVIDER, null );
}

代码示例来源:origin: gosu-lang/old-gosu-repo

private Symbol makeThisSymbol()
{
 return new ReadOnlySymbol( Keyword.KW_this.getName(), TypeLord.getConcreteType( _gosuClass ), Symbol.MEMBER_STACK_PROVIDER, null );
}

代码示例来源:origin: gosu-lang/old-gosu-repo

private ISymbol findSymbol( String strName, ISymbolTable symTable, boolean ignoreFunctionSymbols )
{
 if( Keyword.KW_this.getName().equals( strName ) ) {
  if( isEvalClass() ) {
   // In eval expressions 'this' = 'outer' since the eval expression is wrapped in an anonymous inner class
   strName = Keyword.KW_outer.getName();
  }
  else if( getGosuClass() instanceof IGosuProgram ) {
   // 'this' must be an external symbol for non-eval programs e.g., debugger expressions
   return null;
  }
 }
 ISymbol sym = symTable.getSymbol( strName );
 if( sym == null && !ignoreFunctionSymbols )
 {
  List dfsDecls = getOwner().getDfsDeclsForFunction( strName );
  sym = dfsDecls.isEmpty() ? null : (ISymbol)dfsDecls.get( dfsDecls.size() - 1 );
 }
 return sym;
}

代码示例来源:origin: gosu-lang/old-gosu-repo

private boolean isThisPointer( Expression expr )
{
 return expr != null &&
     expr instanceof Identifier &&
     ((Identifier)expr).getSymbol() != null &&
     Keyword.KW_this.getName().equals( ((Identifier)expr).getSymbol().getName() );
}

代码示例来源:origin: org.gosu-lang.gosu/gosu-core

private boolean isThisPointer( Expression expr )
{
 return expr != null &&
     expr instanceof Identifier &&
     ((Identifier)expr).getSymbol() != null &&
     Keyword.KW_this.getName().equals( ((Identifier)expr).getSymbol().getName() );
}

代码示例来源:origin: org.gosu-lang.gosu/gosu-core

private ISymbol findSymbol( String strName, ISymbolTable symTable, boolean ignoreFunctionSymbols )
{
 if( Keyword.KW_this.getName().equals( strName ) ) {
  if( isEvalClass() ) {
   // In eval expressions 'this' = 'outer' since the eval expression is wrapped in an anonymous inner class
   strName = Keyword.KW_outer.getName();
  }
  else if( getGosuClass() instanceof IGosuProgram ) {
   // 'this' must be an external symbol for non-eval programs e.g., debugger expressions
   return null;
  }
 }
 ISymbol sym = symTable.getSymbol( strName );
 if( sym == null && !ignoreFunctionSymbols )
 {
  List dfsDecls = getOwner().getDfsDeclsForFunction( strName );
  sym = dfsDecls.isEmpty() ? null : (ISymbol)dfsDecls.get( dfsDecls.size() - 1 );
 }
 return sym;
}

代码示例来源:origin: gosu-lang/old-gosu-repo

protected IRExpression pushThis()
{
 String symbolName = (isCompilingEnhancement() ? GosuClassTransformer.ENHANCEMENT_THIS_REF : Keyword.KW_this.getName() );
 return identifier( _cc.getSymbol( symbolName ) );
}

代码示例来源:origin: org.gosu-lang.gosu/gosu-core

protected IRExpression pushThis()
{
 String symbolName = (isCompilingEnhancement() ? GosuClassTransformer.ENHANCEMENT_THIS_REF : Keyword.KW_this.getName() );
 return identifier( _cc.getSymbol( symbolName ) );
}

代码示例来源:origin: org.gosu-lang.gosu/gosu-core

private void transferModifierInfo( ParsedElement stmt, ModifierInfo modifiers, AnnotationUseSiteTarget target, EnhancementDynamicFunctionSymbol dfs )
{
 ModifierInfo paramModifiers = dfs.getReceiver().getModifierInfo();
 // Note, we remove existing so as not to duplicate annos.
 // Also note, the annos added during decl time don't have arg expression, those are parsed only during
 // defn time, thus we have to re-add them here so we have the full annotation expression with args.
 paramModifiers.setAnnotations( Collections.emptyList() );
 for( Iterator<IGosuAnnotation> iter = modifiers.getAnnotations().iterator(); iter.hasNext(); )
 {
  IGosuAnnotation anno = iter.next();
  if( anno.getTarget() == AnnotationUseSiteTarget.receiver && target == AnnotationUseSiteTarget.receiver )
  {
   // annotation targets 'receiver', apply exclusively to enhancement method
   if( appliesToElementType( anno, ElementType.PARAMETER ) )
   {
    if( stmt != null )
    {
     verify( stmt, !anno.isJavaAnnotation() || !GosuClassParser.violatesRepeatable( paramModifiers.getAnnotations(), anno ), Res.MSG_TOO_MANY_ANNOTATIONS, anno.getName(), Keyword.KW_receiver.getName() );
    }
    paramModifiers.addAnnotation( anno );
    // annotation exclusively targets param, remove it from further applications
    iter.remove();
   }
  }
 }
}

代码示例来源:origin: org.gosu-lang.gosu/gosu-lab

private ISymbolTable makeSymTable( Location loc, IType outermostType )
{
 if( outermostType instanceof IGosuClass )
 {
  return ContextSymbolTableUtil.getSymbolTableAtOffset( (IGosuClass)outermostType, StringUtil.getLineOffset( ((IGosuClass)outermostType).getSource(), loc.lineNumber() ) );
 }
 StandardSymbolTable symTable = new StandardSymbolTable();
 IType thisType = TypeSystem.getByFullNameIfValid( loc.declaringType().name().replace( '$', '.' ) );
 if( thisType != null )
 {
  symTable.putSymbol( GosuShop.createSymbol( Keyword.KW_this.getName(), thisType, null ) );
 }
 return symTable;
}

代码示例来源:origin: gosu-lang/old-gosu-repo

public void pushScope( boolean bInitialInstanceMethodScope )
{
 if( _scopes == null )
 {
  _scopes = new Stack<IRScope>();
 }
 IRScope parent = _scopes.isEmpty() ? null : _scopes.peek();
 _scopes.push( new IRScope( parent ) );
 if( bInitialInstanceMethodScope )
 {
  assert parent == null;
  _scopes.peek().addSymbol( Keyword.KW_this.getName(), _context.getIRTypeForCurrentClass() );
 }
}

代码示例来源:origin: org.gosu-lang.gosu/gosu-core

public void pushScope( boolean bInitialInstanceMethodScope )
{
 if( _scopes == null )
 {
  _scopes = new Stack<IRScope>();
 }
 IRScope parent = _scopes.isEmpty() ? null : _scopes.peek();
 _scopes.push( new IRScope( parent ) );
 if( bInitialInstanceMethodScope )
 {
  assert parent == null;
  _scopes.peek().addSymbol( Keyword.KW_this.getName(), _context.getIRTypeForCurrentClass() );
 }
}

代码示例来源:origin: org.gosu-lang.gosu/gosu-core

private void implementToString()
{
 Identifier thisId = new Identifier();
 thisId.setSymbol( new Symbol( Keyword.KW_this.getName(), this, null ), new StandardSymbolTable() );
 thisId.setType( this );
 BeanMethodCallExpression toStrCall = new BeanMethodCallExpression();
 toStrCall.setMethodDescriptor( JavaTypes.IBLOCK().getTypeInfo().getMethod( "toString" ) );
 toStrCall.setRootExpression( thisId );
 toStrCall.setType( JavaTypes.STRING() );
 ReturnStatement returnStmt = new ReturnStatement();
 returnStmt.setValue( toStrCall );
}

代码示例来源:origin: gosu-lang/old-gosu-repo

private void implementToString()
{
 Identifier thisId = new Identifier();
 thisId.setSymbol( new Symbol( Keyword.KW_this.getName(), this, null ), new StandardSymbolTable() );
 thisId.setType( this );
 BeanMethodCallExpression toStrCall = new BeanMethodCallExpression();
 toStrCall.setMethodDescriptor( JavaTypes.IBLOCK().getTypeInfo().getMethod( "toString" ) );
 toStrCall.setRootExpression( thisId );
 toStrCall.setType( JavaTypes.STRING() );
 ReturnStatement returnStmt = new ReturnStatement();
 returnStmt.setValue( toStrCall );
}

代码示例来源:origin: org.gosu-lang.gosu/gosu-core

private void putThisAndSuperSymbols( ModifierInfo modifiers )
{
 if( !Modifier.isStatic( modifiers.getModifiers() ) &&
     getScriptPart() != null &&
     (getScriptPart().getContainingType() instanceof IGosuClassInternal) )
 {
  IGosuClassInternal gsClass = (IGosuClassInternal)getScriptPart().getContainingType();
  IType thisType = gsClass;
  if( gsClass instanceof IGosuEnhancementInternal )
  {
   thisType = ((IGosuEnhancementInternal)gsClass).getEnhancedType();
  }
  if( thisType != null )
  {
   thisType = TypeLord.getConcreteType( thisType );
   getSymbolTable().putSymbol( new ThisSymbol( thisType, _symTable ) );
   if( !(gsClass instanceof IGosuEnhancementInternal) )
   {
    IGosuClassInternal superClass = gsClass.getSuperClass();
    if( superClass == null )
    {
     superClass = IGosuClassInternal.Util.getGosuClassFrom( JavaTypes.OBJECT() );
    }
    getSymbolTable().putSymbol( new Symbol( Keyword.KW_super.getName(), superClass, _symTable, null ) );
   }
  }
 }
}

相关文章