/** * Fortran: create identifier. * * @param name symbol name * @param t type * @param isFcommon if is declare as common variable * @param isDecl 1. copy type if type is function/subroutine which is not external if true. 2. add * declaration if true. * @param xobjFile XobjectFile in current context * @return created identifier */ public static Ident Fident( String name, Xtype t, boolean isFcommon, boolean isDecl, XobjectFile xobjFile) { Xcode code; StorageClass sclass; if (t == null) { code = null; sclass = StorageClass.FCOMMON_NAME; } else { if (t.isFunction()) { code = Xcode.FUNC_ADDR; sclass = StorageClass.FFUNC; if (!t.isFexternal()) { if (isDecl) { if (t.isFsubroutine()) t = Xtype.FexternalSubroutineType.copy(); else if (t.getRef().isBool()) t = Xtype.FexternalLogicalFunctionType.copy(); else if (t.getRef().isIntegral()) t = Xtype.FexternalIntFunctionType.copy(); else { if (xobjFile == null) throw new IllegalStateException("xobjFile is null"); t = t.copy(); t.setIsFexternal(true); t.generateId(); xobjFile.addType(t); } } else { t = t.copy(); } } } else { code = Xcode.VAR; sclass = isFcommon ? StorageClass.FCOMMON : StorageClass.FLOCAL; } } Xobject addr = null; if (t == null || t.isFunction()) isFcommon = false; if (code != null) { addr = Xcons.Symbol(code, t, name); addr.setIsDelayedDecl(isDecl); addr.setIsToBeFcommon(isFcommon); } Ident id = new Ident(name, sclass, t, addr, VarScope.LOCAL, null); id.setIsToBeFcommon(isFcommon); return id; }
public static Ident TempVar(int num, Xtype t) { if (t.isArray()) { t = Xtype.Pointer(t.getRef()); // convert to pointer return new Ident(num, t); } else return new Ident(num, t); }