private Node buildFormal(Formal f) throws SemanticException // Based on buildLocalDecl. { Type t = f.declType(); SJLocalInstance li = (SJLocalInstance) f.localInstance(); if (t.isSubtype(SJ_ABSTRACT_CHANNEL_TYPE)) { if (!(f instanceof SJFormal)) { throw new SemanticException( "[SJProtocolDeclTypeBuilder] Session socket parameters should be declared by their session type: " + f); } SJTypeNode tn = disambiguateSJTypeNode(this, ((SJFormal) f).sessionType()); SJSessionType st = tn.type(); String sjname = f.name(); // Should match that given by SJVariable.sjname. f = f.localInstance(sjts.SJLocalProtocolInstance(li, st, sjname)); f = setSJFormalExt((SJFormal) f, tn, sjname); } return f; }
private Node buildLocalDecl(LocalDecl ld) throws SemanticException { Type t = ld.declType(); SJLocalInstance li = (SJLocalInstance) ld.localInstance(); // SJNamedInstance ni = null; if (t.isSubtype(SJ_PROTOCOL_TYPE)) // Mostly the same as for LocalDecl. { if (!(ld instanceof SJLocalProtocolDecl)) { throw new SemanticException( "[SJProtocolDeclTypeBuilder] Protocols may only be declared using the protocol keyword: " + ld); } SJTypeNode tn = disambiguateSJTypeNode(this, ((SJProtocolDecl) ld).sessionType()); SJSessionType st = tn.type(); String sjname = ld.name(); // Should match that given by SJVariable.sjname. ld = ld.localInstance(sjts.SJLocalProtocolInstance(li, st, sjname)); ld = (LocalDecl) setSJProtocolDeclExt((SJProtocolDecl) ld, tn, sjname); } return ld; }